diff options
author | James Cammarata <jimi@sngx.net> | 2016-12-08 00:36:57 -0500 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2016-12-08 11:35:18 -0500 |
commit | 011ea55a8f1630842c67603ac601d4d7ef6ccef9 (patch) | |
tree | 556d96fec610d01a869cea515f826e2c63961c26 /lib/ansible/modules/system/facter.py | |
parent | c65ba07d2c3c63cb28462b662e26d0a03c5a18d8 (diff) | |
download | ansible-011ea55a8f1630842c67603ac601d4d7ef6ccef9.tar.gz |
Relocating extras into lib/ansible/modules/ after merge
Diffstat (limited to 'lib/ansible/modules/system/facter.py')
-rw-r--r-- | lib/ansible/modules/system/facter.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/ansible/modules/system/facter.py b/lib/ansible/modules/system/facter.py new file mode 100644 index 0000000000..5ae13ab737 --- /dev/null +++ b/lib/ansible/modules/system/facter.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# (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/>. +# + + +ANSIBLE_METADATA = {'status': ['preview'], + 'supported_by': 'community', + 'version': '1.0'} + +DOCUMENTATION = ''' +--- +module: facter +short_description: Runs the discovery program I(facter) on the remote system +description: + - Runs the I(facter) discovery program + (U(https://github.com/puppetlabs/facter)) on the remote system, returning + JSON data that can be useful for inventory purposes. +version_added: "0.2" +options: {} +notes: [] +requirements: [ "facter", "ruby-json" ] +author: + - "Ansible Core Team" + - "Michael DeHaan" +''' + +EXAMPLES = ''' +# Example command-line invocation +ansible www.example.net -m facter +''' + +def main(): + module = AnsibleModule( + argument_spec = dict() + ) + + facter_path = module.get_bin_path('facter', opt_dirs=['/opt/puppetlabs/bin']) + + cmd = [facter_path, "--puppet", "--json"] + + rc, out, err = module.run_command(cmd, check_rc=True) + module.exit_json(**json.loads(out)) + +# import module snippets +from ansible.module_utils.basic import * + +if __name__ == '__main__': + main() |