03af450bdc
After helping someone on IRC he was interested to have this debug module in upstream. This module simply 'prints' a message, and can be ordered to fail if needed. It helps to troubleshoot or understand inventory/facts issues and/or experiment with statements and conditions using only_if. Here is a small example playbook: ```yaml - hosts: all tasks: - local_action: debug msg="System $inventory_hostname has uuid ${ansible_product_uuid}" - local_action: debug msg="System $inventory_hostname lacks a gateway" fail=yes only_if: "is_unset('$ansible_default_ipv4.gateway')" - local_action: debug msg="System $inventory_hostname has gateway ${ansible_default_ipv4.gateway}" only_if: "is_set('$ansible_default_ipv4.gateway')" ``` outputting: ``` [root@moria ansible]# ansible-playbook -v -l localhost:x220 test6.yml PLAY [all] ********************* GATHERING FACTS ********************* ok: [localhost] ok: [x220] TASK: [debug msg="System $inventory_hostname has uuid $ansible_product_uuid"] ********************* ok: [localhost] => {"msg": "System localhost has uuid d125a48c-364f-4e65-b225-fed42ed61fac"} ok: [x220] => {"msg": "System x220 has uuid d125a48c-364f-4e65-b225-fed42ed61fac"} TASK: [debug msg="System $inventory_hostname lacks a gateway" fail=yes] ********************* failed: [localhost] => {"failed": true, "msg": "System localhost lacks a gateway", "rc": 1} ok: [x220] => {"msg": "System x220 has gateway 192.168.1.1"} PLAY RECAP ********************* localhost : ok=2 changed=0 unreachable=0 failed=1 x220 : ok=3 changed=0 unreachable=0 failed=0 ``` I had some other plans for the module, like displaying host inventory and complete inventory to help understand inventory and facts modules, but that would require an action-plugin for transfering inventory information etc... And I am not sure this is wanted/best done in a module. |
||
---|---|---|
.. | ||
apt | ||
apt_repository | ||
assemble | ||
async_status | ||
async_wrapper | ||
authorized_key | ||
command | ||
copy | ||
debug | ||
easy_install | ||
facter | ||
fail | ||
fetch | ||
file | ||
fireball | ||
get_url | ||
git | ||
group | ||
ini_file | ||
lineinfile | ||
mount | ||
mysql_db | ||
mysql_user | ||
nagios | ||
ohai | ||
pause | ||
ping | ||
pip | ||
postgresql_db | ||
postgresql_user | ||
raw | ||
seboolean | ||
selinux | ||
service | ||
setup | ||
shell | ||
slurp | ||
subversion | ||
supervisorctl | ||
template | ||
user | ||
virt | ||
wait_for | ||
yum |