[root@vagrant ~]# mkdir /nfs\\
[root@vagrant nfs]# cd /nfs
[root@vagrant nfs]# vi nfs.yml
- name: Setup for ALL
hosts: all
gather_facts: no
become: yes
tasks:
- name: Install nfs-utils
yum:
name: nfs-utils
state: present
- name: selinux disable
shell: setenforce 0
- name: stop firewall
service:
name: firewalld
state: stopped
enabled: false
- name: Setup for nfs server
hosts: server
gather_facts: no
become: yes
tasks:
- name: make nfs_shared directory
file:
path: /shared
state: directory
mode: 0777
- name: configure /etc/exports
lineinfile:
path: /etc/exports
line: /shared 192.168.122.*(rw)
- name: nfs service restart
become: yes
service:
name: nfs
state: restarted
- name: Setup for nfs clients
hosts: client
gather_facts: no
become: yes
tasks:
- name: make nfs_client directory
file:
path: /remote
state: directory
- name: mount directory
become: yes
mount:
name: /remote
src: 192.168.122.204:/shared
fstype: nfs
state: mounted
[root@vagrant nfs]# ansible-playbook -i nfs_inven.txt nfs.yml -k
[root@vagrant nfs]# virsh console centos2
[root@vagrant nfs]# virsh console centos3
해서 /remote에 파일 만들고
[root@vagrant nfs]# virsh console centos1
해서 /shared에 반영되었는지 확인