[Ansible] NFS Server-Client 구성

tedigom·2021년 2월 20일
0
post-custom-banner

Ansible을 공부하면서 NFS 서버 및 클라이언트를 구성하는 playbook sample code를 작성한다.

# nfs-ansible-playbook.yaml


---
- name: nfs server setup
  hosts: server
  gather_facts: no
  become: yes
  
  tasks:
    - name: make directory (nfs_shared)
      file:
        path: /home/vagrant/nfs_shared
        state: directory
        mode: 0777
        
    - name: /etc/exports configuration
      lineinfile:
        path: /etc/exports
        line: /home/vagrant/nfs_shared xxx.xxx.xxx.xxx/24(rw,sync)
        # client IP 대역 작성
    
    - name: nfs service restart
      service:
        name: nfs
        state: restarted
    


- name: nfs client setup
  hosts: client
  gather_facts: no
  become: yes
  
  tasks:
    - name: make directory_nfs
      file:
        path: /home/vagrant/nfs
        state: directory
        
    - name: make mountpoint
      mount:
        path: /home/vagrant/nfs
        src: xxx.xxx.xxx.xxx:/home/vagrant/nfs_shared
        # 소스 IP 작성
        fstype: nfs
        state: mounted
  
profile
아키텍처(Infra / SW), 클라우드, 모바일에 관심이 많습니다. 쉬운말로 쓰려 노력합니다
post-custom-banner

0개의 댓글