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 @@ + + + + +Logo-Red_Hat-Ansible_Automation_Platform-A-Reverse-RGB + + + + + + + + + + + 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 @@ + + +
+
+
+ + + +
+
\ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/report_windows/templates/packages.j2 b/collections/ansible_collections/demo/patching/roles/report_windows/templates/packages.j2 new file mode 100644 index 0000000..f290897 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows/templates/packages.j2 @@ -0,0 +1,29 @@ + +
+
+ + +
+
+ \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/report_windows/templates/report.j2 b/collections/ansible_collections/demo/patching/roles/report_windows/templates/report.j2 new file mode 100644 index 0000000..7b9ada5 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows/templates/report.j2 @@ -0,0 +1,101 @@ + + + + Ansible Windows Automation Report + + + + + + + + + + + +
+ {% include 'header.j2' %} +
+
+

Ansible Windows Automation Report

+

+

+ + + + + + + + + +{% for windows_host in ansible_play_hosts |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/report_windows/templates/services.j2 b/collections/ansible_collections/demo/patching/roles/report_windows/templates/services.j2 new file mode 100644 index 0000000..b443161 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows/templates/services.j2 @@ -0,0 +1,29 @@ + +
+
+ + +
+
+ \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/report_windows/vars/main.yml b/collections/ansible_collections/demo/patching/roles/report_windows/vars/main.yml new file mode 100644 index 0000000..3ec787e --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows/vars/main.yml @@ -0,0 +1 @@ +file_path: C:\Inetpub\wwwroot\reports \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/report_windows_patching/README.md b/collections/ansible_collections/demo/patching/roles/report_windows_patching/README.md new file mode 100644 index 0000000..dec8155 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows_patching/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/report_windows_patching/defaults/main.yml b/collections/ansible_collections/demo/patching/roles/report_windows_patching/defaults/main.yml new file mode 100644 index 0000000..aaf5c3d --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows_patching/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/report_windows_patching/example_results/Full_Report.png b/collections/ansible_collections/demo/patching/roles/report_windows_patching/example_results/Full_Report.png new file mode 100644 index 0000000..615a021 Binary files /dev/null and b/collections/ansible_collections/demo/patching/roles/report_windows_patching/example_results/Full_Report.png differ diff --git a/collections/ansible_collections/demo/patching/roles/report_windows_patching/files/css/main.css b/collections/ansible_collections/demo/patching/roles/report_windows_patching/files/css/main.css new file mode 100644 index 0000000..dfeb435 --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows_patching/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/report_windows_patching/files/webpage_logo.png b/collections/ansible_collections/demo/patching/roles/report_windows_patching/files/webpage_logo.png new file mode 100644 index 0000000..3d99673 Binary files /dev/null and b/collections/ansible_collections/demo/patching/roles/report_windows_patching/files/webpage_logo.png differ diff --git a/collections/ansible_collections/demo/patching/roles/report_windows_patching/tasks/main.yml b/collections/ansible_collections/demo/patching/roles/report_windows_patching/tasks/main.yml new file mode 100644 index 0000000..83b014c --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows_patching/tasks/main.yml @@ -0,0 +1,23 @@ +- name: Create HTML report + ansible.windows.win_template: + src: report.j2 + dest: "{{ file_path }}/windowspatch.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 logo over + ansible.windows.win_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://{{ hostvars[report_server]['ansible_host'] }}/reports/windowspatch.html" \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/report_windows_patching/templates/report.j2 b/collections/ansible_collections/demo/patching/roles/report_windows_patching/templates/report.j2 new file mode 100644 index 0000000..3da03ec --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows_patching/templates/report.j2 @@ -0,0 +1,113 @@ + + + + Windows Patch Report + + +
+

Ansible Windows Patching Report

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

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

+ + + \ No newline at end of file diff --git a/collections/ansible_collections/demo/patching/roles/report_windows_patching/vars/main.yml b/collections/ansible_collections/demo/patching/roles/report_windows_patching/vars/main.yml new file mode 100644 index 0000000..3ec787e --- /dev/null +++ b/collections/ansible_collections/demo/patching/roles/report_windows_patching/vars/main.yml @@ -0,0 +1 @@ +file_path: C:\Inetpub\wwwroot\reports \ No newline at end of file diff --git a/collections/requirements.yml b/collections/requirements.yml index 44453ee..85a4c0f 100644 --- a/collections/requirements.yml +++ b/collections/requirements.yml @@ -12,6 +12,8 @@ collections: #windows - chocolatey.chocolatey - community.windows + - name: ansible.windows + version: 1.9.0 #cloud - name: azure.azcollection version: 1.13.0 diff --git a/linux/inventory.insights.yml b/linux/inventory.insights.yml index 466bb63..e9a1ebd 100644 --- a/linux/inventory.insights.yml +++ b/linux/inventory.insights.yml @@ -6,6 +6,7 @@ groups: patch_enhancements: insights_patching.rhea_count > 0 patch_security: insights_patching.rhsa_count > 0 get_tags: yes +selection: none filter_tags: - insights-client/purpose=demo keyed_groups: diff --git a/windows/active_directory/create_ad_domain.yml b/windows/active_directory/create_ad_domain.yml index 36ec940..00ee7d2 100644 --- a/windows/active_directory/create_ad_domain.yml +++ b/windows/active_directory/create_ad_domain.yml @@ -1,6 +1,7 @@ --- - name: Create Active Directory domain hosts: "{{ HOSTS | default('windows') }}" + gather_facts: false tasks: - name: Create new domain in a new forest on the target host @@ -14,6 +15,14 @@ reboot_timeout: 3600 when: new_forest.reboot_required + - name: Wait up to 10min for AD web services to start + community.windows.win_wait_for_process: + process_name_exact: Microsoft.ActiveDirectory.WebServices + pre_wait_delay: 60 + state: present + timeout: 600 + sleep: 10 + - name: Create some groups community.windows.win_domain_group: name: "{{ item.name }}" @@ -28,6 +37,7 @@ name: "{{ item.name }}" groups: "{{ item.groups }}" password: "{{ lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1) }}" + update_password: on_create loop: - { name: "UserA", groups: "GroupA" } - { name: "UserB", groups: "GroupB" } diff --git a/windows/active_directory/helpdesk_new_user_portal.yml b/windows/active_directory/helpdesk_new_user_portal.yml index 58b1e52..a9d61ba 100644 --- a/windows/active_directory/helpdesk_new_user_portal.yml +++ b/windows/active_directory/helpdesk_new_user_portal.yml @@ -1,6 +1,7 @@ --- - name: Helpdesk new user portal hosts: "{{ HOSTS | default('windows') }}" + gather_facts: false tasks: - name: Setting host facts using complex arguments @@ -20,13 +21,13 @@ groups: - "GroupA" - "GroupB" - street: 123 4th St. - city: Sometown + street: "{{ street }}" + city: "{{ city }}" state_province: IN - postal_code: 12345 + postal_code: "{{ postal_code }}" country: US attributes: - telephoneNumber: 555-123456 + telephoneNumber: "{{ telephone_number }}" register: new_user - name: Display User diff --git a/windows/patching.yml b/windows/patching.yml new file mode 100644 index 0000000..dbab74c --- /dev/null +++ b/windows/patching.yml @@ -0,0 +1,22 @@ +--- +- name: Windows updates + hosts: "{{ HOSTS | default('os_windows') }}" + vars: + report_server: win1 + + tasks: + - include_role: + name: demo.patching.patch_windows + + - block: + - include_role: + name: demo.patching.report_server + tasks_from: iis + + - include_role: + name: demo.patching.report_windows + + - include_role: + name: demo.patching.report_windows_patching + delegate_to: "{{ report_server }}" + run_once: yes \ No newline at end of file diff --git a/windows/powershell_dsc.yml b/windows/powershell_dsc.yml new file mode 100644 index 0000000..7db3657 --- /dev/null +++ b/windows/powershell_dsc.yml @@ -0,0 +1,41 @@ +--- +- name: PowerShell DSC + hosts: "{{ HOSTS | default('windows') }}" + gather_facts: false + + tasks: + - name: Setup the SecurityPolicyDSC module + community.windows.win_psmodule: + name: SecurityPolicyDSC + module_version: 2.10.0.0 + state: present + + - name: Set password history + ansible.windows.win_dsc: + resource_name: AccountPolicy + Name: Enforce_password_history + Enforce_password_history: 24 + + - name: Set maximum password age + ansible.windows.win_dsc: + resource_name: AccountPolicy + Name: Maximum_Password_Age + Maximum_Password_Age: 60 + + - name: Set minimum password age + ansible.windows.win_dsc: + resource_name: AccountPolicy + Name: Minimum_Password_Age + Maximum_Password_Age: 20 + + - name: Set minimum password length + ansible.windows.win_dsc: + resource_name: AccountPolicy + Name: Minimum_Password_Length + Maximum_Password_Age: 8 + + - name: Set password complexity requirements + ansible.windows.win_dsc: + resource_name: AccountPolicy + Name: Password_must_meet_complexity_requirements + Password_must_meet_complexity_requirements: Enabled diff --git a/windows/setup.yml b/windows/setup.yml index 64508b5..7cb235b 100644 --- a/windows/setup.yml +++ b/windows/setup.yml @@ -7,7 +7,7 @@ controller_components: - credential_types - credentials - job_templates - - workflow_job_templates + #- workflow_job_templates controller_projects: - name: Fact Scan @@ -74,11 +74,13 @@ controller_templates: variable: iis_message required: true - - name: "WINDOWS / Windows updates" - job_type: run + - name: "WINDOWS / Patching" + use_fact_cache: true + job_type: check + ask_job_type_on_launch: yes inventory: "Workshop Inventory" project: "Ansible official demo project" - playbook: "windows/windows_updates.yml" + playbook: "windows/patching.yml" execution_environment: Default execution environment credentials: - "Workshop Credential" @@ -92,8 +94,8 @@ controller_templates: variable: HOSTS required: false - question_name: Update categories - type: multiplechoice - variable: categories + type: multiselect + variable: win_update_categories required: false default: SecurityUpdates choices: @@ -110,7 +112,7 @@ controller_templates: - Updates - question_name: Reboot after install? type: multiplechoice - variable: reboot_server + variable: allow_reboot required: false default: 'Yes' choices: @@ -205,6 +207,24 @@ controller_templates: - 'Running' - 'Stopped' + - name: "WINDOWS / PowerShell DSC configuring password requirements" + job_type: run + inventory: "Workshop Inventory" + project: "Ansible official demo project" + playbook: "windows/powershell_dsc.yml" + execution_environment: Default execution environment + credentials: + - "Workshop Credential" + survey_enabled: true + survey: + name: '' + description: '' + spec: + - question_name: Server Name or Pattern + type: text + variable: HOSTS + required: false + - name: "ACTIVE DIRECTORY / Create Active Directory domain" job_type: run inventory: "Workshop Inventory" @@ -244,6 +264,26 @@ controller_templates: type: text variable: surname required: true + - question_name: Street + type: text + variable: street + default: 123 4th St. + required: false + - question_name: City + type: text + variable: city + default: Sometown + required: false + - question_name: Postal code + type: text + variable: postal_code + default: IN + required: false + - question_name: Telephone number + type: text + variable: telephone_number + default: 555-123456 + required: false - name: "Rollback" job_type: run diff --git a/windows/windows_updates.yml b/windows/windows_updates.yml deleted file mode 100644 index ac97e3e..0000000 --- a/windows/windows_updates.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: Windows updates - hosts: "{{ HOSTS | default('windows') }}" - - tasks: - - name: Install Windows Updates - win_updates: - category_names: "{{ categories | default(omit) }}" - reboot: '{{ reboot_server | default(yes) }}'