{"id":13753618,"url":"https://github.com/network-automation/ansible_inventory_report","last_synced_at":"2025-10-10T10:34:39.923Z","repository":{"id":63486821,"uuid":"105299715","full_name":"network-automation/ansible_inventory_report","owner":"network-automation","description":"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.  ","archived":false,"fork":false,"pushed_at":"2020-08-31T20:03:27.000Z","size":375,"stargazers_count":136,"open_issues_count":0,"forks_count":76,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-07-25T02:50:59.166Z","etag":null,"topics":["ansible","nxos","playbook"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/network-automation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-29T17:30:31.000Z","updated_at":"2025-06-11T13:04:23.000Z","dependencies_parsed_at":"2022-11-19T21:46:16.321Z","dependency_job_id":null,"html_url":"https://github.com/network-automation/ansible_inventory_report","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/network-automation/ansible_inventory_report","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/network-automation%2Fansible_inventory_report","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/network-automation%2Fansible_inventory_report/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/network-automation%2Fansible_inventory_report/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/network-automation%2Fansible_inventory_report/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/network-automation","download_url":"https://codeload.github.com/network-automation/ansible_inventory_report/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/network-automation%2Fansible_inventory_report/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003544,"owners_count":26083595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","nxos","playbook"],"created_at":"2024-08-03T09:01:25.745Z","updated_at":"2025-10-10T10:34:39.884Z","avatar_url":"https://github.com/network-automation.png","language":"HTML","funding_links":[],"categories":["playbook"],"sub_categories":[],"readme":"Example of Networking Inventory with Ansible\n============================================\n\nOne of the many use cases for Ansible and the [networking modules][2] is to grab\ninformation in real time from the network.  In this example I will generate a\nHTML report using the template module from facts I have gathered with the\n[nxos_facts module][1].  ![HTML report generated by template module][3]\n\nThe playbook\n------------\n\nOnly two modules are needed for this example.  The [nxos_facts module][1] and\nthe [template module][5]\n```\n---\n- name: build NXOS inventory report\n  hosts: nxos\n  connection: network_cli\n  gather_facts: False\n\n  vars:\n    desired_version: \"7.0(3)I7(1)\"\n    file_path: /var/www/html/generated_report.html\n\n  tasks:\n    - name: gathering nxos facts\n      nxos_facts:\n        provider: \"{{login_info}}\"\n      register: all_facts\n\n    - name: create HTML report\n      template:\n        src: report.j2\n        dest: \"{{ file_path }}\"\n      delegate_to: localhost\n      run_once: true\n```\n\nRunning the playbook\n--------------------\n\nUse the `ansible-playbook` command:\n```\n[root@localhost ansible_inventory_report]# ansible-playbook inventory.yml\n\nPLAY [cisco] ******************************************************************\n\nTASK [gathering nxos facts] ***************************************************\nok: [n9k3]\nok: [n9k4]\nok: [n9k5]\nok: [n9k2]\nok: [n9k]\nok: [n9k6]\n\nTASK [create HTML report] *****************************************************\nchanged: [n9k -\u003e localhost]\n\nPLAY RECAP ********************************************************************\nn9k                        : ok=2    changed=1    unreachable=0    failed=0\nn9k2                       : ok=1    changed=0    unreachable=0    failed=0\nn9k3                       : ok=1    changed=0    unreachable=0    failed=0\nn9k4                       : ok=1    changed=0    unreachable=0    failed=0\nn9k5                       : ok=1    changed=0    unreachable=0    failed=0\nn9k6                       : ok=1    changed=0    unreachable=0    failed=0\n```\n\nA very similar playbook can be used to generate a report for Cisco IOS devices\nusing the [ios_facts module][4]\n\n```\n[root@localhost ansible_inventory_report]# ansible-playbook inventory-ios.yml\n\nPLAY [build IOS XE inventory] *************************************************\n\nTASK [gathering IOS XE facts] *************************************************\nok: [172.26.249.162]\nok: [172.26.249.161]\nok: [172.26.249.164]\nok: [172.26.249.163]\nok: [172.26.249.160]\nok: [172.26.249.151]\nok: [172.26.249.166]\nok: [172.26.249.153]\nok: [172.26.249.169]\nok: [172.26.249.152]\nok: [172.26.249.154]\nok: [172.26.249.159]\n\nTASK [create HTML report] ***************************************************\nchanged: [172.26.249.160 -\u003e localhost]\n\nPLAY RECAP ******************************************************************\n172.26.249.151             : ok=1    changed=0    unreachable=0    failed=0\n172.26.249.152             : ok=1    changed=0    unreachable=0    failed=0\n172.26.249.153             : ok=1    changed=0    unreachable=0    failed=0\n172.26.249.154             : ok=1    changed=0    unreachable=0    failed=0\n172.26.249.159             : ok=1    changed=0    unreachable=0    failed=0\n172.26.249.160             : ok=2    changed=1    unreachable=0    failed=0\n172.26.249.161             : ok=1    changed=0    unreachable=0    failed=0\n172.26.249.162             : ok=1    changed=0    unreachable=0    failed=0\n172.26.249.163             : ok=1    changed=0    unreachable=0    failed=0\n172.26.249.164             : ok=1    changed=0    unreachable=0    failed=0\n172.26.249.166             : ok=1    changed=0    unreachable=0    failed=0\n172.26.249.169             : ok=1    changed=0    unreachable=0    failed=0\n```\n\n---\n![Red Hat Ansible Automation][6]\n\nRed Hat® Ansible® Automation consists of  three products:\n\n- [Red Hat® Ansible® Tower][7]: Built for operationalizing and scaling\n  automation, managing complex deployments and speeding up productivity. Extend\n  the power of Ansible Tower with Workflows and Surveys to streamline jobs and\n  simple tools to share solutions with your team.\n\n- [Red Hat® Ansible® Engine][8]: a fully supported product built on the\n  foundational capabilities of the Ansible project. Also provides support for\n  select modules including Infoblox.\n\n- [Red Hat® Ansible® Network Automation][9]: provides support for select\n  networking modules from Arista (EOS), Cisco (IOS, IOS XR, NX-OS), Juniper\n  (JunOS), Open vSwitch, and VyOS. Includes Ansible Tower, Ansible Engine, and\n  curated content specifically for network use cases.\n\n[1]: http://docs.ansible.com/ansible/latest/nxos_facts_module.html\n[2]: http://docs.ansible.com/ansible/latest/list_of_network_modules.html\n[3]: images/htmlreport.png\n[4]: http://docs.ansible.com/ansible/latest/ios_facts_module.html\n[5]: http://docs.ansible.com/ansible/latest/template_module.html\n[6]: images/rh-ansible-automation.png\n[7]: https://www.ansible.com/tower\n[8]: https://www.ansible.com/ansible-engine\n[9]: https://www.ansible.com/networking\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetwork-automation%2Fansible_inventory_report","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetwork-automation%2Fansible_inventory_report","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetwork-automation%2Fansible_inventory_report/lists"}