[root@opnfv ansible-runner]# ansible-playbook -i 192.168.121.114, -u ansible -k -e ansible_network_os=junos dan-test.yaml
SSH password:
PLAY [Network Getting Started First Playbook] *********************************************************************************************************************************************************************
TASK [Gathering Facts] ********************************************************************************************************************************************************************************************
ok: [192.168.121.114]
TASK [Get config for junos switch] ********************************************************************************************************************************************************************************
ok: [192.168.121.114]
PLAY RECAP ********************************************************************************************************************************************************************************************************
192.168.121.114 : ok=2 changed=0 unreachable=0 failed=0
[root@opnfv ansible-runner]# python dan-test.py
Not loading passwords
Not loading environment vars
Not loading extra vars
Not loading settings
Not loading ssh key
Parsed /tmp/tmpNsTCJY/inventory/hosts.json inventory source with yaml plugin
PLAYBOOK: main.json ************************************************************
1 plays in /tmp/tmpNsTCJY/project/main.json
PLAY [Openstack networking-ansible test] ***************************************
TASK [Gathering Facts] *********************************************************
The full traceback is:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 138, in run
res = self._execute()
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 516, in _execute
self._connection = self._get_connection(variables=variables, templar=templar)
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 790, in _get_connection
socket_path = self._start_connection()
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 877, in _start_connection
[python, find_file_in_path('ansible-connection'), to_text(os.getppid())],
File "/usr/lib/python2.7/site-packages/ansible/executor/task_executor.py", line 868, in find_file_in_path
paths = os.environ['PATH'].split(os.pathsep) + [os.path.dirname(sys.argv[0])]
File "/usr/lib64/python2.7/UserDict.py", line 23, in getitem
raise KeyError(key)
KeyError: 'PATH'
fatal: [192.168.121.114]: FAILED! => {
"msg": "Unexpected failure during module execution.",
"stdout": ""
}
PLAY RECAP *********************************************************************
192.168.121.114 : ok=0 changed=0 unreachable=0 failed=1
[root@opnfv ansible-runner]# cat dan-test.yaml
pb = [{
'name': 'Openstack networking-ansible test',
'connection': 'netconf',
'hosts': '192.168.121.114',
'tasks': [
{'name': 'Gather Facts',
'junos_facts': None,}
]
}]
inventory = {'all':
{'hosts':
{'192.168.121.114':
{'ansible_user': 'ansible',
'ansible_ssh_pass': 'password'}
}
}
}
ar.run(playbook=pb, inventory=inventory)