diff --git a/cloud/blueprints/windows_core.yml b/cloud/blueprints/windows_core.yml new file mode 100644 index 0000000..2c000f5 --- /dev/null +++ b/cloud/blueprints/windows_core.yml @@ -0,0 +1,6 @@ +--- +vm_blueprint_providers: + - aws +aws_image_filter: 'Windows_Server-2019-English-Core-Base*' +aws_instance_size: t3.medium +aws_userdata_template: aws_windows_userdata \ No newline at end of file diff --git a/cloud/blueprints/windows_full.yml b/cloud/blueprints/windows_full.yml new file mode 100644 index 0000000..92546f5 --- /dev/null +++ b/cloud/blueprints/windows_full.yml @@ -0,0 +1,6 @@ +--- +vm_blueprint_providers: + - aws +aws_image_filter: 'Windows_Server-2019-English-Full-Base*' +aws_instance_size: t3.medium +aws_userdata_template: aws_windows_userdata \ No newline at end of file diff --git a/cloud/destroy_vm.yml b/cloud/destroy_vm.yml index 0d68921..fe73c58 100644 --- a/cloud/destroy_vm.yml +++ b/cloud/destroy_vm.yml @@ -4,12 +4,16 @@ tasks: - name: list systems to be destroyed + debug: + msg: "{{ inventory_hostname }}" + + - name: pause for review... pause: seconds: 30 - prompt: "{{ inventory_hostname }} will be DESTROYED in 30 seconds. Cancel the job to Abort." + prompt: "Systems listed above will be DESTROYED in 30 seconds. Cancel the job to Abort." - name: destroy vm include_role: name: "demo.cloud.aws" tasks_from: destroy_vm - when: "'cloud_aws' in group_names or 'cloud_azure' 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 d08ddd8..85f80ef 100644 --- a/cloud/setup.yml +++ b/cloud/setup.yml @@ -16,7 +16,7 @@ controller_credentials: inputs: username: REPLACEME password: REPLACEME - + - name: Azure credential_type: Microsoft Azure Resource Manager organization: Default @@ -59,7 +59,6 @@ controller_inventory_sources: conditional_groups: cloud_azure: true - controller_templates: - name: Cloud / Create Infra job_type: run @@ -68,6 +67,7 @@ controller_templates: credentials: - AWS - Azure + project: Ansible official demo project playbook: cloud/create_infra.yml inventory: Workshop Inventory @@ -129,6 +129,30 @@ controller_templates: variable: vm_blueprint required: true choices: #"{{ lookup('fileglob', 'blueprints/*.yml') | regex_replace(',','\n') | regex_findall('.*/(.*)(?=.yml)') | list }}" - - windows + - windows_core + - windows_full - rhel8 - rhel7 + - name: Cloud / Destroy VM + job_type: run + organization: Default + credentials: + - AWS + - Azure + - Workshop Credential + project: Ansible official demo project + playbook: cloud/destroy_vm.yml + inventory: Workshop Inventory + execution_environment: Default execution environment + survey_enabled: true + extra_vars: + aws_region: us-east-2 + survey: + name: '' + description: '' + spec: + - question_name: Name or Pattern + type: text + variable: HOSTS + required: true + diff --git a/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_vm.yml b/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_vm.yml index 3e03226..9c3a781 100644 --- a/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_vm.yml +++ b/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_vm.yml @@ -22,7 +22,7 @@ - name: AWS| CREATE VM | save ami set_fact: aws_instance_ami: > - {{ amis.images | selectattr('name', 'defined') | sort(attribute='creation_date') | last }} + {{ (amis.images | selectattr('name', 'defined') | sort(attribute='creation_date'))[-2] }} - name: AWS| CREATE VM | create instance amazon.aws.ec2_instance: diff --git a/collections/ansible_collections/demo/patching/roles/patch_windows/defaults/main.yml b/collections/ansible_collections/demo/patching/roles/patch_windows/defaults/main.yml new file mode 100644 index 0000000..f8a73c3 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/patch_windows/defaults/main.yml @@ -0,0 +1,14 @@ +--- +win_update_categories: + - Application + - Connectors + - CriticalUpdates + - DefinitionUpdates + - DeveloperKits + - FeaturePacks Guidance + - SecurityUpdates + - ServicePacks + - Tools + - UpdateRollups + - Updates +allow_reboot: true \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/patch_windows/tasks/main.yml b/collections/ansible_collections/demo/patching/roles/patch_windows/tasks/main.yml new file mode 100644 index 0000000..0518c79 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/patch_windows/tasks/main.yml @@ -0,0 +1,15 @@ +--- +- name: Scan packages + demo.patching.win_scan_packages: + check_mode: no + +- name: Scan Services + demo.patching.win_scan_services: + check_mode: no + +- name: Install Windows Updates + ansible.windows.win_updates: + category_names: "{{ win_update_categories | default(omit) }}" + reboot: "{{ allow_reboot }}" + state: installed + register: patchingresult 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 71d2364..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://{{ 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 bd92a21..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 @@ -20,7 +20,8 @@ - name: Display link to Linux patch report ansible.builtin.debug: - msg: "Please go to http://{{ ansible_host }}/reports/linuxpatch.html" + msg: "Please go to http://{{ hostvars[report_server]['ansible_host'] }}/reports/linuxpatch.html" + #- name: Send Report via E-mail # community.general.mail: diff --git a/collections/ansible_collections/demo/patching/roles/report_server/tasks/apache.yml b/collections/ansible_collections/demo/patching/roles/report_server/tasks/apache.yml new file mode 100644 index 0000000..d8faec4 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_server/tasks/apache.yml @@ -0,0 +1,20 @@ +--- +- yum: + name: httpd + state: latest + check_mode: no + +- file: + path: /var/www/html/reports/ + state: directory + check_mode: no + +- copy: + dest: /var/www/html/reports/.htaccess + content: Options +Indexes + check_mode: no + +- service: + name: httpd + state: started + check_mode: no \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/report_server/tasks/iis.yml b/collections/ansible_collections/demo/patching/roles/report_server/tasks/iis.yml new file mode 100644 index 0000000..74e6ffe --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_server/tasks/iis.yml @@ -0,0 +1,23 @@ +--- +- name: Install IIS + ansible.windows.win_feature: + name: Web-Server + state: present + check_mode: no + +- name: Start IIS service + ansible.windows.win_service: + name: W3Svc + state: started + check_mode: no + +- name: Create Directory + ansible.windows.win_file: + path: C:\Inetpub\wwwroot\reports + state: directory + check_mode: no + +- name: Enable Directory Browsing + ansible.windows.win_powershell: + script: | + "Set-WebConfigurationProperty -filter /system.webServer/directoryBrowse -name enabled -value true -PSPath 'IIS:\Sites\Default Web Site\reports'" \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/report_windows/README.md b/collections/ansible_collections/demo/patching/roles/report_windows/README.md new file mode 100644 index 0000000..93d6df4 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/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/report_windows/defaults/main.yml b/collections/ansible_collections/demo/patching/roles/report_windows/defaults/main.yml new file mode 100644 index 0000000..1154771 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/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/report_windows/example_results/Ansible Windows Automation Report.png b/collections/ansible_collections/demo/patching/roles/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/report_windows/example_results/Ansible Windows Automation Report.png differ diff --git a/collections/ansible_collections/demo/patching/roles/report_windows/files/css/new.css b/collections/ansible_collections/demo/patching/roles/report_windows/files/css/new.css new file mode 100644 index 0000000..f58d18f --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/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/report_windows/files/redhat-ansible-logo.svg b/collections/ansible_collections/demo/patching/roles/report_windows/files/redhat-ansible-logo.svg new file mode 100644 index 0000000..2ecef98 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows/files/redhat-ansible-logo.svg @@ -0,0 +1,48 @@ + + + diff --git a/collections/ansible_collections/demo/patching/roles/report_windows/files/server.png b/collections/ansible_collections/demo/patching/roles/report_windows/files/server.png new file mode 100644 index 0000000..9ad96fc Binary files /dev/null and b/collections/ansible_collections/demo/patching/roles/report_windows/files/server.png differ diff --git a/collections/ansible_collections/demo/patching/roles/report_windows/files/webpage_logo.png b/collections/ansible_collections/demo/patching/roles/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/report_windows/files/webpage_logo.png differ diff --git a/collections/ansible_collections/demo/patching/roles/report_windows/tasks/main.yml b/collections/ansible_collections/demo/patching/roles/report_windows/tasks/main.yml new file mode 100644 index 0000000..c2f1479 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows/tasks/main.yml @@ -0,0 +1,28 @@ +--- +- name: create HTML report + ansible.windows.win_template: + src: report.j2 + dest: "{{ file_path }}/windows.html" + check_mode: no + +- name: copy CSS over + ansible.windows.win_copy: + src: "css" + dest: "{{ file_path }}" + directory_mode: true + check_mode: no + +- name: copy logos over + ansible.windows.win_copy: + src: "{{ item }}" + dest: "{{ file_path }}" + directory_mode: true + loop: + - "webpage_logo.png" + - "redhat-ansible-logo.svg" + - "server.png" + check_mode: no + +#- name: display link to inventory report +# ansible.builtin.debug: +# msg: "Please go to http://{{ host_vars[report_server]['ansible_host'] }}/reports/windows.html" \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/report_windows/templates/header.j2 b/collections/ansible_collections/demo/patching/roles/report_windows/templates/header.j2 new file mode 100644 index 0000000..6d504d0 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows/templates/header.j2 @@ -0,0 +1,15 @@ + + +
| Windows Device | +Operating System | +Operating System Kernel Version | +
|---|---|---|
|
+
+
+{% 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
+| Hostname | +Operating System | +Required Updates | +
|---|---|---|
| {{hostvars[windows_host]['inventory_hostname']}} | +{{hostvars[windows_host]['ansible_distribution']|default("none")}} | +
+
|
+
+
Created with Ansible on {{hostvars[inventory_hostname].ansible_date_time.iso8601}}