This role is used for simplified mounting of file shares.
This is currently in an early stage and only works for smb shares
none
These are all variables
Parameter | Description | Default Value |
---|---|---|
smb_shares |
Dictionary of smb (cifs) shares to mount, see Parameters for smb_shares |
- |
smb_credentials_dir |
Directory where to put credentials file | /etc |
sshfs_shares |
Dictionary of sshfsshares to mount, see Parameters for sshfs_shares |
- |
smb_shares
are always mounted with type cifs
and in state mounted
. However there are some options to provide:
Parameter | Description | Default Value |
---|---|---|
path |
[Mandatory] Path to the mount point | - |
src |
[Mandatory] Device to be mounted on path |
- |
options |
Mount options (see fstab(5), or vfstab(4) on Solaris) | - |
mounted |
Whether the share shall be mounted (true ) or not (false ) |
true |
owner |
Owner of the path |
ansible_user |
group |
Group of the path |
ansible_user |
credentials |
If defined the role will add a credentials file at /etc/sharename . The role will aggregate the credential file to the options as -o credentials=/etc/sharename . |
- |
credentials.username |
Username to connect to src , will be added to credentials file |
- |
credentials.password |
Password to connect to src , will be added to credentials file. I recommend to encrypt the password |
- |
credentials.domain |
Domain to connect to src , will be added to credentials file |
- |
sharename
represent the key for each share at smb_shares
i.e. for the example below we have demo
and freenas
sshfs_shares
are always mounted with type fuse.sshfs
and in state mounted
. However there are some options to provide:
Parameter | Description | Default Value |
---|---|---|
path |
[Mandatory] Path to the mount point | - |
host |
[Mandatory] Hostname to be mounted on path |
- |
target_path |
[Mandatory] Target path on host |
- |
user |
[Mandatory] User to connect to host |
- |
owner |
Owner of the path |
ansible_user |
group |
Group of the path |
ansible_user |
options |
Mount options (see fstab(5), or vfstab(4) on Solaris) | - |
mounted |
Whether the share shall be mounted (true ) or not (false ) |
true |
Examples:
smb_shares:
demo: # share which uses no credentails
path: /mnt/demo
src: //192.168.0.1/demo
options: file_mode=0777,dir_mode=0777,rw,uid=1000,gid=1000
mounted: no # will unmount
freenas: # share with credentials
path: /mnt/freenas
src: //192.168.0.1/media
options: file_mode=0777,dir_mode=0777,rw,uid=1000,gid=1000
credentials:
username: usera
passsword: MySmbPassword
domain: domain
mounted: true
Remark
I recommend to use
ansible-vault
to encryptusername
andpassword
none
The following example installs an ssh-tunnel for each server
---
- hosts: localhost
vars:
smb_shares:
demo: # share which uses no credentials
path: /mnt/demo
src: //192.168.0.1/demo
options: file_mode=0777,dir_mode=0777,rw,uid=1000,gid=1000
owner: papanito
group: papanito
freenas: # share with credentials
path: /mnt/freenas
src: //192.168.0.1/media
options: file_mode=0777,dir_mode=0777,rw,uid=1000,gid=1000
credentials:
username: usera
passsword: MySmbPassword
domain: domain
sshfs_shares:
yunohost:
path: /mnt/myhost
host: myhost
user: papanito
owner: papanito
group: papanito
target_path: /home/papanito
options: "noauto,x-systemd.automount,_netdev,reconnect,identityfile=/home/papanito/.ssh/id_rsa,allow_other,default_permissions"
roles:
- papanito.diskmounter
This is Free Software, released under the terms of the Apache v2 license.