Debian Codegraph @

test/integration/targets/module_precedence/lib_no_extension/ping

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # (c) 2012, Michael DeHaan <[email protected]>
5 # (c) 2016, Toshio Kuratomi <[email protected]>
6 #
7 # This file is part of Ansible
8 #
9 # Ansible is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # Ansible is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
21
22 from __future__ import annotations
23
24 ANSIBLE_METADATA = {'metadata_version': '1.1',
25 'status': ['stableinterface'],
26 'supported_by': 'core'}
27
28
29 DOCUMENTATION = '''
30 ---
31 module: ping
32 version_added: historical
33 short_description: Try to connect to host, verify a usable python and return C(pong) on success.
34 description:
35 - A trivial test module, this module always returns C(pong) on successful
36 contact. It does not make sense in playbooks, but it is useful from
37 C(/usr/bin/ansible) to verify the ability to login and that a usable python is configured.
38 - This is NOT ICMP ping, this is just a trivial test module.
39 options: {}
40 author:
41 - "Ansible Core Team"
42 - "Michael DeHaan"
43 '''
44
45 EXAMPLES = '''
46 # Test we can logon to 'webservers' and execute python with json lib.
47 ansible webservers -m ping
48 '''
49
50 from ansible.module_utils.basic import AnsibleModule
51
52
53 def main():
54 module = AnsibleModule(
55 argument_spec=dict(
56 data=dict(required=False, default=None),
57 ),
58 supports_check_mode=True
59 )
60 result = dict(ping='pong')
61 if module.params['data']:
62 if module.params['data'] == 'crash':
63 raise Exception("boom")
64 result['ping'] = module.params['data']
65 result['location'] = 'library'
66 module.exit_json(**result)
67
68
69 if __name__ == '__main__':
70 main()