Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/network-automation/ansible_inventory_report
This repo contains an Ansible networking inventory report playbook (inventory.yml). This playbook exports hostname, platform, mgmt0 IP address and code version to a HTML file. The jinja2 template used for the website can also highlight the version of code if it doesn't match a desired version.
https://github.com/network-automation/ansible_inventory_report
ansible nxos playbook
Last synced: about 2 months ago
JSON representation
This repo contains an Ansible networking inventory report playbook (inventory.yml). This playbook exports hostname, platform, mgmt0 IP address and code version to a HTML file. The jinja2 template used for the website can also highlight the version of code if it doesn't match a desired version.
- Host: GitHub
- URL: https://github.com/network-automation/ansible_inventory_report
- Owner: network-automation
- License: other
- Created: 2017-09-29T17:30:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-08-31T20:03:27.000Z (over 4 years ago)
- Last Synced: 2024-11-16T06:30:31.904Z (2 months ago)
- Topics: ansible, nxos, playbook
- Language: HTML
- Homepage:
- Size: 366 KB
- Stars: 130
- Watchers: 18
- Forks: 74
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-list-ansible - ansible_inventory_report
README
Example of Networking Inventory with Ansible
============================================One of the many use cases for Ansible and the [networking modules][2] is to grab
information in real time from the network. In this example I will generate a
HTML report using the template module from facts I have gathered with the
[nxos_facts module][1]. ![HTML report generated by template module][3]The playbook
------------Only two modules are needed for this example. The [nxos_facts module][1] and
the [template module][5]
```
---
- name: build NXOS inventory report
hosts: nxos
connection: network_cli
gather_facts: Falsevars:
desired_version: "7.0(3)I7(1)"
file_path: /var/www/html/generated_report.htmltasks:
- name: gathering nxos facts
nxos_facts:
provider: "{{login_info}}"
register: all_facts- name: create HTML report
template:
src: report.j2
dest: "{{ file_path }}"
delegate_to: localhost
run_once: true
```Running the playbook
--------------------Use the `ansible-playbook` command:
```
[root@localhost ansible_inventory_report]# ansible-playbook inventory.ymlPLAY [cisco] ******************************************************************
TASK [gathering nxos facts] ***************************************************
ok: [n9k3]
ok: [n9k4]
ok: [n9k5]
ok: [n9k2]
ok: [n9k]
ok: [n9k6]TASK [create HTML report] *****************************************************
changed: [n9k -> localhost]PLAY RECAP ********************************************************************
n9k : ok=2 changed=1 unreachable=0 failed=0
n9k2 : ok=1 changed=0 unreachable=0 failed=0
n9k3 : ok=1 changed=0 unreachable=0 failed=0
n9k4 : ok=1 changed=0 unreachable=0 failed=0
n9k5 : ok=1 changed=0 unreachable=0 failed=0
n9k6 : ok=1 changed=0 unreachable=0 failed=0
```A very similar playbook can be used to generate a report for Cisco IOS devices
using the [ios_facts module][4]```
[root@localhost ansible_inventory_report]# ansible-playbook inventory-ios.ymlPLAY [build IOS XE inventory] *************************************************
TASK [gathering IOS XE facts] *************************************************
ok: [172.26.249.162]
ok: [172.26.249.161]
ok: [172.26.249.164]
ok: [172.26.249.163]
ok: [172.26.249.160]
ok: [172.26.249.151]
ok: [172.26.249.166]
ok: [172.26.249.153]
ok: [172.26.249.169]
ok: [172.26.249.152]
ok: [172.26.249.154]
ok: [172.26.249.159]TASK [create HTML report] ***************************************************
changed: [172.26.249.160 -> localhost]PLAY RECAP ******************************************************************
172.26.249.151 : ok=1 changed=0 unreachable=0 failed=0
172.26.249.152 : ok=1 changed=0 unreachable=0 failed=0
172.26.249.153 : ok=1 changed=0 unreachable=0 failed=0
172.26.249.154 : ok=1 changed=0 unreachable=0 failed=0
172.26.249.159 : ok=1 changed=0 unreachable=0 failed=0
172.26.249.160 : ok=2 changed=1 unreachable=0 failed=0
172.26.249.161 : ok=1 changed=0 unreachable=0 failed=0
172.26.249.162 : ok=1 changed=0 unreachable=0 failed=0
172.26.249.163 : ok=1 changed=0 unreachable=0 failed=0
172.26.249.164 : ok=1 changed=0 unreachable=0 failed=0
172.26.249.166 : ok=1 changed=0 unreachable=0 failed=0
172.26.249.169 : ok=1 changed=0 unreachable=0 failed=0
```---
![Red Hat Ansible Automation][6]Red Hat® Ansible® Automation consists of three products:
- [Red Hat® Ansible® Tower][7]: Built for operationalizing and scaling
automation, managing complex deployments and speeding up productivity. Extend
the power of Ansible Tower with Workflows and Surveys to streamline jobs and
simple tools to share solutions with your team.- [Red Hat® Ansible® Engine][8]: a fully supported product built on the
foundational capabilities of the Ansible project. Also provides support for
select modules including Infoblox.- [Red Hat® Ansible® Network Automation][9]: provides support for select
networking modules from Arista (EOS), Cisco (IOS, IOS XR, NX-OS), Juniper
(JunOS), Open vSwitch, and VyOS. Includes Ansible Tower, Ansible Engine, and
curated content specifically for network use cases.[1]: http://docs.ansible.com/ansible/latest/nxos_facts_module.html
[2]: http://docs.ansible.com/ansible/latest/list_of_network_modules.html
[3]: images/htmlreport.png
[4]: http://docs.ansible.com/ansible/latest/ios_facts_module.html
[5]: http://docs.ansible.com/ansible/latest/template_module.html
[6]: images/rh-ansible-automation.png
[7]: https://www.ansible.com/tower
[8]: https://www.ansible.com/ansible-engine
[9]: https://www.ansible.com/networking