Debian Codegraph @

ansible_collections/community/general/plugins/modules/ohai.py

raw
1 #!/usr/bin/python
2
3 # Copyright (c) 2012, Michael DeHaan <[email protected]>
4 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
5 # SPDX-License-Identifier: GPL-3.0-or-later
6
7 from __future__ import annotations
8
9 DOCUMENTATION = r"""
10 module: ohai
11 short_description: Returns inventory data from I(Ohai)
12 description:
13 - Similar to the M(community.general.facter_facts) module, this runs the I(Ohai) discovery program (U(https://docs.chef.io/ohai.html))
14 on the remote host and returns JSON inventory data. I(Ohai) data is a bit more verbose and nested than I(facter).
15 extends_documentation_fragment:
16 - community.general._attributes
17 attributes:
18 check_mode:
19 support: none
20 diff_mode:
21 support: none
22 options: {}
23 notes: []
24 requirements: ["ohai"]
25 author:
26 - "Ansible Core Team"
27 - "Michael DeHaan (@mpdehaan)"
28 """
29
30 EXAMPLES = r"""
31 # fmt: console
32
33 ansible webservers -m ohai --tree=/tmp/ohaidata
34 ...
35 """
36 import json
37
38 from ansible.module_utils.basic import AnsibleModule
39
40
41 def main():
42 module = AnsibleModule(argument_spec=dict())
43 module.run_command_environ_update = {"LANGUAGE": "C", "LC_ALL": "C"}
44 cmd = ["/usr/bin/env", "ohai"]
45 rc, out, err = module.run_command(cmd, check_rc=True)
46 module.exit_json(**json.loads(out))
47
48
49 if __name__ == "__main__":
50 main()