generalize role to a generale mount role
This commit is contained in:
parent
1e93481389
commit
0ab1f2d078
3 changed files with 30 additions and 24 deletions
|
|
@ -1 +1 @@
|
||||||
nfs: {}
|
mounts: {}
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,8 @@
|
||||||
- name: install nfs client tools
|
- name: install nfs client tools
|
||||||
package:
|
package:
|
||||||
name: nfs-client
|
name: nfs-client
|
||||||
|
when: mounts.values()|selectattr("type", "equalto", "nfs")|list|length > 0
|
||||||
|
|
||||||
- name: create mount points if they don't exist
|
- name: handle single mount
|
||||||
with_dict: "{{ nfs }}"
|
include_tasks: mount.yml
|
||||||
file:
|
loop: "{{ mounts|dict2items }}"
|
||||||
path: "{{ item.value.mountpoint }}"
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
- name: mount nfs shares
|
|
||||||
with_dict: "{{ nfs }}"
|
|
||||||
mount:
|
|
||||||
path: "{{ item.value.mountpoint }}"
|
|
||||||
src: "{{ item.value.source }}"
|
|
||||||
opts: "{{ item.value.options }}"
|
|
||||||
fstype: nfs
|
|
||||||
state: mounted
|
|
||||||
|
|
||||||
- name: write nfs shares to fstab
|
|
||||||
with_dict: "{{ nfs }}"
|
|
||||||
mount:
|
|
||||||
path: "{{ item.value.mountpoint }}"
|
|
||||||
src: "{{ item.value.source }}"
|
|
||||||
opts: "{{ item.value.options }}"
|
|
||||||
fstype: nfs
|
|
||||||
state: present
|
|
||||||
|
|
|
||||||
25
tasks/mount.yml
Normal file
25
tasks/mount.yml
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
- set_fact:
|
||||||
|
mount: "{{ {}|combine(item.value, { 'mountpoint': item.key }, recursive=True) }}"
|
||||||
|
|
||||||
|
- name: "create mount point {{ mount.mountpoint }}"
|
||||||
|
file:
|
||||||
|
path: "{{ mount.mountpoint }}"
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: "mount {{ mount.mountpoint }}"
|
||||||
|
mount:
|
||||||
|
path: "{{ mount.mountpoint }}"
|
||||||
|
src: "{{ mount.source }}"
|
||||||
|
opts: "{{ mount.options }}"
|
||||||
|
fstype: "{{ mount.type }}"
|
||||||
|
passno: "{{ mount.passno|d(0) }}"
|
||||||
|
state: mounted
|
||||||
|
|
||||||
|
- name: "write mount {{ mount.mountpoint }} to fstab"
|
||||||
|
mount:
|
||||||
|
path: "{{ mount.mountpoint }}"
|
||||||
|
src: "{{ mount.source }}"
|
||||||
|
opts: "{{ mount.options }}"
|
||||||
|
fstype: "{{ mount.type }}"
|
||||||
|
passno: "{{ mount.passno|d(0) }}"
|
||||||
|
state: present
|
||||||
Loading…
Add table
Add a link
Reference in a new issue