Last active
October 17, 2018 12:44
-
-
Save markuman/09bde0f22f62fe4dc8833a484c95c2f6 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]$ 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: Invalid data from file, expected dictionary and got: None | |
File "/usr/lib/python3.7/site-packages/ansible/plugins/inventory/script.py", line 159, in parse | |
self._populate_host_vars([host], got) | |
File "/usr/lib/python3.7/site-packages/ansible/plugins/inventory/__init__.py", line 179, in _populate_host_vars | |
raise AnsibleParserError("Invalid data from file, expected dictionary and got:\n\n%s" % to_native(variables)) | |
[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]$ ~/.local/bin/ansible -vvv -i testinv.py all -m ping | |
ansible 2.7.0 | |
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 | |
Parsed /home/markus/git/myinv/testinv.py inventory source with script plugin | |
META: ran handlers | |
<10.109.2.112> ESTABLISH SSH CONNECTION FOR USER: root | |
<10.109.2.112> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/markus/.ssh/id_ed25519"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/markus/.ansible/cp/393cf8d877 10.109.2.112 '/bin/sh -c '"'"'echo ~root && sleep 0'"'"'' | |
<10.109.2.112> (0, '/root\n', '\n WARNING UNAUTHORIZED ACCESS DENIED\n\n') | |
<10.109.2.112> ESTABLISH SSH CONNECTION FOR USER: root | |
<10.109.2.112> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/markus/.ssh/id_ed25519"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/markus/.ansible/cp/393cf8d877 10.109.2.112 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1539780269.54-271240318619465 `" && echo ansible-tmp-1539780269.54-271240318619465="` echo /root/.ansible/tmp/ansible-tmp-1539780269.54-271240318619465 `" ) && sleep 0'"'"'' | |
<10.109.2.112> (0, 'ansible-tmp-1539780269.54-271240318619465=/root/.ansible/tmp/ansible-tmp-1539780269.54-271240318619465\n', '') | |
Using module file /home/markus/.local/lib/python2.7/site-packages/ansible/modules/system/ping.py | |
<10.109.2.112> PUT /home/markus/.ansible/tmp/ansible-local-3028xjYJk2/tmpQmDDxn TO /root/.ansible/tmp/ansible-tmp-1539780269.54-271240318619465/AnsiballZ_ping.py | |
<10.109.2.112> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/markus/.ssh/id_ed25519"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/markus/.ansible/cp/393cf8d877 '[10.109.2.112]' | |
<10.109.2.112> (0, 'sftp> put /home/markus/.ansible/tmp/ansible-local-3028xjYJk2/tmpQmDDxn /root/.ansible/tmp/ansible-tmp-1539780269.54-271240318619465/AnsiballZ_ping.py\n', '') | |
<10.109.2.112> ESTABLISH SSH CONNECTION FOR USER: root | |
<10.109.2.112> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/markus/.ssh/id_ed25519"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/markus/.ansible/cp/393cf8d877 10.109.2.112 '/bin/sh -c '"'"'chmod u+x /root/.ansible/tmp/ansible-tmp-1539780269.54-271240318619465/ /root/.ansible/tmp/ansible-tmp-1539780269.54-271240318619465/AnsiballZ_ping.py && sleep 0'"'"'' | |
<10.109.2.112> (0, '', '') | |
<10.109.2.112> ESTABLISH SSH CONNECTION FOR USER: root | |
<10.109.2.112> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/markus/.ssh/id_ed25519"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/markus/.ansible/cp/393cf8d877 -tt 10.109.2.112 '/bin/sh -c '"'"'/usr/bin/python /root/.ansible/tmp/ansible-tmp-1539780269.54-271240318619465/AnsiballZ_ping.py && sleep 0'"'"'' | |
<10.109.2.112> (0, '\r\n{"invocation": {"module_args": {"data": "pong"}}, "ping": "pong"}\r\n', 'Shared connection to 10.109.2.112 closed.\r\n') | |
<10.109.2.112> ESTABLISH SSH CONNECTION FOR USER: root | |
<10.109.2.112> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/markus/.ssh/id_ed25519"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/markus/.ansible/cp/393cf8d877 10.109.2.112 '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1539780269.54-271240318619465/ > /dev/null 2>&1 && sleep 0'"'"'' | |
<10.109.2.112> (0, '', '') | |
10.109.2.112 | SUCCESS => { | |
"changed": false, | |
"invocation": { | |
"module_args": { | |
"data": "pong" | |
} | |
}, | |
"ping": "pong" | |
} | |
META: ran handlers | |
META: ran handlers |
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
#!/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"}}} | |
print(json.dumps(inventory)) | |
if len(sys.argv) == 2: | |
if sys.argv[1] == "--list": | |
get_inventory() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment