[Ansible] 03. Playbook 작성

Date:     Updated:

카테고리:

태그:

[Ansible] 03. Playbook 작성


🔔 자세한 모듈 내용은 아래 문서를 참고

모듈 내용 : https://docs.ansible.com/ansible/latest/collections/ansible/builtin/index.html#modules

예제 Github : https://github.com/revenge1005/Ansible_study


🔔 간단한 Playbook 작성

(a) 📜 Apache Install

$ cat <<EOF > install_apache.yml
---

- hosts: all
  become: true
  tasks:

  - name: update repository index
    dnf:
      update_cache: yes

  - name: install httpd package
    dnf:
      name: httpd
      state: latest

  - name: httpd Service Start & enable
    service:
      name: httpd
      state: started
      enabled: yes
EOF

$ ansible-playbook --ask-become-pass install_apache.yml

01


(b) 📜 Apache Remove

cat <<EOF > remove_apache.yml
---

- hosts: all
  become: true
  tasks:

  - name: httpd Service Stop
    service:
      name: httpd
      state: stopped 

  - name: remove httpd package
    dnf:
      name: httpd
      state: absent
EOF

$ ansible-playbook --ask-become-pass remove_apache.yml

02


ANSIBLE 카테고리 내 다른 글 보러가기

댓글 남기기