ansibleansible-2.x

Ansible is skipping the debug line


I have this task in a role and a debug line beneath it:

- 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

But it's skipping the debug task.

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]

When I enable verbose mode, -vv, it shows the content of the registered variable.

I'm using Ansible version 2.4.3


Solution

  • There's a missing feature in 2.4.3 which doesn't show the skip reason, this was added in 2.6.1; Upgraded my version to 2.6.1 and saw the reason:

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

    So I removed the verbosity=2 from the task and it's now working as expected.