Initialisation depot
This commit is contained in:
41
Migration/Ansible/roles/nfs/tasks/main.yml
Normal file
41
Migration/Ansible/roles/nfs/tasks/main.yml
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
# NFS Client Role - Main Tasks
|
||||
|
||||
- name: Ensure required variables are present
|
||||
assert:
|
||||
that:
|
||||
- nfs_mounts is defined or (nfs_server is defined and nfs_share is defined and nfs_mount_point is defined)
|
||||
fail_msg: "You must define either 'nfs_mounts' (a list of mounts) or the trio 'nfs_server', 'nfs_share' and 'nfs_mount_point'."
|
||||
|
||||
- name: Install nfs-common package (Debian/Ubuntu)
|
||||
apt:
|
||||
name: nfs-common
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: Build `nfs_mounts` list from single-vars if needed
|
||||
set_fact:
|
||||
nfs_mounts: "{{ [ {'server': nfs_server, 'share': nfs_share, 'path': nfs_mount_point, 'options': (nfs_options | default(omit)) } ] }}"
|
||||
when: nfs_mounts is not defined
|
||||
|
||||
- name: Validate each NFS server is reachable (port 2049)
|
||||
wait_for:
|
||||
host: "{{ item.server }}"
|
||||
port: 2049
|
||||
timeout: 5
|
||||
state: started
|
||||
loop: "{{ nfs_mounts }}"
|
||||
loop_control:
|
||||
label: "{{ item.server }}:{{ item.share }}"
|
||||
|
||||
- name: Ensure the NFS share is exported by the server
|
||||
shell: |
|
||||
showmount -e {{ item.server }} | awk 'NR>1 {print $1}' | grep -x -- "{{ item.share }}"
|
||||
register: showmount_check
|
||||
failed_when: showmount_check.rc != 0
|
||||
changed_when: false
|
||||
loop: "{{ nfs_mounts }}"
|
||||
loop_control:
|
||||
label: "{{ item.server }}:{{ item.share }}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user