다중 Play 사용해보기

---
- name: first play
  hosts: localhost
  become: true //ansible.cfg가 아닌 playbook에서 권한 상승을 명시할 수 있다
  tasks:
    - name: first task
      yum:
        name: httpd
        state: present
    - name: second task
      service: 
        name: httpd
        state: started
        enabled: true

- name: second play
  hosts: 192.168.56.13
  become: true
  tasks:
    - name: first task
      yum:
        name: mariadb-server
        state: latest
    - name: second task
      service: 
        name: mariadb
        state: started
        enabled: true 

      

Playbook에서 명시할 수 있는 권한 상승

Playbook에서 명시할 수 없는 권한 상승

yum module의 state인자

yum module의 state인자에는 세 가지 값이 들어갈 수 있다.

present : 없으면 설치

latest : 없으면 설치, 있어도 최신버전으로 업그레이드(package 호환성을 고려해야함)

absent : package 삭제

key 전달

localhost에 접근하기위한 key를 복사해서 넣어주어야한다