Skip to content

Commit

Permalink
Changed the playbooks to support napalm-ansible 0.7.0. Also changed
Browse files Browse the repository at this point in the history
'os' fact to 'ansible_os' to make the playbooks consistent with other
examples.
  • Loading branch information
ipspace committed Oct 7, 2017
1 parent a128b9b commit 4ddf246
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion LLDP-to-Graph/LLDP-test.yml
Expand Up @@ -6,7 +6,7 @@
hostname: "{{ansible_host|default(inventory_hostname)}}"
username: "{{ansible_user}}"
password: "{{ansible_ssh_pass}}"
dev_os: "{{os}}"
dev_os: "{{ansible_os}}"
optional_args:
port: "{{api_port|default(ansible_port)|default(22)}}"
filter:
Expand Down
2 changes: 1 addition & 1 deletion LLDP-to-Graph/LLDP-to-Graph.yml
Expand Up @@ -6,7 +6,7 @@
hostname: "{{ansible_host|default(inventory_hostname)}}"
username: "{{ansible_user}}"
password: "{{ansible_ssh_pass}}"
dev_os: "{{os}}"
dev_os: "{{ansible_os}}"
optional_args:
port: "{{api_port|default(ansible_port)|default(22)}}"
filter:
Expand Down
16 changes: 16 additions & 0 deletions LLDP-to-Graph/README.md
Expand Up @@ -3,6 +3,22 @@
The *LLDP-to-Graph* Ansible playbook uses LLDP neighbor data collected
with *napalm_get_facts* Ansible module to generate network diagram in *Graphviz* .dot file format.

## Installation guide

The playbooks were tested with these versions of Ansible and NAPALM:

* Ansible 2.4
* napalm 1.2.0 (or greater)
* napalm-ansible 0.7.0 (or greater)

Notes:

* The playbooks have been updated to work with Ansible 2.4 and will not work
with previous versions of Ansible
* Run `napalm-ansible` to find path to your distribution of NAPALM
and update ansible.cfg accordingly
* The graph-generation playbook doesn't work correctly with Cisco IOS because NAPALM reports different interface names in interface facts and LLDP neighbor facts

## Usage

* Create your inventory file. The current **hosts** file uses vEOS leaf-and-spine topology. Set IP addresses, usernames, passwords and ports in the inventory file.
Expand Down
2 changes: 1 addition & 1 deletion LLDP-to-Graph/ansible.cfg
Expand Up @@ -3,4 +3,4 @@ inventory=./hosts
gathering=explicit
retry_files_enabled=false
transport=local
library=napalm-ansible/library
library=/usr/local/lib/python2.7/dist-packages/napalm_ansible
8 changes: 4 additions & 4 deletions LLDP-to-Graph/hosts
@@ -1,4 +1,4 @@
spine-1 ansible_host=10.0.2.2 ansible_port=20001 api_port=21001 os=eos ansible_user=admin ansible_ssh_pass=admin
spine-2 ansible_host=10.0.2.2 ansible_port=20002 api_port=21002 os=eos ansible_user=admin ansible_ssh_pass=admin
leaf-1 ansible_host=10.0.2.2 ansible_port=20003 api_port=21003 os=eos ansible_user=admin ansible_ssh_pass=admin
leaf-2 ansible_host=10.0.2.2 ansible_port=20004 api_port=21004 os=eos ansible_user=admin ansible_ssh_pass=admin
spine-1 ansible_host=10.0.2.2 ansible_port=20001 api_port=21001 ansible_os=eos ansible_user=admin ansible_ssh_pass=admin
spine-2 ansible_host=10.0.2.2 ansible_port=20002 api_port=21002 ansible_os=eos ansible_user=admin ansible_ssh_pass=admin
leaf-1 ansible_host=10.0.2.2 ansible_port=20003 api_port=21003 ansible_os=eos ansible_user=admin ansible_ssh_pass=admin
leaf-2 ansible_host=10.0.2.2 ansible_port=20004 api_port=21004 ansible_os=eos ansible_user=admin ansible_ssh_pass=admin
2 changes: 1 addition & 1 deletion LLDP-to-Graph/links-fix.j2
@@ -1,5 +1,5 @@
{% for local in play_hosts %}
{% for ifname,lldp in hostvars[local].lldp_neighbors|dictsort if lldp|length > 0 %}
{% for ifname,lldp in hostvars[local].napalm_lldp_neighbors|dictsort if lldp|length > 0 %}
{% for n in lldp if local < n.hostname or n.hostname not in play_hosts %}
{{local}}:{{ifname}} -- {{n.hostname}}:{{n.port}}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion LLDP-to-Graph/links.j2
@@ -1,5 +1,5 @@
{% for local in play_hosts %}
{% for ifname,lldp in hostvars[local].lldp_neighbors|dictsort if lldp|length > 0 %}
{% for ifname,lldp in hostvars[local].napalm_lldp_neighbors|dictsort if lldp|length > 0 %}
{% for n in lldp if local < n.hostname %}
{{local}}:{{ifname}} -- {{n.hostname}}:{{n.port}}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion LLDP-to-Graph/neighbors.j2
@@ -1,5 +1,5 @@
{% for local in play_hosts %}
{% for ifname,lldp in hostvars[local].lldp_neighbors|dictsort if lldp|length > 0 %}
{% for ifname,lldp in hostvars[local].napalm_lldp_neighbors|dictsort if lldp|length > 0 %}
{% for n in lldp %}
{{local}}:{{ifname}} -- {{n.hostname}}:{{n.port}}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion LLDP-to-Graph/simple-graph.j2
Expand Up @@ -3,7 +3,7 @@ graph network {
"{{local}}" [shape=box]
{% endfor %}
{% for local in play_hosts %}
{% for ifname,lldp in hostvars[local].lldp_neighbors|dictsort if lldp|length > 0 %}
{% for ifname,lldp in hostvars[local].napalm_lldp_neighbors|dictsort if lldp|length > 0 %}
{% for n in lldp if local < n.hostname or n.hostname not in play_hosts %}
"{{local}}" -- "{{n.hostname}}";
{% endfor %}
Expand Down
9 changes: 9 additions & 0 deletions OSPF-Deployment/hosts.fqdn
@@ -0,0 +1,9 @@
#
# Auto-generated inventory file
#
E1.virl.info ansible_host=172.16.1.110 ansible_os=ios ansible_user=cisco ansible_ssh_pass=cisco
E2.virl.info ansible_host=172.16.1.111 ansible_os=ios ansible_user=cisco ansible_ssh_pass=cisco
E3.virl.info ansible_host=172.16.1.120 ansible_os=ios ansible_user=cisco ansible_ssh_pass=cisco
E4.virl.info ansible_host=172.16.1.121 ansible_os=ios ansible_user=cisco ansible_ssh_pass=cisco
PE1.virl.info ansible_host=172.16.1.112 ansible_os=ios ansible_user=cisco ansible_ssh_pass=cisco
PE2.virl.info ansible_host=172.16.1.122 ansible_os=ios ansible_user=cisco ansible_ssh_pass=cisco

0 comments on commit 4ddf246

Please sign in to comment.