ansible 작업이 실행 목록에없는 이유를 어떻게 확인합니까?
플레이 북을 실행하면 하나의 작업 만 표시됩니다.
playbook: test.yaml
play #1 (lab): lab TAGS: []
tasks:
Install pip TAGS: []
그리고 플레이 북을 실행하면 정말 정상입니다
PLAY [lab] *****************************************************************************************************************************
TASK [Gathering Facts] *****************************************************************************************************************
ok: [my_ipaddress]
TASK [Install pip] *********************************************************************************************************************
ok: [my_ipaddress]
PLAY RECAP *****************************************************************************************************************************
my_ipaddress : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
그리고 /var/log/ansible.log에서도 실행 출력과 동일하게 정상적으로 보입니다.
그래서 질문은 더 적은 설정을해야합니까? 실행 목록에없는 태스크가 있거나 더 자세한 출력 정보를 표시 할 수있는 다른 디버그 출력이있는 이유는 무엇입니까?
내 ansible 구성
OS 버전은 다음과 같습니다 .Ubuntu 18.04.5 LTS
ansible 버전 :
ansible 2.9.12
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/primula/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/primula/.local/lib/python3.6/site-packages/ansible
executable location = /home/primula/.local/bin/ansible
python version = 3.6.9 (default, Jul 17 2020, 12:50:27) [GCC 8.4.0]
내 플레이 북 :
---
- hosts: lab
roles:
- { role: apache2, become: yes }
- { role: pip, become: yes }
apache2 역할 구성
경로 : /etc/ansible/roles/apache2/tasks/maim.yaml
---
- name: Install apache2
apt:
name: apache2
update_cache: yes
pip 역할 구성
경로 : /etc/ansible/roles/pip/tasks/main.yaml
---
- name: Install pip
apt:
name: python-pip
update_cache: yes
내 ansible invotory & ansible.cfg invotory입니다
[lab]
<ipaddress> ansible_ssh_user=<user_name> ansible_ssh_pass='<ssh_pass>' ansible_become_user=<root_user> ansible_become=true ansible_become_pass='<root_pass>'
ansible.cfg
[defaults]
private_key_file = /root/.ssh/id_rsa
roles_path = /etc/ansible/roles
inventory = /etc/ansible/hosts
timeout = 10
log_path = /var/log/ansible.log
deprecation_warnings = False
strategy = debug
any_errors_fatal = True
답변
사용할 때 실행 목록에없는 작업 ansible-playbook --list-tasks your_playbook.yml
은 모듈에서 수행 한 팩트 수집과 관련된 작업입니다.setup
플레이의 모든 호스트에 대해 기본적으로 켜져있는 암시 적 자동 작업입니다. 암시 적이면 위의 명령에 의해보고되지 않습니다.
당신은과 플레이 수준에서 사실 수집을 제어 할 수있는 gather_facts
놀이 키워드 , 예를 들어,
---
- name: Some play without facts gathering
hosts: my_group
gather_facts: false
tasks:
- name: dummy demo task
debug:
msg: I am dummy task
더 자세한 출력에 대한 질문과 관련하여 스위치를 ansible(-playbook)
사용하여 상세 모드를 켤 수 있습니다 -v(vv)
( v
s가 많을수록 세부 정보가 많음).