10-10-2019 09:35 PM - edited 10-10-2019 09:40 PM
thanks in advance. running into Error while trying to run ansible playbook
Use an Ansible playbook to extract data from the Sandbox Router
cat my-inventory
[all:vars]
ansible_connection=local
ansible_python_interpreter="/usr/lib/python3/dist-packages/ansible
[sandbox]
router ansible_host='ios-xe-mgmt.cisco.com'
[sandbox:vars]
username=developer
password=C1sco12345
port=8181
cat test-to-sandbox.yml
---
# playbook to get basic IOS facts, just to prove Ansible works to a Cisco device.
- name: Get IOS Facts from a Cisco IOS or XE router.
hosts: sandbox
vars:
cli:
host: "{{ ansible_host }}"
username: "{{ username }}"
password: "{{ password }}"
port: "{{ port }}"
tasks:
- ios_facts:
gather_subset: all
provider: "{{ cli }}"
- debug:
msg: "Device hostname is {{ ansible_net_hostname }}"
- debug:
msg: "Device OS version is {{ ansible_net_version }}"
Error:
PLAY [Get IOS Facts from a Cisco IOS or XE router.] ****************************************************************************************
TASK [Gathering Facts] *********************************************************************************************************************
fatal: [router]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"setup": {"failed": true, "module_stderr": "/bin/sh: 1: Syntax error: Unterminated quoted string\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 2}}, "msg": "The following modules failed to execute: setup\n"}
PLAY RECAP *********************************************************************************************************************************
router : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
10-16-2019 06:58 AM
Hi Mohammed,
I got the same error too and the problem was the variable ansible_python_interpreter.
This line assumes you are running python3 and in my case that is not the case. I'm running python 2.7 so comment the line out by adding the hashtag in the front and run the playbook again and let us know the results.
Thank you,
Juan
#ansible_python_interpreter="/usr/lib/python3/dist-packages/ansible
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide