Skip to content

ansible-network/network.reports

Repository files navigation

Ansible Network Reports

CI OpenSSF Best Practices

About

  • The Ansible Network Reports Collection provides a platform-agnostic way to gather, generate, persist, and visualize network resource reports. This collection enables users to collect network facts, convert them into structured formats (YAML, JSON), and visualize them as HTML reports using Jinja2 templates.

  • This collection can be used by network administrators, system operators, and IT professionals looking to monitor and manage their network infrastructure through automated reporting.

Screenshot from 2025-02-11 17-30-19

Requirements

Installation

To consume this Validated Content from Automation Hub, the following needs to be added to ansible.cfg:

[galaxy]
server_list = automation_hub

[galaxy_server.automation_hub]
url=https://console.redhat.com/api/automation-hub/content/validated/
auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
token=<SuperSecretToken>

Utilize the current Token, and if the token has expired, obtain the necessary token from the Automation Hub Web UI.

With this configured, simply run the following commands:

ansible-galaxy collection install network.base
ansible-galaxy collection install network.reports

Use Cases

1. Gather Network Resource Reports

  • Collect network resource facts like interfaces, BGP configurations, OSPF settings, etc.
  • Convert these facts into YAML, JSON, or HTML formats.
- name: Gather Network Reports
  hosts: network_devices
  gather_facts: false
  tasks:
    - name: Network Resource Manager
      ansible.builtin.include_role:
        name: network.reports.gather
      vars:
        format:
          - yaml
          - json
        resources:
          - interfaces
          - l2_interfaces
          - bgp_global

2. Generate HTML Reports from Network Facts

  • Convert collected facts into HTML web reports using Jinja2 templates.
  • Run a lightweight web server to visualize the reports.
- name: Generate Network HTML Report
  hosts: network_devices
  gather_facts: false
  tasks:
    - name: Generate Network Report
      ansible.builtin.include_role:
        name: network.reports.generate_web_report
      vars:
        file_path: "./network_reports"

3. Persist Network Reports to SCM (GitHub/GitLab)

  • Persist generated reports into GitHub or GitLab repositories for version control and audit.
- name: Persist Reports to GitHub
  hosts: network_devices
  gather_facts: false
  tasks:
    - name: Persist Reports to GitHub Repository
      ansible.builtin.include_role:
        name: network.reports.persist
      vars:
        scm:
          origin:
            url: "{{ github_repo_url }}"
            token: "{{ github_access_token }}"
            user:
              name: "{{ git_user_name }}"
              email: "{{ git_user_email }}"

Testing

The project uses tox to run ansible-lint and ansible-test sanity. Assuming this repository is checked out in the proper structure, e.g., collections_root/ansible_collections/network/reports, run:

  tox -e ansible-lint
  tox -e py39-sanity

To run integration tests, ensure that your inventory has a network_reports group.

[network_devices]
ios
junos

[ios:vars]
< enter inventory details for IOS devices >

[junos:vars]
< enter inventory details for Junos devices >
  ansible-test network-integration -i /path/to/inventory --python 3.9 [target]

Contributing

We welcome community contributions to this collection. If you find problems, please open an issue or create a PR against this repository.

Don't know how to start? Refer to the Ansible community guide!

Want to submit code changes? Take a look at the Quick-start development guide.

We also use the following guidelines:

Code of Conduct

This collection follows the Ansible project's Code of Conduct. Please read and familiarize yourself with this document.

Release Notes

Release notes are available here.

Related Information

Licensing

GNU General Public License v3.0 or later.

See LICENSE to see the full text.

GNU General Public License v3.0 or later.

See LICENSE to see the full text.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages