cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1518
Views
0
Helpful
1
Replies

ERROR: DEVNET_Learning Labs_Home lab: Using Ansible from your computer: # 8 Use an Ansible playbook to extract data from the Sandbox Router

Mohammed Hasaballa
Cisco Employee
Cisco Employee

thanks in advance. running into Error while trying to run ansible playbook

Use an Ansible playbook to extract data from the Sandbox Router

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

1 Reply 1

juan-ruiz
Level 1
Level 1

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