Comments (9)
Hi @lmshippy ,
that's because the module only supports a limited amount of commands and show run X
is not one of them.
You can take a look at all the supported commands here
from ntc-ansible.
I am using a custom index file, and a custom template. The problem is not with that, the problem I am having is with being a pull the interfaces dynamically and then use them with with_items. Basically following the example Jason posted in the link below.
from ntc-ansible.
Hi @lmshippy,
Can you show the output running in verbose mode or add a task like this:
debug: var=interface
And do this after your set_fact task. Show us this output.
Thanks.
from ntc-ansible.
from ntc-ansible.
Actually something seems off. You did a debug and you're still seeing the response
key. Let's eliminate the set_fact
for now and just do this:
with_items: "{{ interfaces.response }}"
from ntc-ansible.
Here is the new playbook and below is the debug output.
---
- name: COLLECT DATA TEST
hosts: iosrouters
gather_facts: no
connection: local
tasks:
- name: GET INTERFACES
ntc_show_command:
connection=ssh
platform={{ vendor }}_{{ os }}_{{ api }}
index_file=index
template_dir=/usr/lib/python2.7/dist-packages/ansible/modules/ntc-ansible/ntc-templates/templates
command='show ip int brief'
host={{ inventory_hostname }}
username={{ un }}
password={{ pwd }}
tags: test
register: interfaces
- name: GET INTERFACES DETAIL
ntc_show_command:
connection=ssh
platform={{ vendor }}_{{ os }}_{{ api }}
index_file=interface.index
template_dir=/usr/lib/python2.7/dist-packages/ansible/modules/ntc-ansible/ntc-templates/templates
command="show run int {{ item.intf }}"
host={{ inventory_hostname }}
username={{ un }}
password={{ pwd }}
tags: test
with_items: "{{ interfaces.response }}"
register: interfaceinfo
TASK [GET INTERFACES] **********************************************************
ok: [x.x.x.x] => {"changed": false, "response": [{"intf": "Embedded-Service-Engine0/0", "ipaddr": "unassigned", "proto": "down", "status": "administratively down"}, {"intf": "GigabitEthernet0/0", "ipaddr": "x.x.x.x", "proto": "up", "status": "up"}, {"intf": "GigabitEthernet0/1", "ipaddr": "x.x.x.x", "proto": "up", "status": "up"}, {"intf": "Loopback0", "ipaddr": "x.x.x.x", "proto": "up", "status": "up"}, {"intf": "Tunnel1", "ipaddr": "x.x.x.x", "proto": "up", "status": "up"}, {"intf": "Tunnel2", "ipaddr": "x.x.x.x", "proto": "up", "status": "up"}], "response_list": []}
TASK [GET INTERFACES DETAIL] ***************************************************
ok: [x.x.x.x] => (item={u'status': u'administratively down', u'intf': u'Embedded-Service-Engine0/0', u'ipaddr': u'unassigned', u'proto': u'down'}) => {"changed": false, "item": {"intf": "Embedded-Service-Engine0/0", "ipaddr": "unassigned", "proto": "down", "status": "administratively down"}, "response": [{"helper": "", "hsrp": "", "interface": "Embedded-Service-Engine0/0", "ip_addr": "", "sub_mask": ""}], "response_list": []}
ok: [x.x.x.x] => (item={u'status': u'up', u'intf': u'GigabitEthernet0/0', u'ipaddr': u'x.x.x.x', u'proto': u'up'}) => {"changed": false, "item": {"intf": "GigabitEthernet0/0", "ipaddr": "x.x.x.x", "proto": "up", "status": "up"}, "response": [{"helper": "", "hsrp": "", "interface": "GigabitEthernet0/0", "ip_addr": "x.x.x.x", "sub_mask": "x.x.x.x"}], "response_list": []}
ok: [x.x.x.x] => (item={u'status': u'up', u'intf': u'Loopback0', u'ipaddr': u'x.x.x.x', u'proto': u'up'}) => {"changed": false, "item": {"intf": "Loopback0", "ipaddr": "x.x.x.x", "proto": "up", "status": "up"}, "response": [{"helper": "", "hsrp": "", "interface": "Loopback0", "ip_addr": "x.x.x.x", "sub_mask": "x.x.x.x"}], "response_list": []}
ok: [x.x.x.x] => (item={u'status': u'up', u'intf': u'Tunnel1', u'ipaddr': u'x.x.x.x', u'proto': u'up'}) => {"changed": false, "item": {"intf": "Tunnel1", "ipaddr": "x.x.x.x", "proto": "up", "status": "up"}, "response": [{"helper": "", "hsrp": "", "interface": "Tunnel1", "ip_addr": "x.x.x.x", "sub_mask": "x.x.x.x"}], "response_list": []}
ok: [x.x.x.x] => (item={u'status': u'up', u'intf': u'Tunnel2', u'ipaddr': u'x.x.x.x', u'proto': u'up'}) => {"changed": false, "item": {"intf": "Tunnel2", "ipaddr": "x.x.x.x", "proto": "up", "status": "up"}, "response": [{"helper": "", "hsrp": "", "interface": "Tunnel2", "ip_addr": "x.x.x.x", "sub_mask": "x.x.x.x"}], "response_list": []}
from ntc-ansible.
Looks like it worked...what am I missing?
If you add a debug: var=interfaceinfo
, you should have what you need, no?
from ntc-ansible.
Actually looking, you are correct, the information is in there. The file we were creating was putting in a bunch of extra stuff at the top but we were able to figure it out. Quick question, with the loop it is reconnecting to the device each time for the looped command, is there any way to have it maintain the connection for the loop?
from ntc-ansible.
Hey @lmshippy ,
this is not possible yet, but it's a feature we will release in the future :)
from ntc-ansible.
Related Issues (20)
- ntc_file_copy - module object has no attribute FullLoader HOT 3
- Module failure when trying to use 'ntc_show_command' HOT 2
- ntc-templates module not references master HOT 1
- ntc_file_copy - msg: '''CiscoIosFileTransfer'' object has no attribute ''scp_conn''' HOT 2
- textfsm.TextFSMError HOT 8
- F5 errors HOT 7
- how to run ntc-ansible on Cisco ASA HOT 3
- setup.py: "ImportError No module named pathlib" HOT 3
- ntc_save_config is missing call to escalate privilege HOT 1
- ntc_show__command cant find netmiko HOT 6
- Remove Git Submodule for ntc-templates HOT 1
- Move into Ansible Collection HOT 2
- pyntc cannot import name ntc_device error HOT 3
- I can not run setup.py install. I have a newer version of SCP HOT 2
- Restructure to ansible collection HOT 1
- Add Proper CI HOT 2
- Add Proper Issues, Bugs, etc templates HOT 2
- Update Branching Strategy to Match NTC dev standards HOT 1
- Install ntc-ansible HOT 2
- Can't figure out how to make it work with netmiko HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ntc-ansible.