I am trying to develop a Playbook which will reference an external
variables file that contains numerous MAC addresses that I want to
interrogate a network core device for.
If I use a very simple playbook just showing the entire ARP table such as
this I get the expected results as show.
---
- name: IP From Arp For ISE Cleanup
hosts: CoreTest
gather_facts: false
connection: network_cli
tasks:
#Execute commands on specified hosts, interating through imported items.
- name: Interrogate ARP Tables on Customer Core Devices
ios_command:
commands: sh ip arp vrf ipt
register: results
#Print Results
- name: Print Results
debug:
msg: "{{ results }}"
stdout_lines:
- - Protocol Address Age (min) Hardware Addr Type
Interface
- Internet 172.17.x.x - 0000.0c9f.f1fc ARPA Vlan508
- Internet 172.17.x.x 110 001f.6dcc.5e4a ARPA Vlan508
- Internet 172.17.x.x 77 001f.6dcc.5447 ARPA Vlan508
However when I use the include filter and point to an external variables
files which includes the specific MAC addresses I want to find the debug
output doesn't show me that it ever gets the IP addresses.
Can anyone tell me why this is happening?
---
- name: IP From Arp For ISE Cleanup
hosts: CoreTest
gather_facts: false
connection: network_cli
tasks:
# Imports the variables
- name: Include MAC Addresses From External File
include_vars:
file: mac_addresses.yml
name: mac_addresses
#Execute commands on specified hosts, interating through imported items.
- name: Interrogate ARP Tables on Customer Core Devices
ios_command:
commands: sh ip arp vrf ipt | include "{{ item }}"
with_items: "{{ mac_addresses.macs }}"
register: results
#Print Results
- name: Print Results
debug:
msg: "{{ item }}"
with_items: "{{ mac_addresses.macs }}"
TASK [Include MAC Addresses From External File]
***********************************************************************************************************************************************************
task path: /etc/ansible/ip_arp.yml:10
ok: [Switch.Sc] => changed=false
ansible_facts:
mac_addresses:
macs:
- 001a.e82a.9f0d
- 001a.e82a.9f71
ansible_included_var_files:
- /etc/ansible/mac_addresses.yml
TASK [Interrogate ARP Tables on Customer Core Devices]
*************************************************************************************************************************************************
ok: [Switch.Sc] => (item=001a.e82a.9f0d) => changed=false
invocation:
module_args:
auth_pass: null
authorize: null
commands:
- sh ip arp vrf ipt | include "001a.e82a.9f0d"
host: null
interval: 1
match: all
password: null
port: null
provider: null
retries: 10
ssh_keyfile: null
timeout: null
username: null
wait_for: null
item: 001a.e82a.9f0d
stdout:
- ''
stdout_lines: <omitted>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1367f1c4-c37b-4cb4-9dad-376c4b023415%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.