diff --git a/cloud/README.md b/cloud/README.md index 699e28c..1c9e9b6 100644 --- a/cloud/README.md +++ b/cloud/README.md @@ -1,11 +1,42 @@ -# Ansible Cloud Demos +# Cloud Demos + +## Table of Contents +- [Cloud Demos](#cloud-demos) + - [Table of Contents](#table-of-contents) + - [About These Demos](#about-these-demos) + - [Jobs](#jobs) + - [Inventory](#inventory) + - [Post Setup Setup](#post-setup-setup) + - [Configure Credentials](#configure-credentials) + - [Add Workshop Credential Password](#add-workshop-credential-password) + - [Remove Inventory Variables](#remove-inventory-variables) + - [Getting your Puiblic Key for Create Infra Job](#getting-your-puiblic-key-for-create-infra-job) + - [Suggested Usage](#suggested-usage) + - [Known Issues](#known-issues) + +## About These Demos +This category of demos shows examples of multi-cloud provisioning and management with Ansible Automation Platform. The list of demos can be found below. These demos are particularly helpful in building additional infrastructure for other demo categories such as Linux and Windows. See the [Suggested Usage](#suggested-usage) section of this document for recommendations on how to best use these demos. + +### Jobs + +- [**Cloud / Create Infra**](create_infra.yml) - Creates a VPC with required routing and firewall rules for provisioning VMs +- [**Cloud / Create VM**](create_vm.yml) - Create a VM based on a [blueprint](blueprints/) in the selected cloud provider +- [**Cloud / Destroy VM**](destroy_vm.yml) - Destroy a VM that has been created in a cloud provider. VM must be imported into dynamic inventory to be deleted. + +### Inventory + +A dynamic inventory is created to pull inventory hosts from cloud providers. The VM will be added by name therefore provisioning VMs with the same name will cause conflict in the inventory. + +Groups will be created based on the operating system (platform) of the VM provisioned as well as a group called `cloud_`. + +## Post Setup Setup +After running the setup job template, there are a few steps required to make the demos fully functional. See post setup actions below. -## Setup > These steps may differ if you in your environment -### Add AWS Credentials +### Configure Credentials -1) Add AWS Access and Secret key to the AWS Credential created by the setup job +- Add AWS Access and Secret key to the `AWS` Credential created by the setup job. ### Add Workshop Credential Password @@ -23,12 +54,11 @@ 4) `cat .ssh/authorized_keys` and copy the key listed including the `ssh-rsa` prefix -## Demos +## Suggested Usage -### Cloud / Create Infra +**Cloud / Create Infra** -The Create Infra job builds cloud infrastructure based on the provider definition in the included `demo.cloud` collection. -The Create Infra job builds cloud infrastructure based on the provider definition in the included `demo.cloud` collection. +**Cloud / Create VM** - The Create VM job builds a VM in the given provider based on the included `demo.cloud` collection. VM [blueprints](blueprints/) define variables for each provider that override the defaults in the collection. When creating VMs it is recommended to follow naming conventions that can be used as host patterns. (eg. VM names: `win1`, `win2`, `win3`. Host Pattern: `win*` ) -### Cloud / Create VM - -The Create VM job builds a VM in the given provider based on the included `demo.cloud` collection. VM blueprints define variables for each provider that override the collection roles. \ No newline at end of file +## Known Issues +Azure does not work without a custom execution environment that includes the Azure dependencies. \ No newline at end of file diff --git a/cloud/blueprints/windows.yml b/cloud/blueprints/windows.yml new file mode 100644 index 0000000..d70ca69 --- /dev/null +++ b/cloud/blueprints/windows.yml @@ -0,0 +1,14 @@ +--- +vm_blueprint_providers: + - aws + - azure +aws_image_filter: 'Windows_Server-2019-English-Core-Base*' +aws_instance_size: t3.medium +aws_userdata_template: aws_windows_userdata +az_vm_os_type: Windows +az_vm_size: Standard_DS1_v2 +az_vm_image: + offer: WindowsServer + publisher: MicrosoftWindowsServer + sku: 2022-Datacenter + version: latest \ No newline at end of file diff --git a/cloud/destroy_vm.yml b/cloud/destroy_vm.yml index 1c7c3e2..fe73c58 100644 --- a/cloud/destroy_vm.yml +++ b/cloud/destroy_vm.yml @@ -16,4 +16,4 @@ include_role: name: "demo.cloud.aws" tasks_from: destroy_vm - when: "'cloud_aws' in group_names" \ No newline at end of file + when: "'cloud_aws' in group_names or 'cloud_azure' in group_names" diff --git a/cloud/setup.yml b/cloud/setup.yml index 32aa69d..dc61b61 100644 --- a/cloud/setup.yml +++ b/cloud/setup.yml @@ -17,6 +17,13 @@ controller_credentials: username: REPLACEME password: REPLACEME + #- name: Azure + # credential_type: Microsoft Azure Resource Manager + # organization: Default + # update_secrets: false + # inputs: + # subscription: REPLACEME + controller_inventory_sources: - name: AWS Inventory organization: Default @@ -35,12 +42,30 @@ controller_inventory_sources: - key: platform prefix: os + #- name: Azure Inventory + # organization: Default + # source: azure_rm + # inventory: Workshop Inventory + # credential: Azure + # execution_environment: Ansible Engine 2.9 execution environment + # overwrite: true + # source_vars: + # hostnames: + # - tags.Name + # - default + # keyed_groups: + # - key: os_profile.system + # prefix: os + # conditional_groups: + # cloud_azure: true + controller_templates: - name: Cloud / Create Infra job_type: run organization: Default - credentials: + credentials: - AWS + #- Azure project: Ansible official demo project playbook: cloud/create_infra.yml inventory: Workshop Inventory @@ -58,6 +83,7 @@ controller_templates: required: true choices: - aws + #- azure - question_name: AWS Public Key (only required for aws provider) type: textarea required: false @@ -67,6 +93,7 @@ controller_templates: organization: Default credentials: - AWS + #- Azure - Workshop Credential project: Ansible official demo project playbook: cloud/create_vm.yml @@ -93,6 +120,7 @@ controller_templates: required: true choices: - aws + #- azure - question_name: Blueprint type: multiplechoice variable: vm_blueprint @@ -107,6 +135,7 @@ controller_templates: organization: Default credentials: - AWS + #- Azure - Workshop Credential project: Ansible official demo project playbook: cloud/destroy_vm.yml @@ -123,3 +152,4 @@ controller_templates: type: text variable: HOSTS required: true + diff --git a/collections/ansible_collections/demo/cloud/roles/azure/defaults/main.yml b/collections/ansible_collections/demo/cloud/roles/azure/defaults/main.yml index e38e0e3..085623d 100644 --- a/collections/ansible_collections/demo/cloud/roles/azure/defaults/main.yml +++ b/collections/ansible_collections/demo/cloud/roles/azure/defaults/main.yml @@ -2,8 +2,16 @@ ############## # Azure Vars ############## -az_region: +az_region: eastus az_rg_name: ansible az_rg_prefix: demo az_vnet_cidr_block: 10.0.0.0/16 -az_subnet_cidr: 10.0.1.0/24 \ No newline at end of file +az_subnet_cidr: 10.0.1.0/24 +az_vm_name: "{{ vm_name }}" +az_vm_owner: "{{ vm_owner }}" +az_blueprint: "{{ vm_blueprint }}" +az_vm_username: "{{ ansible_user }}" +az_vm_password: "{{ ansible_password }}" +az_env_tag: prod +az_purpose_tag: ansible_demo +az_ansiblegroup_tag: cloud diff --git a/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_infra.yml b/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_infra.yml index cc655e3..c7f5804 100644 --- a/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_infra.yml +++ b/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_infra.yml @@ -1,8 +1,8 @@ --- - name: AZURE | CREATE INFRA | resource group azure.azcollection.azure_rm_resourcegroup: - name: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg" - location: "{{ az_region }}" + name: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg" + location: "{{ az_region }}" - name: AZURE | CREATE INFRA | virtual network azure.azcollection.azure_rm_virtualnetwork: diff --git a/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_vm.yml b/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_vm.yml index e69de29..560bdc2 100644 --- a/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_vm.yml +++ b/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_vm.yml @@ -0,0 +1,28 @@ +--- +- name: AZURE | CREATE VM | vnet interface + azure.azcollection.azure_rm_networkinterface: + resource_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg" + name: "{{ az_vm_name }}_nic" + public_ip_name: "{{ az_vm_name }}_ip" + virtual_network: "{{ az_rg_name }}-{{ az_rg_prefix }}-vnet" + subnet: "{{ az_rg_name }}-{{ az_rg_prefix }}-subnet }}" + security_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-sec-group" + +- name: AZURE | CREATE VM | vm + azure.azcollection.azure_rm_virtualmachine: + resource_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg" + name: "{{ az_vm_name }}" + os_type: "{{ az_vm_os_type }}" + vm_size: "{{ az_vm_size }}" + admin_username: "{{ az_vm_username }}" + admin_password: "{{ az_vm_password }}" + network_interfaces: "{{ az_vm_name }}_nic" + image: "{{ az_vm_image }}" + tags: + blueprint: "{{ az_blueprint }}" + purpose: "{{ az_purpose_tag }}" + env: "{{ az_env_tag }}" + ansible_group: "{{ az_ansiblegroup_tag }}" + owner: "{{ az_vm_owner }}" + info: "This instance was built by Red Hat Product Demos" + Name: "{{ az_vm_name }}" diff --git a/collections/ansible_collections/demo/cloud/roles/azure/tasks/destroy_vm.yml b/collections/ansible_collections/demo/cloud/roles/azure/tasks/destroy_vm.yml new file mode 100644 index 0000000..9be4644 --- /dev/null +++ b/collections/ansible_collections/demo/cloud/roles/azure/tasks/destroy_vm.yml @@ -0,0 +1,8 @@ +--- +- name: Destroy VM + azure.azcollection.azure_rm_virtualmachine: + resource_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg" + name: "{{ inventory_hostname }}" + state: absent + remove_on_absent: all_autocreated + delegate_to: localhost \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/README.md b/collections/ansible_collections/demo/patching/roles/build_report_windows/README.md new file mode 100644 index 0000000..93d6df4 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows/README.md @@ -0,0 +1,36 @@ +build_report_windows +======== + +Installs Apache and creates a report based on facts from Windows services and packages modules + +Requirements +------------ + +Must run on Apache server + +Role Variables / Configuration +-------------- + +N/A + +Dependencies +------------ + +N/A + +Example Playbook +---------------- + +The role can be used to create an html report on any number of Linux hosts using any number of Windows servers about their services and packages installed + + +``` +--- +- hosts: all + + tasks: + - name: Run Windows Report + import_role: + name: shadowman.reports.build_report_windows + +``` \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/defaults/main.yml b/collections/ansible_collections/demo/patching/roles/build_report_windows/defaults/main.yml new file mode 100644 index 0000000..1154771 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows/defaults/main.yml @@ -0,0 +1,2 @@ +--- +detailedreport: True \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/example_results/Ansible Windows Automation Report.png b/collections/ansible_collections/demo/patching/roles/build_report_windows/example_results/Ansible Windows Automation Report.png new file mode 100644 index 0000000..1ead477 Binary files /dev/null and b/collections/ansible_collections/demo/patching/roles/build_report_windows/example_results/Ansible Windows Automation Report.png differ diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/files/css/new.css b/collections/ansible_collections/demo/patching/roles/build_report_windows/files/css/new.css new file mode 100644 index 0000000..f58d18f --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows/files/css/new.css @@ -0,0 +1,202 @@ +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_windows/files/redhat-ansible-logo.svg b/collections/ansible_collections/demo/patching/roles/build_report_windows/files/redhat-ansible-logo.svg new file mode 100644 index 0000000..2ecef98 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows/files/redhat-ansible-logo.svg @@ -0,0 +1,48 @@ + + + + +Logo-Red_Hat-Ansible_Automation_Platform-A-Reverse-RGB + + + + + + + + + + + diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/files/server.png b/collections/ansible_collections/demo/patching/roles/build_report_windows/files/server.png new file mode 100644 index 0000000..9ad96fc Binary files /dev/null and b/collections/ansible_collections/demo/patching/roles/build_report_windows/files/server.png differ diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/files/webpage_logo.png b/collections/ansible_collections/demo/patching/roles/build_report_windows/files/webpage_logo.png new file mode 100644 index 0000000..65b5836 Binary files /dev/null and b/collections/ansible_collections/demo/patching/roles/build_report_windows/files/webpage_logo.png differ diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/tasks/main.yml b/collections/ansible_collections/demo/patching/roles/build_report_windows/tasks/main.yml new file mode 100644 index 0000000..f349f23 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows/tasks/main.yml @@ -0,0 +1,24 @@ +- name: create HTML report + ansible.builtin.template: + src: report.j2 + dest: "{{ file_path }}/windows.html" + +- name: copy CSS over + ansible.builtin.copy: + src: "css" + dest: "{{ file_path }}" + directory_mode: true + +- name: copy logos over + ansible.builtin.copy: + src: "{{ item }}" + dest: "{{ file_path }}" + directory_mode: true + loop: + - "webpage_logo.png" + - "redhat-ansible-logo.svg" + - "server.png" + +- name: display link to inventory report + ansible.builtin.debug: + msg: "Please go to http://{{ ansible_host }}/windows.html" \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/header.j2 b/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/header.j2 new file mode 100644 index 0000000..6d504d0 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/header.j2 @@ -0,0 +1,15 @@ + + +
+
+
+ + + +
+
\ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/packages.j2 b/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/packages.j2 new file mode 100644 index 0000000..f290897 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/packages.j2 @@ -0,0 +1,29 @@ + +
+
+ + +
+
+ \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/report.j2 b/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/report.j2 new file mode 100644 index 0000000..96b5f3d --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/report.j2 @@ -0,0 +1,101 @@ + + + + Ansible Windows Automation Report + + + + + + + + + + + +
+ {% include 'header.j2' %} +
+
+

