separating out nfs_setup - conflict with hosts and vars_prompt when used with include_task
This commit is contained in:
20
coretasks/nfs_setup.yml
Normal file
20
coretasks/nfs_setup.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
tasks:
|
||||||
|
- name: install_nfs_client_packages
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: "{{ 'nfs-common' if ansible_os_family == 'Debian' else 'nfs-utils' }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: ensure_local_mount_dir_exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ nfs_client_path }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: configure_mount_nfs
|
||||||
|
ansible.posix.mount:
|
||||||
|
src: "{{ nfs_server }}:{{ nfs_server_path }}"
|
||||||
|
path: "{{ nfs_client_path }}"
|
||||||
|
fstype: nfs
|
||||||
|
opts: rw,sync,hard,intr
|
||||||
|
state: mounted
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: run_nfs_setup_if_not_mounted
|
- name: run_nfs_setup_if_not_mounted
|
||||||
ansible.builtin.include_tasks: "{{ playbook_dir }}/nfs_setup.yml"
|
ansible.builtin.include_tasks: "{{ playbook_dir }}/coretasks/nfs_setup.yml"
|
||||||
vars:
|
vars:
|
||||||
nfs_client_path: "{{ media_path }}"
|
nfs_client_path: "{{ media_path }}"
|
||||||
when: nfs_check.rc != 0 and nfs_server != ""
|
when: nfs_check.rc != 0 and nfs_server != ""
|
||||||
|
|||||||
13
nfs_config.yml
Normal file
13
nfs_config.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
- name: setup_nfs_mount
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
vars_prompt:
|
||||||
|
- name: nfs_server
|
||||||
|
prompt: "Enter NFS Server IP or hostname"
|
||||||
|
private: no
|
||||||
|
- name: nfs_server_path
|
||||||
|
prompt: "Enter remote path on the NFS server (e.g. /exports/media)"
|
||||||
|
private: no
|
||||||
|
- name: nfs_client_path
|
||||||
|
prompt: "Enter local mount path (e.g. /mnt/media)"
|
||||||
|
private: no
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
- name: setup_nfs_mount
|
|
||||||
hosts: all
|
|
||||||
become: true
|
|
||||||
vars_prompt:
|
|
||||||
- name: nfs_server
|
|
||||||
prompt: "Enter NFS Server IP or hostname"
|
|
||||||
private: no
|
|
||||||
- name: nfs_server_path
|
|
||||||
prompt: "Enter remote path on the NFS server (e.g. /exports/media)"
|
|
||||||
private: no
|
|
||||||
- name: nfs_client_path
|
|
||||||
prompt: "Enter local mount path (e.g. /mnt/media)"
|
|
||||||
private: no
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: install_nfs_client_packages
|
|
||||||
ansible.builtin.package:
|
|
||||||
name: "{{ 'nfs-common' if ansible_os_family == 'Debian' else 'nfs-utils' }}"
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: ensure_local_mount_dir_exists
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: "{{ nfs_client_path }}"
|
|
||||||
state: directory
|
|
||||||
mode: '0755'
|
|
||||||
|
|
||||||
- name: configure_mount_nfs
|
|
||||||
ansible.posix.mount:
|
|
||||||
src: "{{ nfs_server }}:{{ nfs_server_path }}"
|
|
||||||
path: "{{ nfs_client_path }}"
|
|
||||||
fstype: nfs
|
|
||||||
opts: rw,sync,hard,intr
|
|
||||||
state: mounted
|
|
||||||
Reference in New Issue
Block a user