애드혹 명령 실행

  1. 애드혹 명령을 사용하여 관리 호스트 유저의 id 명령어 실행하기

Untitled

  1. copy 모듈을 사용하여 제어 노드에서 애드혹 명령을 실행하여 /etc/motd 파일의 내용을 문자열 “Managed by Ansible”과 그 뒤에 새 줄로 구성하도록 변경하기(제어 노드와 관리 호스트 둘다)
ansible localhost,192.168.56.13 -m copy -a "src=/home/vagrant/ansible_practice_0521/copy dest=/home/vagrant" -i invent
ory --become-user root

Untitled

플레이북 작성

  1. 관리 호스트에 httpd 패키지를 설치되어 있는지 확인하고 제어 노드의 files/index.html 파일을 관리 호스트의 /var/www/html/index.html 파일로 복사하고 httpd 서비스를 실행하는 플레이북 구성하기

  2. 플레이북을 실행하여 관리 호스트의 웹 서버로 접속할 수 있는지 확인하기

---
- name: practice-0521-2
  hosts: 192.168.56.13
  become: true
  tasks:
    - name: download httpd
      yum:
        name: httpd
        state: present
    - name: copy
      copy:
        src: /home/vagrant/files/index.html
        dest: /var/www/html/
    - name: run httpd server
      service:
        name: httpd
        state: started
        enabled: true

Untitled

다중 플레이북 작성

  1. 관리 호스트에 httpd 패키지와 firewalld 패키지가 설치되어 있는지 확인하고 설치되어 있지 않으면 설치를 하는 플레이 작성

관리 호스트에 /var/www/html/index2.html 파일에 Welcome to the example.com intranet! 메세지를 작성하는 플레이 작성

http 서비스 방화벽을 개방하는 플레이 작성

uri 모듈을 사용하여 관리 호스트에 접속하여 Welcome to the example.com intranet! 문구를 가져오는 플레이 작성