tests/ansible/lib/modules/custom_python_modify_environ.py
raw| 1 | #!/usr/bin/python |
| 2 | # I am an Ansible new-style Python module. I modify the process environment and |
| 3 | # don't clean up after myself. |
| 4 | |
| 5 | from ansible.module_utils.basic import AnsibleModule |
| 6 | |
| 7 | import os |
| 8 | |
| 9 | |
| 10 | def main(): |
| 11 | module = AnsibleModule(argument_spec={ |
| 12 | 'key': {'type': 'str'}, |
| 13 | 'val': {'type': 'str'} |
| 14 | }) |
| 15 | os.environ[module.params['key']] = module.params['val'] |
| 16 | module.exit_json(msg='Muahahaha!') |
| 17 | |
| 18 | if __name__ == '__main__': |
| 19 | main() |