|
|
|
@ -37,11 +37,6 @@ options:
|
|
|
|
|
message.
|
|
|
|
|
required: false
|
|
|
|
|
default: "Hello world!"
|
|
|
|
|
rc:
|
|
|
|
|
description:
|
|
|
|
|
- The return code of the module. If fail=yes, this will default to 1.
|
|
|
|
|
required: false
|
|
|
|
|
default: 0
|
|
|
|
|
fail:
|
|
|
|
|
description:
|
|
|
|
|
- A boolean that indicates whether the debug module should fail or not.
|
|
|
|
@ -49,37 +44,11 @@ options:
|
|
|
|
|
default: "no"
|
|
|
|
|
examples:
|
|
|
|
|
- code: |
|
|
|
|
|
- local_action: debug msg="System $inventory_hostname has uuid $ansible_product_uuid"
|
|
|
|
|
- local_action: debug msg="System $inventory_hostname lacks a gateway" fail=yes
|
|
|
|
|
- action: debug msg="System $inventory_hostname has uuid $ansible_product_uuid"
|
|
|
|
|
- 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}"
|
|
|
|
|
- action: debug msg="System $inventory_hostname has gateway ${ansible_default_ipv4.gateway}"
|
|
|
|
|
only_if: "is_set('${ansible_default_ipv4.gateway}')"
|
|
|
|
|
description: "Example that prints the loopback address and gateway for each host"
|
|
|
|
|
author: Dag Wieers
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
module = AnsibleModule(
|
|
|
|
|
argument_spec = dict(
|
|
|
|
|
fail = dict(default='no', choices=BOOLEANS),
|
|
|
|
|
msg = dict(default='Hello world!'),
|
|
|
|
|
rc = dict(default=0),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
fail = module.boolean(module.params.get('fail'))
|
|
|
|
|
msg = module.params.get('msg')
|
|
|
|
|
rc = module.params.get('rc')
|
|
|
|
|
|
|
|
|
|
if fail and rc == 0:
|
|
|
|
|
rc = 1
|
|
|
|
|
|
|
|
|
|
if fail:
|
|
|
|
|
module.fail_json(rc=rc, msg=msg)
|
|
|
|
|
else:
|
|
|
|
|
module.exit_json(msg=msg)
|
|
|
|
|
|
|
|
|
|
# this is magic, see lib/ansible/module_common.py
|
|
|
|
|
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
|
|
|
|
main()
|
|
|
|
|