번외. DOC CLI command

ansible-doc "모듈 명"

ex)
ansible-doc yum
ansible-doc get_url

번외. 플레이북 문제

1. USER 생성

CLI
---
ansible -m user -a "name=kube-user uid=2000" all

PlayBook
--------
---
- name: test play
  hosts: web
  tasks:
    - name: create directory
      ansible.builtin.file:
        path: /home/ansible-user
        state: directory 
    - name: create user ---- 여기부터 답
      user:
        name: kube-user
        uid: 2000
        state: present
확인
----
ansible -a "cat /etc/passwd" all
++
file: 의 state
--------------
1. file : 파일 설정, 없으면 빈 파일 생성
2. directory : 디렉토리 생성, 없으면 생성
3. absent : 파일/디렉토리/링크 등 모든 걸 삭제
4. touch : 파일 없으면 생성, 있으면 타임스탬프만 갱신
5. link : 심볼릭 링크 생성
6. hard : 하드 링크 생성

2. httpd 설치

---
- name: test play
  hosts: web
  tasks:
    - name: create directory
      ansible.builtin.file:
        path: /home/ansible-user
        state: directory
    - name: create user
      user:
        name: kube-user
        uid: 2000
        state: present
    - name: httpd install ---- 여기부터 답
      yum:
        name: httpd
        state: installed # or latest - 최신 버젼 or presnet - 동일
    - name: enable service
      service:
        name: httpd
        state: started
        enabled: yes
확인
----
ansible -a "systemctl stop firewalld" web

or

ansible -m service -a "name=httpd state=stopped" web
=>
시작 - started

image.png

3. Copy File