mitogen/tests/ansible/lib/modules/mitogen_test_gethostbyname.py

17 lines
438 B
Python
Raw Normal View History

#!/usr/bin/python
# I am a module that indirectly depends on glibc cached /etc/resolv.conf state.
import socket
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(argument_spec={'name': {'type': 'str'}})
try:
module.exit_json(addr=socket.gethostbyname(module.params['name']))
2018-07-04 23:41:58 +00:00
except socket.error as e:
module.fail_json(msg=str(e))
if __name__ == '__main__':
main()