diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/example_results/Ansible Network Automation Report.png b/collections/ansible_collections/demo/patching/roles/build_report_network/example_results/Ansible Network Automation Report.png index d766491..2cfac3a 100644 Binary files a/collections/ansible_collections/demo/patching/roles/build_report_network/example_results/Ansible Network Automation Report.png and b/collections/ansible_collections/demo/patching/roles/build_report_network/example_results/Ansible Network Automation Report.png differ diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/files/css/main.css b/collections/ansible_collections/demo/patching/roles/build_report_network/files/css/main.css new file mode 100644 index 0000000..d978eb3 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/files/css/main.css @@ -0,0 +1,207 @@ +p.hostname { + color: #000000; + font-weight: bolder; + font-size: large; + margin: auto; + width: 50%; +} + +#subtable { + background: #ebebeb; + margin: 0px; + width: 100%; +} + +#subtable tbody tr td { + padding: 5px 5px 5px 5px; +} + +#subtable thead th { + padding: 5px; +} + +* { + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; + font-family: "Open Sans", "Helvetica"; + +} + +a { + color: #ffffff; +} + +p { + color: #ffffff; +} +h1 { + text-align: center; + color: #ffffff; +} + +body { + background:#353a40; + padding: 0px; + margin: 0px; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; +} + +table { + border-collapse: separate; + background:#fff; + @include border-radius(5px); + @include box-shadow(0px 0px 5px rgba(0,0,0,0.3)); +} + +.main_net_table { + margin:50px auto; +} + +.main_net_table { + margin:50px auto; +} + +thead { + @include border-radius(5px); +} + +thead th { + font-size:16px; + font-weight:400; + color:#fff; + @include text-shadow(1px 1px 0px rgba(0,0,0,0.5)); + text-align:left; + padding:20px; + border-top:1px solid #858d99; + background: #353a40; + + &:first-child { + @include border-top-left-radius(5px); + } + + &:last-child { + @include border-top-right-radius(5px); + } +} + +tbody tr td { + font-weight:400; + color:#5f6062; + font-size:13px; + padding:20px 20px 20px 20px; + border-bottom:1px solid #e0e0e0; + +} + +tbody tr:nth-child(2n) { + background:#f0f3f5; +} + +tbody tr:last-child td { + border-bottom:none; + &:first-child { + @include border-bottom-left-radius(5px); + } + &:last-child { + @include border-bottom-right-radius(5px); + } +} + +td { + vertical-align: top; +} + +span.highlight { + background-color: yellow; +} + +.expandclass { + color: #5f6062; +} + +.content{ + display:none; + margin: 10px; +} + +header { + width: 100%; + position: initial; + float: initial; + padding: 0; + margin: 0; + border-radius: 0; + height: 88px; + background-color: #171717; +} + +.header-container { + margin: 0 auto; + width: 100%; + height: 100%; + max-width: 1170px; + padding: 0; + float: initial; + display: flex; + align-items: center; +} + +.header-logo { + width: 137px; + border: 0; + margin: 0; + margin-left: 15px; +} + +.header-link { + margin-left: 40px; + text-decoration: none; + cursor: pointer; + text-transform: uppercase; + font-size: 15px; + font-family: 'Red Hat Text'; + font-weight: 500; +} + +.header-link:hover { + text-shadow: 0 0 0.02px white; + text-decoration: none; +} + +table.net_info td { + padding: 5px; +} + +p.expandclass:hover { + text-decoration: underline; + color: #EE0000; + cursor: pointer; +} + +.summary_info { +} + +.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active, a.ui-button:active, .ui-button:active, .ui-button.ui-state-active:hover { + border: 1px solid #5F0000; + background: #EE0000; +} + +div#net_content { + padding: 0px; + height: auto !important; +} + +img.router_image { + vertical-align: middle; + padding: 0px 10px 10px 10px; + width: 50px; +} + +table.net_info { + width: 100%; +} + +p.internal_label { + color: #000000; +} diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/files/css/new.css b/collections/ansible_collections/demo/patching/roles/build_report_network/files/css/new.css deleted file mode 100644 index f58d18f..0000000 --- a/collections/ansible_collections/demo/patching/roles/build_report_network/files/css/new.css +++ /dev/null @@ -1,202 +0,0 @@ -p.hostname { - color: #000000; - font-weight: bolder; - font-size: large; - margin: auto; - width: 50%; - } - - #subtable { - background: #ebebeb; - margin: 0px; - width: 100%; - } - - #subtable tbody tr td { - padding: 5px 5px 5px 5px; - } - - #subtable thead th { - padding: 5px; - } - - * { - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; - font-family: "Open Sans", "Helvetica"; - - } - - a { - color: #ffffff; - } - - p { - color: #ffffff; - } - h1 { - text-align: center; - color: #ffffff; - } - - body { - background:#353a40; - padding: 0px; - margin: 0px; - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - } - - table { - border-collapse: separate; - background:#fff; - @include border-radius(5px); - @include box-shadow(0px 0px 5px rgba(0,0,0,0.3)); - } - - .main_net_table { - margin:50px auto; - } - - thead { - @include border-radius(5px); - } - - thead th { - font-size:16px; - font-weight:400; - color:#fff; - @include text-shadow(1px 1px 0px rgba(0,0,0,0.5)); - text-align:left; - padding:20px; - border-top:1px solid #858d99; - background: #353a40; - - &:first-child { - @include border-top-left-radius(5px); - } - - &:last-child { - @include border-top-right-radius(5px); - } - } - - tbody tr td { - font-weight:400; - color:#5f6062; - font-size:13px; - padding:20px 20px 20px 20px; - border-bottom:1px solid #e0e0e0; - } - - tbody tr:nth-child(2n) { - background:#f0f3f5; - } - - tbody tr:last-child td { - border-bottom:none; - &:first-child { - @include border-bottom-left-radius(5px); - } - &:last-child { - @include border-bottom-right-radius(5px); - } - } - - td { - vertical-align: top; - } - - span.highlight { - background-color: yellow; - } - - .expandclass { - color: #5f6062; - } - - .content{ - display:none; - margin: 10px; - } - - header { - width: 100%; - position: initial; - float: initial; - padding: 0; - margin: 0; - border-radius: 0; - height: 88px; - background-color: #171717; - } - - .header-container { - margin: 0 auto; - width: 100%; - height: 100%; - max-width: 1170px; - padding: 0; - float: initial; - display: flex; - align-items: center; - } - - .header-logo { - width: 137px; - border: 0; - margin: 0; - margin-left: 15px; - } - - .header-link { - margin-left: 40px; - text-decoration: none; - cursor: pointer; - text-transform: uppercase; - font-size: 15px; - font-family: 'Red Hat Text'; - font-weight: 500; - } - - .header-link:hover { - text-shadow: 0 0 0.02px white; - text-decoration: none; - } - - table.net_info td { - padding: 5px; -} - -p.expandclass:hover { - text-decoration: underline; - color: #EE0000; - cursor: pointer; -} - -.summary_info { -} - -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active, a.ui-button:active, .ui-button:active, .ui-button.ui-state-active:hover { - border: 1px solid #5F0000; - background: #EE0000; -} - -div#net_content { - padding: 0px; - height: auto !important; -} - -img.router_image { - vertical-align: middle; - padding: 0px 10px 10px 10px; - width: 50px; -} - -table.net_info { - width: 100%; -} - -p.internal_label { - color: #000000; -} \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/tasks/main.yml b/collections/ansible_collections/demo/patching/roles/build_report_network/tasks/main.yml index accaeba..f00e455 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_network/tasks/main.yml +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/tasks/main.yml @@ -1,13 +1,21 @@ +- name: Create web directory if it does not exist + ansible.builtin.file: + path: "{{ file_path }}" + state: directory + mode: '0755' + - name: create HTML report ansible.builtin.template: src: report.j2 dest: "{{ file_path }}/network.html" + check_mode: no - name: copy CSS over ansible.builtin.copy: src: "css" dest: "{{ file_path }}" directory_mode: true + check_mode: no - name: copy logos over ansible.builtin.copy: @@ -18,7 +26,8 @@ - "webpage_logo.png" - "redhat-ansible-logo.svg" - "router.png" + check_mode: no -- name: display link to inventory report - ansible.builtin.debug: - msg: "Please go to http://{{ ansible_host }}/network.html" \ No newline at end of file +# - name: Display link to Linux patch report +# ansible.builtin.debug: +# msg: "Please go to http://{{ hostvars[report_server]['ansible_host'] }}/reports/network.html" diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/ansible.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/ansible.j2 new file mode 100644 index 0000000..01386bf --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/ansible.j2 @@ -0,0 +1,41 @@ + +
+
+

Ansible Automation Info

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Ansible user{{ hostvars[network_switch]['ansible_user'] }}
Transport{% set ansible_connection = hostvars[network_switch]['ansible_net_api'] %}{{ transport[ansible_connection] }}
Ansible Mgmt IP{{ hostvars[network_switch]['ansible_host'] | default('N/A') }}
Ansible groups{% for group in hostvars[network_switch]['group_names'] %}{{ group }} {% endfor %}
Ansible core version{% for group in hostvars[network_switch]['ansible_version']['string']|default("Unknown") %}{{ group }} {% endfor %}
Ansible Python{{ hostvars[network_switch]['ansible_playbook_python']|default("Unknown") }}
Python version{{ hostvars[network_switch]['ansible_net_python_version']|default("Unknown") }}
+
+
+
+ diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/bgp.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/bgp.j2 index d6b0f67..97d1b5a 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/bgp.j2 +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/bgp.j2 @@ -1,25 +1,46 @@ - +
-
- - - \ No newline at end of file + diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/bgp_address_family.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/bgp_address_family.j2 new file mode 100644 index 0000000..94686a7 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/bgp_address_family.j2 @@ -0,0 +1,46 @@ + +
+
+

BGP Address Family

+
+{% if hostvars[network_switch]['ansible_network_resources']['bgp_address_family']['address_family'] is defined and hostvars[network_switch]['ansible_network_resources']['bgp_address_family']['address_family']|length > 0 %} + +{% for address_family in hostvars[network_switch]['ansible_network_resources']['bgp_address_family']['address_family'] %} +

Address Family {{ address_family['afi'] }}

+ + + + + + + + + {% if hostvars[network_switch]['ansible_network_resources']['bgp_address_family']['address_family']['networks'] is defined %} + {% for bgp_network in address_family['networks'] %} + + + + {% endfor %} + {% elif hostvars[network_switch]['ansible_network_resources']['bgp_address_family']['address_family']['network'] is defined %} + {% for bgp_network in address_family['network'] %} + + + + + {% endfor %} + {% else %} + No BGP networks information available + {% endif %} + +
Network
{{ bgp_network['prefix']|default("Not Configured") }}
{{ bgp_network['address']|default("Not Configured") }}{{ bgp_network['mask']|default("Not Configured") }}
+{% endfor %} + +{% elif hostvars[network_switch]['ansible_network_resources']['bgp_address_family']['address_family'] is defined and hostvars[network_switch]['ansible_network_resources']['bgp_address_family']['address_family']|length == 0 %} +no BGP address-family is not configured on this device +{% else %} +No BGP information available +{% endif %} +
+
+
+ diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/header.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/header.j2 index 6d504d0..25265ce 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/header.j2 +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/header.j2 @@ -1,5 +1,3 @@ - -
@@ -12,4 +10,4 @@ />
-
\ No newline at end of file + diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/interfaces.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/interfaces.j2 index bf13414..ef80194 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/interfaces.j2 +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/interfaces.j2 @@ -1,10 +1,8 @@ - +
-
- - - \ No newline at end of file + diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/lldp_interfaces.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/lldp_interfaces.j2 index 3ad0852..6e4393a 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/lldp_interfaces.j2 +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/lldp_interfaces.j2 @@ -1,9 +1,9 @@ - +
-
- - - \ No newline at end of file + diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/ospf.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/ospf.j2 index d06ff5b..25ce225 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/ospf.j2 +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/ospf.j2 @@ -1,8 +1,8 @@ - +
-
- - - \ No newline at end of file + diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/report.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/report.j2 index f00eac7..c2e55e1 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/report.j2 +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/report.j2 @@ -1,13 +1,12 @@ - Ansible Network Automation Report + Network Automation Report - - - - + + + - -
{% include 'header.j2' %}
-

Ansible Network Automation Report

-

+

Ansible Network Automation Example Report

- +
@@ -75,35 +33,71 @@ collapsible: true -{% for network_switch in groups['tag_Router']|sort %} +{% for network_switch in groups['routers']|sort %} +{% if hostvars[network_switch].ansible_facts.network_resources is defined %} - - - - +

picture of network device{{ hostvars[network_switch].ansible_net_hostname }}

+ +
+
Network Device
-

- {{ hostvars[network_switch]['ansible_net_hostname'].split('.')[0] }}

-
-{% include 'summary.j2' %} -
-{% include 'interfaces.j2' %} - -{% include 'vlans.j2' %} -{% include 'lldp_interfaces.j2' %} -{% include 'l2_interfaces.j2' %} - -{% include 'l3_interfaces.j2' %} -{% include 'lacp.j2' %} -{% include 'bgp.j2' %} -{% include 'ospf.j2' %} -
+ + + + + + + + + + + + + + + + + + +
Platform{% set ansible_network_os = hostvars[network_switch]['ansible_net_system'] %}{{ vendor[ansible_network_os]}} {{hostvars[network_switch]['ansible_net_system'] }}
Code Version{{ hostvars[network_switch]['ansible_net_version'] }}
Model{{ hostvars[network_switch]['ansible_net_model'] }}
Serial Number{{ hostvars[network_switch]['ansible_net_serialnum'] | default('N/A') }}
+ + + {% include 'ansible.j2' %} +
+ + + + + + + {% include 'interfaces.j2' %} + + + {% include 'vlans.j2' %} + {% include 'lldp_interfaces.j2' %} + {% include 'l2_interfaces.j2' %} + + + {% include 'l3_interfaces.j2' %} + {% include 'lacp.j2' %} + {% include 'static.j2' %} + {% include 'bgp.j2' %} + {% include 'bgp_address_family.j2' %} + {% include 'ospf.j2' %} + +{% endif %} {% endfor %} -

Created with


+

Created with


red hat ansible automation platform logo +

The source code to create this report can be found at https://github.com/network-automation/toolkit

+If you are new to Ansible Automation check out the following links:
+Getting Started
+Free hands-on workshops
+Youtube Videos
+

diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/static.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/static.j2 new file mode 100644 index 0000000..33ce549 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/static.j2 @@ -0,0 +1,45 @@ + +
+
+

Static Routes

+
+{% if hostvars[network_switch]['ansible_network_resources']['static_routes'] is defined and hostvars[network_switch]['ansible_network_resources']['static_routes']|length > 0 %} + + + + + + + + + + + + +{% for net_route in hostvars[network_switch]['ansible_network_resources']['static_routes'] %} + + +{% for address_family in net_route.address_families|default([]) %} + +{% for routes in address_family['routes'] %} + +{% for next_hops in routes['next_hops'] %} + + + +{% endfor %} +{% endfor %} +{% endfor %} + +{% endfor %} + +
VRFAddress-FamilyRouteInterfaceNext-Hop AddressGlobal
{{ net_route['vrf']|default("N/A") }}{{ address_family['afi'] }}{{ routes['dest'] }}{{ next_hops['interface']|default("N/A") }}{{ next_hops['forward_router_address']|default("N/A") }}{{ next_hops['global']|default("N/A") }}
+{% elif hostvars[network_switch]['ansible_network_resources']['static_routes'] is defined and hostvars[network_switch]['ansible_network_resources']['static_routes']|length == 0 %} +Static Routes are not configured on this device +{% else %} +No Static Route information available +{% endif %} +
+
+
+ diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/summary.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/summary.j2 deleted file mode 100644 index 5f643e4..0000000 --- a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/summary.j2 +++ /dev/null @@ -1,25 +0,0 @@ -
- - - - - - - - - - - - - - - - - - - - - - -
Platform{{hostvars[network_switch]['ansible_net_system']}}
Code Version{{hostvars[network_switch]['ansible_net_version']}}
Model{{hostvars[network_switch]['ansible_net_model']|default("N/A")}}
Serial Number{{hostvars[network_switch]['ansible_net_serialnum']}}
Transport{{hostvars[network_switch]['ansible_net_api']}}
-
diff --git a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/vlans.j2 b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/vlans.j2 index 044a334..a01d56c 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_network/templates/vlans.j2 +++ b/collections/ansible_collections/demo/patching/roles/build_report_network/templates/vlans.j2 @@ -1,8 +1,8 @@ - +
-
- -