[Ansible] 03. Playbook 작성
카테고리: ANSIBLE
태그: ansible
[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

(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

댓글 남기기