ฉันจะยืนยันสาเหตุที่งาน ansible ไม่อยู่ในรายการที่กำลังทำงานได้อย่างไร

Aug 18 2020

เมื่อฉันเรียกใช้งานเพลย์บุ๊กจะแสดงงานเดียวเท่านั้น

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 ก็ดูปกติเช่นเดียวกับ Execution output

ดังนั้นคำถามคือฉันต้องทำการตั้งค่าน้อยลงหรือไม่? เหตุใดจึงมีงานที่ไม่อยู่ในรายการการดำเนินการหรือมีเอาต์พุตการดีบักอื่น ๆ ที่สามารถแสดงข้อมูลเอาต์พุตโดยละเอียดได้มากขึ้น

นี่คือ
เวอร์ชันระบบปฏิบัติการการกำหนดค่าที่ตอบได้ของฉัน: Ubuntu 18.04.5 LTS
เวอร์ชันที่ตอบได้:

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]

Playbook ของฉัน:

---
- 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.cfg ที่ตอบได้ของฉัน

[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

คำตอบ

1 Zeitounator Aug 18 2020 at 16:14

งานที่ไม่อยู่ในรายการดำเนินการของคุณเมื่อใช้งาน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)โหมด verbose โดยใช้-v(vv)สวิตช์ (ยิ่งvs มากรายละเอียดมากขึ้น)