ohai 1.61 KB
Newer Older
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
#

22 23 24
DOCUMENTATION = '''
---
module: ohai
Jan-Piet Mens committed
25
short_description: Returns inventory data from I(Ohai)
26
description:
Jan-Piet Mens committed
27
     - Similar to the M(facter) module, this runs the I(Ohai) discovery program
28 29
       (U(http://wiki.opscode.com/display/chef/Ohai)) on the remote host and 
       returns JSON inventory data.
30
       I(Ohai) data is a bit more verbose and nested than I(facter).
31
version_added: "0.6"
32
options: {}
33 34 35 36 37
notes: []
requirements: [ "ohai" ]
author: Michael DeHaan
'''

38 39 40 41 42
EXAMPLES = '''
# Retrieve (ohai) data from all Web servers and store in one-file per host
ansible webservers -m ohai --tree=/tmp/ohaidata
'''

43 44 45 46
def main():
    module = AnsibleModule(
        argument_spec = dict()
    )
47
    cmd = ["/usr/bin/env", "ohai"]
48
    rc, out, err = module.run_command(cmd, check_rc=True)
49
    module.exit_json(**json.loads(out))
50

51
# import module snippets
52
from ansible.module_utils.basic import *
53 54 55 56

main()