Ansible Windows Automation Report

+

+

+ + + + + + + + + +{% for windows_host in groups['tag_Windows']|sort %} + + + + + +{% endfor %} + +
Windows DeviceOperating SystemOperating System Kernel Version
+
+

+ {{ hostvars[windows_host]['inventory_hostname'].split('.')[0] }}

+
+{% if detailedreport == 'True' %} +{% include 'packages.j2' %} +{% include 'services.j2' %} +{% endif %} +
{{hostvars[windows_host]['ansible_os_family']|default("none")}}{{hostvars[windows_host]['ansible_distribution']|default("none")}}
+

Created with


+
+
+
+ + diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/services.j2 b/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/services.j2 new file mode 100644 index 0000000..b443161 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/services.j2 @@ -0,0 +1,29 @@ + +
+
+ + +
+
+ \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/vars/main.yml b/collections/ansible_collections/demo/patching/roles/build_report_windows/vars/main.yml new file mode 100644 index 0000000..f09b15e --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows/vars/main.yml @@ -0,0 +1 @@ +file_path: /var/www/html \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/README.md b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/README.md new file mode 100644 index 0000000..dec8155 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/README.md @@ -0,0 +1,36 @@ +build_report_windows_patch +======== + +Installs Apache and creates a report based on facts from Windows update job + +Requirements +------------ + +Must run on Apache server + +Role Variables / Configuration +-------------- + +N/A + +Dependencies +------------ + +N/A + +Example Playbook +---------------- + +The role can be used to create an html patching report on any number of Linux hosts using any number of Windows servers + + +``` +--- +- hosts: all + + tasks: + - name: Run Windows Patch Report + import_role: + name: shadowman.reports.build_report_windows_patch + +``` \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/defaults/main.yml b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/defaults/main.yml new file mode 100644 index 0000000..aaf5c3d --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/defaults/main.yml @@ -0,0 +1,3 @@ +EMAIL_FROM: tower@shadowman.dev +to_emails: alex@shadowman.dev,tower@shadowman.dev +EMAIL_TO: "{{ to_emails.split(',') }}" \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/example_results/Full_Report.png b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/example_results/Full_Report.png new file mode 100644 index 0000000..615a021 Binary files /dev/null and b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/example_results/Full_Report.png differ diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/files/css/main.css b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/files/css/main.css new file mode 100644 index 0000000..dfeb435 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/files/css/main.css @@ -0,0 +1,111 @@ +p.hostname { + color: #000000; + font-weight: bolder; + font-size: large; + } + + #subtable { + background: #ebebeb; + margin: 0px; + } + + #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; + } + + table { + border-collapse: separate; + background:#fff; + @include border-radius(5px); + margin:50px auto; + @include box-shadow(0px 0px 5px rgba(0,0,0,0.3)); + } + + thead { + @include border-radius(5px); + } + + thead th { + font-family: 'Patua One', monospace; + 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-family: 'Open Sans', sans-serif; + 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); + } + } + + span.highlight { + background-color: yellow; + } + + .expandclass { + color: #5f6062; + } + + .content{ + display:none; + margin: 10px; + } \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/files/webpage_logo.png b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/files/webpage_logo.png new file mode 100644 index 0000000..3d99673 Binary files /dev/null and b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/files/webpage_logo.png differ diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/tasks/main.yml b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/tasks/main.yml new file mode 100644 index 0000000..12a9a74 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/tasks/main.yml @@ -0,0 +1,38 @@ +- name: Create HTML report + ansible.builtin.template: + src: report.j2 + dest: "{{ file_path }}/windowspatch.html" + check_mode: no + +- name: Copy CSS over + ansible.builtin.copy: + src: "css" + dest: "{{ file_path }}" + directory_mode: true + check_mode: no + +- name: Copy logo over + ansible.builtin.copy: + src: "webpage_logo.png" + dest: "{{ file_path }}" + directory_mode: true + check_mode: no + +- name: Display link to Patch report + ansible.builtin.debug: + msg: "Please go to http://{{ ansible_host }}/windowspatch.html" + +- name: Send Report via E-mail + community.general.mail: + host: "{{ EMAIL_HOST }}" + username: "{{ EMAIL_USERNAME }}" + password: "{{ EMAIL_PASSWORD }}" + port: "{{ EMAIL_PORT }}" + subject: "Windows Patching Report" + body: "{{ lookup('template', 'report.j2') }}" + from: "{{ EMAIL_FROM }}" + to: "{{ EMAIL_TO }}" + subtype: html + delegate_to: localhost + become: false + check_mode: no \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/templates/report.j2 b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/templates/report.j2 new file mode 100644 index 0000000..058b0db --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/templates/report.j2 @@ -0,0 +1,115 @@ + + + + Windows Patch Report + + +
+

Ansible Windows Patching Report

+ +
+ + +
+
+ + + + + + + + + +{% for windows_host in groups['tag_Windows']|sort %} + + + + + + +{% endfor %} + +
HostnameOperating SystemRequired Updates
{{hostvars[windows_host]['inventory_hostname']}}{{hostvars[windows_host]['ansible_distribution']|default("none")}} +
    + +{% if hostvars[windows_host].patchresult.updates is defined and hostvars[windows_host].patchresult.found_update_count|int > 0 %} +{% for update in hostvars[windows_host].patchresult.updates %} +{% set updatenum = hostvars[windows_host].patchresult.updates[update] %} +
  • {{updatenum.title}}
  • +{% endfor %} +{% else %} +
  • Compliant
  • +{% endif %} +
+
+{% for host in ansible_play_hosts %} +

Created with Ansible on {{hostvars[host].ansible_date_time.iso8601}}

+{% endfor %} + + + \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/vars/main.yml b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/vars/main.yml new file mode 100644 index 0000000..f09b15e --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/vars/main.yml @@ -0,0 +1 @@ +file_path: /var/www/html \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/report_linux/tasks/main.yml b/collections/ansible_collections/demo/patching/roles/report_linux/tasks/main.yml index 158c560..fede495 100644 --- a/collections/ansible_collections/demo/patching/roles/report_linux/tasks/main.yml +++ b/collections/ansible_collections/demo/patching/roles/report_linux/tasks/main.yml @@ -24,4 +24,4 @@ - name: display link to inventory report ansible.builtin.debug: - msg: "Please go to http://{{ hostvars[report_server]['ansible_host'] }}/reports/linux.html" \ No newline at end of file + msg: "Please go to http://{{ hostvars[report_server]['ansible_host'] }}/reports/linux.html" diff --git a/collections/ansible_collections/demo/patching/roles/report_linux_patching/tasks/main.yml b/collections/ansible_collections/demo/patching/roles/report_linux_patching/tasks/main.yml index 3ecba5e..ee42bc6 100644 --- a/collections/ansible_collections/demo/patching/roles/report_linux_patching/tasks/main.yml +++ b/collections/ansible_collections/demo/patching/roles/report_linux_patching/tasks/main.yml @@ -22,6 +22,7 @@ ansible.builtin.debug: msg: "Please go to http://{{ hostvars[report_server]['ansible_host'] }}/reports/linuxpatch.html" + #- name: Send Report via E-mail # community.general.mail: # host: "{{ EMAIL_HOST }}" diff --git a/collections/requirements.yml b/collections/requirements.yml index 997c3dc..85a4c0f 100644 --- a/collections/requirements.yml +++ b/collections/requirements.yml @@ -16,6 +16,6 @@ collections: version: 1.9.0 #cloud - name: azure.azcollection - version: 1.11.0 + version: 1.13.0 - name: amazon.aws version: 3.1.1 diff --git a/docs b/docs deleted file mode 120000 index d75422d..0000000 --- a/docs +++ /dev/null @@ -1 +0,0 @@ -old-demo-repository/docs \ No newline at end of file diff --git a/images b/images deleted file mode 120000 index 3c16ad4..0000000 --- a/images +++ /dev/null @@ -1 +0,0 @@ -old-demo-repository/images \ No newline at end of file diff --git a/meta b/meta deleted file mode 120000 index a20b215..0000000 --- a/meta +++ /dev/null @@ -1 +0,0 @@ -old-demo-repository/meta \ No newline at end of file diff --git a/roles b/roles deleted file mode 120000 index 27351dc..0000000 --- a/roles +++ /dev/null @@ -1 +0,0 @@ -old-demo-repository/roles \ No newline at end of file