Ansible 正在跳过调试行

问题描述 投票:0回答:2

我在角色中执行此任务,并在其下面有一条调试行:

- name: Restore bootstrap DB
  command: "mongorestore -v --host localhost:{{ mongodb_net.port }} -d {{ item.dbname }} --dir {{ item.clone_dir }}"
  register: restore_result
  with_items:
    - { dbname: "{{ mongodb_db1_dbname }}", clone_dir: "/var/tmp/db_bootstrap/DB1_CLONE" }
    - { dbname: "{{ mongodb_db2_dbname }}", clone_dir: "/var/tmp/db_bootstrap/DB2_CLONE" }

- debug: var=restore_result verbosity=2

但是它跳过了调试任务。

TASK [mongodb : Restore bootstrap DB] ***************************************************
changed: [xx.xx.xx.167] => (item={u'dbname': u'DB1', u'clone_dir': u'/var/tmp/db_bootstrap/DB1'})
changed: [xx.xx.xx.167] => (item={u'dbname': u'DB2', u'clone_dir': u'/var/tmp/db_bootstrap/DB2'})

TASK [mongodb : debug] ******************************************************************
skipping: [xx.xx.xx.167]

当我启用详细模式时,

-vv
,它会显示注册变量的内容。

我使用的是 Ansible 版本 2.4.3

ansible ansible-2.x
2个回答
26
投票

2.4.3中缺少一个功能,没有显示跳过原因,这是在2.6.1中添加的;将我的版本升级到2.6.1并看到原因:

TASK [mongodb : debug] ********************************************************************************
skipping: [xx.xx.xx.167] => {"skipped_reason": "Verbosity threshold not met."}

因此我从任务中删除了

verbosity=2
,它现在按预期工作。


0
投票

您可以尝试使用aiansible进行调试:https://github.com/sunnycloudy/aiansible

DEBUG INFO:
/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/kubespray-defaults/tasks/main.yaml:2


    2|- name: Configure defaults
    3|  debug:
    4|    msg: "Check roles/kubespray-defaults/defaults/main.yml"
    5|  tags:
    6|    - always
    7|
    8|# do not run gather facts when bootstrap-os in roles
    9|- name: set fallback_ips
   10|  import_tasks: fallback_ips.yml
   11|  when:


Saturday 25 May 2024  23:07:13 +0800 (0:00:00.101)       10:20:04.700 ********* 

TASK [kubespray-defaults : Configure defaults] *****************************************************************************************************************************************************************
ok: [test1] => {
    "msg": "Check roles/kubespray-defaults/defaults/main.yml"
}
Aiansible(CN) => result._result
{'msg': 'Check roles/kubespray-defaults/defaults/main.yml', '_ansible_verbose_always': True, '_ansible_no_log': False, 'changed': False}
Aiansible(CN) => bt
0:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/playbooks/ansible_version.yml:11=>Check 2.11.0 <= Ansible version < 2.13.0
1:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/playbooks/ansible_version.yml:20=>Check that python netaddr is installed
2:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/playbooks/ansible_version.yml:28=>Check that jinja is not too old (install via pip)
3:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/download/tasks/prep_download.yml:2=>download : prep_download | Set a few facts
4:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/download/tasks/prep_download.yml:8=>download : prep_download | On localhost, check if passwordless root is possible
5:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/download/tasks/prep_download.yml:23=>download : prep_download | On localhost, check if user has access to the container runtime without using sudo
6:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/download/tasks/prep_download.yml:38=>download : prep_download | Parse the outputs of the previous commands
7:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/download/tasks/prep_download.yml:48=>download : prep_download | Check that local user is in group or can become root
8:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/download/tasks/prep_download.yml:59=>download : prep_download | Register docker images info
9:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/download/tasks/prep_download.yml:68=>download : prep_download | Create staging directory on remote node
10:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/download/tasks/prep_download.yml:78=>download : prep_download | Create local cache for files and images on control node
11:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/download/tasks/main.yml:10=>download : download | Get kubeadm binary and list of required images
12:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/download/tasks/main.yml:19=>download : download | Download files / images
13:/root/.nujnus/test_suite/K8s_v2_22_2/install_k8s_v2_22_2/install/kubespray/roles/kubespray-defaults/tasks/main.yaml:2=>kubespray-defaults : Configure defaults
Aiansible(CN) => a
msg: Check roles/kubespray-defaults/defaults/main.yml


© www.soinside.com 2019 - 2024. All rights reserved.