diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml deleted file mode 100644 index a0bc47d..0000000 --- a/.github/linters/.markdown-lint.yml +++ /dev/null @@ -1,6 +0,0 @@ -{ - "default": true, - "MD003": false, - "MD013": false, - "MD033": false -} \ No newline at end of file diff --git a/.github/linters/ansible-lint.yml b/.github/linters/ansible-lint.yml deleted file mode 100644 index 1339519..0000000 --- a/.github/linters/ansible-lint.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -########################## -########################## -## Ansible Linter rules ## -########################## -########################## - -############################# -# Exclude paths from linter # -############################# -#exclude_paths: - -######################## -# Make output parsable # -######################## -parseable: true - -####################### -# Set output to quiet # -####################### -quiet: true - -##################### -# Path to rules dir # -##################### -#rulesdir: - -################ -# Tags to skip # -################ -skip_list: - - 'empty-string-compare' # Allow compare to empty string - - '204' # Allow string length greater than 160 chars - - 'no-changed-when' # False positives for running command shells - - 'command-instead-of-module' # Allow git commands for push, add, etc... - - 'command-instead-of-shell' # Allow use of shell when you want - - 'no-handler' # Allow step to run like handler - -################## -# Tags to follow # -################## -#tags: - -############# -# Use rules # -############# -use_default_rules: true - -################# -# Set verbosity # -################# -verbosity: 1 diff --git a/.github/linters/markdown-lint.yml b/.github/linters/markdown-lint.yml deleted file mode 100644 index 89963f4..0000000 --- a/.github/linters/markdown-lint.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -########################### -########################### -## Markdown Linter rules ## -########################### -########################### - -# Linter rules doc: -# - https://github.com/DavidAnson/markdownlint -# -# Note: -# To comment out a single error: -# -# any violations you want -# -# - -############### -# Rules by id # -############### -MD004: false # Unordered list style -MD007: - indent: 2 # Unordered list indentation -MD013: - line_length: 400 # Line length 80 is far to short -MD026: - punctuation: ".,;:!。,;:" # List of not allowed -MD029: false # Ordered list item prefix -MD033: false # Allow inline HTML -MD036: false # Emphasis used instead of a heading - -################# -# Rules by tags # -################# -blank_lines: false # Error on blank lines diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..ba6ee68 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,46 @@ +# Contribution Guidelines +This document aims to outline the requirements for the various forms of contribution for this project. + +**ALL** contributions are subject to review via pull request + +## Pull Requests +1) Ensure the "base repository" is set to "RedHatGov/product-demos" since this is a fork it defaults to it's parent "ansible/product-demos". + +### Pull Request Guidelines +- PRs should include the playbook/demo and required entry in corresponding `/setup.yml`. +- PRs should include documentation in corresponding `/README.md`. +- PRs should be rebased against the `main` branch to avoid conflicts. +- PRs should not impact more than a single directory/demo section. +- PRs should not rely on external infrastructure or configuration unless the dependency is automated or specified in the `user_message` of `setup.yml`. + +## Adding a New Demo +1) Create a new branch based on main. (eg. `git checkout -b `) +2) Add your playbook to the appropriate demo/section subdirectory. +3) Make any changes needed to match the existing standards in the directory. + 1) Ex: Parameterized hosts + ```ansible + hosts: "{{ HOSTS | default('windows') }}" + ``` +4) Create an entry for your playbook in your subdirectories `setup.yml` + 1) You can copy paste an existing one and edit it. + 2) Ensure you edit the name, playbook path, survey etc. +5) Add any needed roles/collections to the [requirements.yml](/collections/requirements.yml) +6) Test via RHPDS, specify your branch name within the project configuration. + +## New Demo Section/Category +1) Create a new subdirectory with no spaces +2) Create a new setup.yml copying appropriate elements from another + - Below is a sample skeleton for a new setup.yml + ```ansible + --- + user_message: '' + + controller_components: + - job_templates + + controller_templates: + ... + ``` + - `controller_components` can be any of the roles defined [here](https://github.com/redhat-cop/controller_configuration/tree/devel/roles) + - Add variables for each component listed +3) Include a README.md in the subdirectory diff --git a/README.md b/README.md index d490a3b..665c9da 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,20 @@ This is a centralized location for all Ansible Product Demos going forward. -| Demo Name | Description | -|------------------------------------------------------------------|---------------------------------------------------------------------------------------------| -| [AAP on CodeReady](aap-on-crc/README.md) | Repository and video of how to install Ansible Automation Platform on Code Ready Containers | -| [Infrastructure Demos](old-demo-repository#infrastructure-demos) | Azure, AWS, Chocolatey, Linux and Windows Demos | -| [Network Demos](old-demo-repository#network-demos) | Cisco IOS and F5 Demos | -| [Security Demos](old-demo-repository#security-demos) | OSCAP and hardening demos | -| [Developer Demos](old-demo-repository#developer-demos) | Create Reports with Ansible | +| Demo Name | Description | +|-----------|-------------| +| [Linux](linux/README.md) | Repository of demos for RHEL and Linux automation | +| [Windows](windows/README.md) | Repository of demos for Windows Server automation | +| [Cloud](cloud/README.md) | Demo for infrastructure and cloud provisioning automation | +| [Network](network/README.md) | Ansible Network automation demos | ## Contributions -Please push contributions via a pull request following the naming convention of name-of-demo. - -[![GitHub Super-Linter](https://github.com/ansible/ansible-demos/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter) - +If you would like to contribute to this project please refer to [contribution guide](CONTRIBUTING.md) for best practices. ## Using this project - > This project is tested for compatibility with AAP2 Linux Automation Workshop available to Red Hat Employees and Partners. + > This project is tested for compatibility with AAP2 Linux Automation Workshop available to Red Hat Employees and Partners. To use with other Ansible Controller installations, review the [pre-requisite documentation](https://github.com/RedHatGov/ansible-tower-samples/tree/product-demos). 1. First you must create a credential for [Automation Hub](https://console.redhat.com/ansible/automation-hub/) to successfully sync collections used by this project. @@ -40,6 +36,4 @@ Please push contributions via a pull request following the naming convention of - Name: Controller Credential - Extra vars: - demo: - -4. If you require a Windows Active Directory domain you will need to run the "ACTIVE DIRECTORY / Create Active Directory domain" template after the Windows setup completes. This will create the "ansible.local" domain as well as a few generic users and groups. \ No newline at end of file + demo: diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..5bd4066 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,3 @@ +[defaults] +collections_paths=./collections +roles_path=./roles diff --git a/cloud/aws_key.yml b/cloud/aws_key.yml new file mode 100644 index 0000000..275eec6 --- /dev/null +++ b/cloud/aws_key.yml @@ -0,0 +1,25 @@ +--- +- name: Create AWS keypair + hosts: localhost + vars: + aws_key_name: aws-test-key + aws_keypair_owner: undef + + tasks: + - name: Fail if variables not defined + ansible.builtin.assert: + that: + - aws_key_name is defined + - aws_region is defined + - aws_public_key is defined + - aws_keypair_owner is defined + fail_msg: "Required variables not set" + + - name: Create AWS keypair + amazon.aws.ec2_key: + name: "{{ aws_key_name }}" + region: "{{ aws_region }}" + key_material: "{{ aws_public_key }}" + state: present + tags: + owner: "{{ aws_keypair_owner }}" diff --git a/cloud/blueprints/rhel9.yml b/cloud/blueprints/rhel9.yml new file mode 100644 index 0000000..244a0d5 --- /dev/null +++ b/cloud/blueprints/rhel9.yml @@ -0,0 +1,7 @@ +--- +vm_providers: + - aws +aws_image_owners: 309956199498 +aws_instance_size: t3.micro +aws_image_architecture: x86_64 +aws_image_filter: 'RHEL-9*HVM-*Hourly*' \ No newline at end of file diff --git a/cloud/setup.yml b/cloud/setup.yml index dc61b61..97984e9 100644 --- a/cloud/setup.yml +++ b/cloud/setup.yml @@ -1,13 +1,27 @@ --- user_message: - - Update AWS credential with Access and Secret key - - Update Workshop Credential with password used to login to Controller controller_components: + - execution_environments + - projects - credentials - inventory_sources + - groups - job_templates +controller_execution_environments: + - name: Cloud Services Execution Environment + image: quay.io/scottharwell/cloud-ee:latest + +controller_projects: +- name: Ansible Cloud Content Lab - AWS + organization: Default + scm_type: git + wait: yes + #scm_url: https://github.com/ansible-content-lab/aws.infrastructure_config_demos.git + scm_url: https://github.com/willtome/aws.infrastructure_config_demos.git + default_environment: Cloud Services Execution Environment + controller_credentials: - name: AWS credential_type: Amazon Web Services @@ -36,11 +50,17 @@ controller_inventory_sources: - tag:Name compose: ansible_host: public_ip_address + ansible_user: 'ec2-user' groups: cloud_aws: true + os_linux: tags.blueprint.startswith('rhel') keyed_groups: - key: platform prefix: os + - key: tags.blueprint + prefix: blueprint + - key: tags.owner + prefix: owner #- name: Azure Inventory # organization: Default @@ -59,7 +79,73 @@ controller_inventory_sources: # conditional_groups: # cloud_azure: true +controller_groups: + - name: cloud_aws + inventory: Workshop Inventory + variables: + ansible_user: ec2-user + controller_templates: + - name: Cloud / AWS / Create Peer Infrastructure + job_type: run + organization: Default + credentials: + - AWS + project: Ansible Cloud Content Lab - AWS + playbook: playbook_create_peer_network.yml + inventory: Workshop Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + extra_vars: + aws_region: us-east-1 + dmz_ssh_key_name: aws-test-key + priv_network_ssh_key_name: aws-test-key + + - name: Cloud / AWS / Delete Peer Infrastructure + job_type: run + organization: Default + credentials: + - AWS + project: Ansible Cloud Content Lab - AWS + playbook: playbook_delete_peer_network.yml + inventory: Workshop Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + extra_vars: + aws_region: us-east-1 + + - name: Cloud / AWS / Create Transit Infrastructure + job_type: run + organization: Default + credentials: + - AWS + project: Ansible Cloud Content Lab - AWS + playbook: playbook_create_transit_network.yml + inventory: Workshop Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + extra_vars: + aws_region: us-east-1 + dmz_ssh_key_name: aws-test-key + priv_network_ssh_key_name: aws-test-key + + - name: Cloud / AWS / Delete Transit Infrastructure + job_type: run + organization: Default + credentials: + - AWS + project: Ansible Cloud Content Lab - AWS + playbook: playbook_delete_transit_network.yml + inventory: Workshop Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + extra_vars: + aws_region: us-east-1 + - name: Cloud / Create Infra job_type: run organization: Default @@ -69,7 +155,9 @@ controller_templates: project: Ansible official demo project playbook: cloud/create_infra.yml inventory: Workshop Inventory - execution_environment: Default execution environment + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry survey_enabled: true extra_vars: aws_region: us-east-2 @@ -88,20 +176,23 @@ controller_templates: type: textarea required: false variable: aws_public_key - - name: Cloud / Create VM + + - name: Cloud / AWS / Create VM job_type: run organization: Default credentials: - AWS - #- Azure - Workshop Credential - project: Ansible official demo project - playbook: cloud/create_vm.yml + project: Ansible Cloud Content Lab - AWS + playbook: playbook_create_vm.yml inventory: Workshop Inventory - execution_environment: Default execution environment + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry survey_enabled: true extra_vars: - aws_region: us-east-2 + aws_region: us-east-1 + aws_keypair_name: aws-test-key survey: name: '' description: '' @@ -114,42 +205,121 @@ controller_templates: type: text variable: vm_owner required: true - - question_name: Provider + - question_name: Deployment + type: text + variable: vm_deployment + required: true + - question_name: Environment type: multiplechoice - variable: vm_provider + variable: vm_environment required: true choices: - - aws - #- azure + - Dev + - QA + - Prod - question_name: Blueprint type: multiplechoice variable: vm_blueprint required: true - choices: #"{{ lookup('fileglob', 'blueprints/*.yml') | regex_replace(',','\n') | regex_findall('.*/(.*)(?=.yml)') | list }}" + choices: - windows_core - windows_full + - rhel9 - rhel8 - rhel7 - - name: Cloud / Destroy VM + - question_name: Subnet + type: text + variable: aws_vpc_subnet_name + required: true + default: dmz-subnet + - question_name: Security Group + type: text + variable: aws_securitygroup_name + required: true + default: dmz-sg + + - name: Cloud / AWS / Delete VM job_type: run organization: Default credentials: - AWS - #- Azure - Workshop Credential - project: Ansible official demo project - playbook: cloud/destroy_vm.yml + project: Ansible Cloud Content Lab - AWS + playbook: playbook_delete_inventory_vm.yml inventory: Workshop Inventory - execution_environment: Default execution environment + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry survey_enabled: true extra_vars: - aws_region: us-east-2 + aws_region: us-east-1 survey: name: '' description: '' spec: - question_name: Name or Pattern type: text - variable: HOSTS + variable: _hosts required: true + - name: Cloud / AWS / VPC Report + job_type: run + organization: Default + credentials: + - AWS + project: Ansible Cloud Content Lab - AWS + playbook: playbook_create_reports.yml + inventory: Workshop Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + extra_vars: + aws_region: us-east-1 + aws_report: vpc + + - name: Cloud / AWS / Tags Report + job_type: run + organization: Default + credentials: + - AWS + project: Ansible Cloud Content Lab - AWS + playbook: playbook_create_reports.yml + inventory: Workshop Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + extra_vars: + aws_region: us-east-1 + aws_report: tags + + - name: Cloud / AWS / Create Keypair + job_type: run + organization: Default + credentials: + - AWS + project: Ansible official demo project + playbook: cloud/aws_key.yml + inventory: Workshop Inventory + notification_templates_started: Telemetry + notification_templates_success: Telemetry + notification_templates_error: Telemetry + survey_enabled: true + extra_vars: + aws_region: us-east-1 + survey: + name: '' + description: '' + spec: + - question_name: Keypair Name + type: text + variable: aws_key_name + required: true + default: aws-test-key + - question_name: Keypair Public Key + type: textarea + variable: aws_public_key + required: true + - question_name: Owner + type: text + variable: aws_keypair_owner + required: true 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/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 @@ - +
-
- -