ansible/ansible — pull request #1213 by dagwieers (2012-10-03 12:17:29+00:00)
Title: Module to assist users in understanding Ansible

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 ${ansible_lo.ipv4.address}"
- local_action: debug msg="System ${inventory_hostname} lacks a gateway" fail=yes
only_if: "is_unset('$network_gateway')"
- local_action: debug msg="System ${inventory_hostname} has gateway ${network_gateway}"
only_if: "is_set('$network_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 ${ansible_lo.ipv4.address}"] *********************
ok: [localhost] => {"msg": "System localhost has 127.0.0.1"}
ok: [x220] => {"msg": "System x220 has 127.0.0.1"}

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.