Created
October 17, 2018 12:39
-
-
Save markuman/2da6182d5b9ec87e73eadd76a82e7aea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[markus@dell myinv]$ ~/.local/bin/ansible -vvv -i testinv.py all -m ping | |
ansible 2.5.1 | |
config file = /etc/ansible/ansible.cfg | |
configured module search path = [u'/home/markus/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] | |
ansible python module location = /home/markus/.local/lib/python2.7/site-packages/ansible | |
executable location = /home/markus/.local/bin/ansible | |
python version = 2.7.15 (default, Jun 27 2018, 13:05:28) [GCC 8.1.1 20180531] | |
Using /etc/ansible/ansible.cfg as config file | |
[ERROR]: | |
[WARNING]: * Failed to parse /home/markus/git/myinv/testinv.py with script plugin: failed to parse executable inventory script results from /home/markus/git/myinv/testinv.py: needs to be a json dict | |
File "/home/markus/.local/lib/python2.7/site-packages/ansible/plugins/inventory/script.py", line 129, in parse | |
raise AnsibleError("failed to parse executable inventory script results from {0}: needs to be a json dict\n{1}".format(path, err)) | |
[WARNING]: * Failed to parse /home/markus/git/myinv/testinv.py with ini plugin: /home/markus/git/myinv/testinv.py:4: Expected key=value host variable assignment, got: json | |
File "/home/markus/.local/lib/python2.7/site-packages/ansible/plugins/inventory/ini.py", line 132, in parse | |
self._parse(path, data) | |
File "/home/markus/.local/lib/python2.7/site-packages/ansible/plugins/inventory/ini.py", line 210, in _parse | |
hosts, port, variables = self._parse_host_definition(line) | |
File "/home/markus/.local/lib/python2.7/site-packages/ansible/plugins/inventory/ini.py", line 308, in _parse_host_definition | |
self._raise_error("Expected key=value host variable assignment, got: %s" % (t)) | |
File "/home/markus/.local/lib/python2.7/site-packages/ansible/plugins/inventory/ini.py", line 137, in _raise_error | |
raise AnsibleError("%s:%d: " % (self._filename, self.lineno) + message) | |
[WARNING]: Unable to parse /home/markus/git/myinv/testinv.py as an inventory source | |
[WARNING]: No inventory was parsed, only implicit localhost is available | |
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' | |
[markus@dell myinv]$ ansible -vvv -i testinv.py all -m ping | |
ansible 2.7.0 | |
config file = /etc/ansible/ansible.cfg | |
configured module search path = ['/home/markus/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] | |
ansible python module location = /usr/lib/python3.7/site-packages/ansible | |
executable location = /usr/bin/ansible | |
python version = 3.7.0 (default, Sep 15 2018, 19:13:07) [GCC 8.2.1 20180831] | |
Using /etc/ansible/ansible.cfg as config file | |
[WARNING]: * Failed to parse /home/markus/git/myinv/testinv.py with script plugin: failed to parse executable inventory script results from /home/markus/git/myinv/testinv.py: needs to be a json dict | |
File "/usr/lib/python3.7/site-packages/ansible/plugins/inventory/script.py", line 133, in parse | |
raise AnsibleError("failed to parse executable inventory script results from {0}: needs to be a json dict\n{1}".format(path, err)) | |
[WARNING]: * Failed to parse /home/markus/git/myinv/testinv.py with ini plugin: /home/markus/git/myinv/testinv.py:4: Expected key=value host variable assignment, got: json | |
File "/usr/lib/python3.7/site-packages/ansible/plugins/inventory/ini.py", line 132, in parse | |
self._parse(path, data) | |
File "/usr/lib/python3.7/site-packages/ansible/plugins/inventory/ini.py", line 210, in _parse | |
hosts, port, variables = self._parse_host_definition(line) | |
File "/usr/lib/python3.7/site-packages/ansible/plugins/inventory/ini.py", line 308, in _parse_host_definition | |
self._raise_error("Expected key=value host variable assignment, got: %s" % (t)) | |
File "/usr/lib/python3.7/site-packages/ansible/plugins/inventory/ini.py", line 137, in _raise_error | |
raise AnsibleError("%s:%d: " % (self._filename, self.lineno) + message) | |
[WARNING]: Unable to parse /home/markus/git/myinv/testinv.py as an inventory source | |
[WARNING]: No inventory was parsed, only implicit localhost is available | |
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' | |
[markus@dell myinv]$ cat testinv.py | |
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
import json | |
import os | |
import pprint | |
import sys | |
def get_inventory(): | |
inventory = {"kinesis": {"hosts": ["10.109.2.112"], "vars": {"ansible_ssh_user": "root", "ansible_ssh_private_key_file": "~/.ssh/id_ed25519"}}} | |
return inventory | |
if len(sys.argv) == 2: | |
if sys.argv[1] == "--list": | |
get_inventory() | |
[markus@dell myinv]$ ls -l testinv.py | |
-rwxr-xr-x 1 markus markus 369 17. Okt 14:38 testinv.py | |
[markus@dell myinv]$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment