1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/library
Dag Wieers 03af450bdc 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 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.
2012-10-04 09:50:18 +02:00
..
apt Fixing various module related things. 2012-10-02 22:32:17 -04:00
apt_repository Fixing various module related things. 2012-10-02 22:32:17 -04:00
assemble Fixing various module related things. 2012-10-02 22:32:17 -04:00
async_status attempt at DOCUMENTATION for async_status 2012-10-02 09:56:55 +02:00
async_wrapper whitespace + remove deprecated YAML parser (migration script lives in examples/scripts and warning was added 2012-08-06 20:07:02 -04:00
authorized_key Fixing various module related things. 2012-10-02 22:32:17 -04:00
command Fixing various module related things. 2012-10-02 22:32:17 -04:00
copy Module DOCUMENTATION: assemble, authorized_key, command, copy 2012-09-28 21:55:49 +02:00
debug Module to assist users in understanding Ansible 2012-10-04 09:50:18 +02:00
easy_install Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
facter Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
fail Added a fail module in order to fail execution on certain conditions 2012-10-02 21:40:28 +02:00
fetch various small doc tweaks 2012-10-02 22:43:46 -04:00
file various small doc tweaks 2012-10-02 22:43:46 -04:00
fireball Teach fireball mode to disable the fireball by paying attention to 'minutes=N' (default 30) and do not let fireball module crash 2012-10-01 22:41:00 -04:00
get_url various small doc tweaks 2012-10-02 22:43:46 -04:00
git Add module documentation for git, group, service, and user 2012-09-29 23:50:25 -07:00
group Add module documentation for git, group, service, and user 2012-09-29 23:50:25 -07:00
ini_file removed EXAMPLES from ini_file 2012-09-29 01:26:40 +02:00
lineinfile Merge pull request #1170 from jpmens/docspatch01 2012-10-01 05:19:16 -07:00
mount DOCUMENTATION for fetch,mount,ohai,easy_install 2012-09-30 12:29:32 +02:00
mysql_db Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
mysql_user Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
nagios Fix issue https://github.com/ansible/ansible/issues/1194 2012-10-02 15:12:33 +02:00
ohai Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
pause standardize DOCUMENTATION for nagios, pause 2012-10-02 09:15:11 +02:00
ping various small doc tweaks 2012-10-02 22:43:46 -04:00
pip Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
postgresql_db Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
postgresql_user DOCUMENTATION for fetch,mount,ohai,easy_install 2012-09-30 12:29:32 +02:00
raw Added attribution to all module DOCUMENTATION strings 2012-10-01 12:37:51 +02:00
seboolean Added DOCUMENTATION to seboolean module. 2012-09-30 15:41:00 +02:00
selinux Added DOCUMENTATION to selinux module. 2012-09-30 15:34:26 +02:00
service Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
setup Added attribution to all module DOCUMENTATION strings 2012-10-01 12:37:51 +02:00
shell Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
slurp module docs for slurp 2012-09-30 16:58:15 +02:00
subversion Added DOCUMENTATION to subversion module. 2012-09-29 16:28:55 +02:00
supervisorctl Added DOCUMENTATION to supervisorctl module. 2012-09-29 21:02:07 +02:00
template Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
user Jumbo DOCUMENTATION patch 2012-10-01 09:18:54 +02:00
virt Attribute author of virt correctly (sorry) 2012-09-30 14:08:47 +02:00
wait_for Module DOCUMENTATION for template, wait_for, and yum 2012-09-29 00:49:02 +02:00
yum Module DOCUMENTATION for template, wait_for, and yum 2012-09-29 00:49:02 +02:00