I'm trying to figure out custom Ansible modules. Messages are not displayed in the exit_json() function in the custom Ansible module
library/test_out_module.py
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
some_var=dict(required=True, type='raw'),
)
)
some_var = module.params['some_var']
result = {}
result['result_data'] = some_var
result['result'] = 'goodbye'
result['changed'] = True
module.exit_json(**result)
if __name__ == '__main__':
main()
playbook:
---
- hosts: localhost
gather_facts: no
tasks:
- name: test out module
test_out_module:
some_var: asdad
what am I doing wrong?
result
constantine@MacBook-Pro-Constantine ~/work/tapentertainment/ansible $ ./ansible-playbook playbooks/dev-devel.yml
PLAY [localhost] *********************************************************************************************************************************************************************************************************************************************************************
TASK [test out module] ***************************************************************************************************************************************************************************************************************************************************************
changed: [localhost]
PLAY RECAP ***************************************************************************************************************************************************************************************************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Version:
ansible [core 2.16.3]
python version = 3.12.1 (main, Dec 7 2023, 20:45:44) [Clang 15.0.0 (clang-1500.0.40.1)]
jinja version = 3.1.3
libyaml = True