The meaning of life is to explore the world

Ansible tips

Posted on By Jason Liu

Ansible tips

  1. set_stats must have data
    set_stats:
     data:
         failure_reason: "Duplicate."
    
  2. Cannot loop on a block

  3. debug cannot show up in a play, but only in tasks

  4. set_stats variables cannot be used within same playbook, but only in other playbooks

  5. set_stats/set_fact cannot partially change a dictionary, the correct way is to use “combine” filter

  6. unless in a role, include/import cannot be inside tasks, but only outside

  7. import is static, include is dynamic

  8. vars in a task is NOT recognizable in the where clause, but loop_control var is.
    vars in a task is recognizable in the loop clause

  9. variable scope (e.g. set_fact) covers all the descendant and ancestor playbooks included.
    Therefore vars in descendant/ancestor playbooks are alwasy overwritten by parent/offspring set_fact due to precedence.