Installs samba mount utils and configures cifs mounts.
Variable name | Type | Default | Description |
---|---|---|---|
cifs_packages | list | cifs-utils, smbclient | The packages required for samba mounting and client activities |
cifs_mounts | list[dict] | [] | A list of cifs mounts to configure |
∟.path | file path | The mount point on the host machine | |
∟.cifs_path | samba path | The samba share to mount | |
∟.opts | list[opt strings] | The cifs mount options (see mount.cifs).* | |
∟.dump | int | option omitted if not set | See ansible mount for details. |
∟.passno | int | option omitted if not set | See ansible mount for details. |
∟.state | string | present | The mount state (see ansible mount) |
∟.credentials | dict | Special dictionary to define the credentials file. Allows files to be created by giving username/password or copied given src and destination path.* | |
∟.credentials.username | string | User, if the credentials file should be created | |
∟.credentials.password | string | Password, if the credentials file should be created | |
∟.credentials.domain | string | The samba domain, if the credentials file should be created (optional) | |
∟.credentials.owner | string | The file owner, if the credentials file should be created (optional) | |
∟.credentials.mode | string | 0600 | The file permissions, if the credentials file should be created (optional) |
∟.credentials.path | file path | The destination path, if the credentials file is to be copied or created on the ansible host. Also used for the credentials option. | |
∟.credentials.src | file path | The source path, if the credentials file is to be copied to the ansible host |
*Note that the credentials
option can be set through the .credentials
variable if the credentials file should be automatically created or copied to the host.
Immediately mount a single share as guest with rw permissions
- hosts: "{{ test_host | default('localhost') }}"
roles:
- role: cifs-mounts
vars:
cifs_mounts:
- path: /mnt/test
cifs_path: //example/test
opts:
- guest
- rw
state: mounted
Add two mount entries in fstab, without immediately mounting, one using inline credentials and the other one with a credentials file created by the role.
- hosts: "{{ test_host | default('localhost') }}"
roles:
- role: cifs-mounts
vars:
cifs_mounts:
- path: /mnt/test
cifs_path: //example/test
opts:
- username=test
- password=test
state: present
- path: /mnt/test2
cifs_path: //example/test2
credentials:
username: test2
password: test2
path: /home/test/cifs.credentials
state: present