ubuntu 노드 2개 추가 후
nfs.yaml
---
- name: setup for nfs server
hosts: localhost
gather_facts: no
tasks:
- name: make nfs_shared directory
file:
path: /home/vagrant/nfs_shared
state: directory
mode: 0755
- name: configure /etc/exports
become: yes
lineinfile:
path: /etc/exports
line: /home/vagrant/nfs_shared 192.168.110.0/24(rw,no_root_squash,sync)
- name: nfs service restart
become: yes
service:
name: nfs
state: restarted
- name: setup for nfs clients - second play
hosts:
- centos
- ubuntu
# gather_facts: yes ; gather_facts 의 디폴트 값은 yes 이므로 주석해제해도 결과는 같습니다.
tasks:
- name: installed nfs-utils on centos
become: yes
yum:
name: nfs-utils
state: present
when: ansible_facts['os_family'] == "RedHat"
- name: install nfs-common on ubuntu
become: yes
apt:
name: nfs-common
update_cache: yes
when: ansible_facts['os_family'] == "Debian"
- name: make nfs_client_directorY
file:
path: /home/vagrant/nfs
state: directory
- name: mount point directory as client
become: yes
mount:
path: /home/vagrant/nfs
src: 192.168.110.10:/home/vagrant/nfs_shared
fstype: nfs
opts: nfsvers=4
state: mounted
ansible-playbook nfs.yaml
ansible ubuntu -m shell -a "df -h" -k
[vagrant@control work]$ ansible ubuntu -m shell -a "df -h" -k
SSH password:
node5 | CHANGED | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
tmpfs 197M 964K 196M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 62G 5.2G 54G 9% /
tmpfs 983M 0 983M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 234M 1.6G 13% /boot
192.168.110.10:/home/vagrant/nfs_shared 40G 3.5G 37G 9% /home/vagrant/nfs
tmpfs 197M 4.0K 197M 1% /run/user/1000
node4 | CHANGED | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
tmpfs 197M 964K 196M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 62G 5.2G 54G 9% /
tmpfs 983M 0 983M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 234M 1.6G 13% /boot
192.168.110.10:/home/vagrant/nfs_shared 40G 3.5G 37G 9% /home/vagrant/nfs
tmpfs 197M 4.0K 197M 1% /run/user/1000
마운트 되었다는 것을 확인 할 수 있다.
'Ansible' 카테고리의 다른 글
| Ansible 미니 프로젝트 (0) | 2024.02.22 |
|---|---|
| ansible!!! (1) | 2024.02.15 |
| ansible 에러 (0) | 2024.02.14 |
| ansible 기본 환경설정 (2) | 2024.02.13 |
| ansible 수요일 (1) | 2024.02.07 |