Ansible Study - Playbooks
- Inventory 에서 정의된 호스트에서 무엇을 해야할지를 정의한 것.
- 자동화 절차를 기술한 코드 파일 코드 Set을 의미함.
- YAML 형식으로 기록
- playbook의 목표는 호스트의 그룹을 정의된 Ansible내에서 테스크로 불리는 역할(Role)에 매핑해주는 것
hosts 1개, 기본
-
name: 'Execute two commands on localhost'
hosts: web_node1
tasks:
- name: 'Execute a date command'
command: date
- name: 'Execute a command to display hosts file'
command: 'cat /etc/hosts'
Play name 1개 + 그룹에 속한 hosts
-
name: 'Execute two commands on web_node1'
hosts: "web_node1,sql_db1"
tasks:
-
name: 'Execute a date command'
command: date
-
name: 'Execute a command to display hosts file'
command: 'cat /etc/hosts'
Play name 2개 + hosts 2개
-
name: 'Execute command to display date on web_node1'
hosts: web_node1
tasks:
-
name: 'Execute a date command'
command: date
-
name: 'Execute a command to display hosts file contents on web_node2'
hosts: web_node2
tasks:
-
name: 'Execute a command to display hosts file'
command: 'cat /etc/hosts'
playbook 연습 - 연속적인 Task
-
name: 'Stop the web services on web server nodes'
hosts: web_nodes
tasks:
-
name: 'Stop the web services on web server nodes'
command: 'service httpd stop'
-
hosts: db_nodes
tasks:
-
name: 'Shutdown the database services on db server nodes'
command: 'service mysql stop'
-
hosts: all_nodes
tasks:
-
name: 'Restart all servers (web and db) at once'
command: '/sbin/shutdown -r'
-
hosts: db_nodes
tasks:
-
name: 'Start the database services on db server nodes'
command: 'service mysql start'
-
hosts: web_nodes
tasks:
-
name: 'Start the web services on web server nodes'
command: 'service httpd start'
Author And Source
이 문제에 관하여(Ansible Study - Playbooks), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@codingdaddy/Ansible-Study-Playbooks저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)