diff --git a/cloud/blueprints/windows.yml b/cloud/blueprints/windows_core.yml similarity index 100% rename from cloud/blueprints/windows.yml rename to cloud/blueprints/windows_core.yml 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/collections/ansible_collections/demo/cloud/README.md b/cloud/collections/ansible_collections/demo/cloud/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/cloud/collections/ansible_collections/demo/cloud/roles/aws/defaults/main.yml b/cloud/collections/ansible_collections/demo/cloud/roles/aws/defaults/main.yml deleted file mode 100644 index 2ba3f9e..0000000 --- a/cloud/collections/ansible_collections/demo/cloud/roles/aws/defaults/main.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -####### -# AWS VARS -####### -aws_vpc_name: ansible -aws_vpc_prefix: demo -aws_vpc_cidr_block: 10.0.0.0/16 -aws_subnet_cidr: 10.0.1.0/24 -aws_region: us-east-1 -aws_vm_name: "{{ vm_name }}" -aws_vm_owner: "{{ vm_owner }}" -aws_blueprint: "{{ vm_blueprint }}" -aws_image_filter: "{{ omit }}" -aws_image_size: "{{ omit }}" -aws_image_architecture: "{{ omit }}" -aws_image_owners: "{{ omit }} " -aws_userdata_template: default -aws_keypair_name: "{{ aws_vpc_name }}-{{ aws_vpc_prefix }}-demo-key" -aws_securitygroup_name: "{{ aws_vpc_name }}-{{ aws_vpc_prefix }}-sec-group" -aws_env_tag: prod -aws_purpose_tag: ansible_demo -aws_ansiblegroup_tag: cloud -aws_ec2_wait: true - diff --git a/cloud/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_infra.yml b/cloud/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_infra.yml deleted file mode 100644 index 510aed5..0000000 --- a/cloud/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_infra.yml +++ /dev/null @@ -1,118 +0,0 @@ ---- -- name: AWS | CREATE INFRA | vpc - amazon.aws.ec2_vpc_net: - state: present - name: "{{ aws_vpc_name }}-{{ aws_vpc_prefix }}-vpc" - cidr_block: "{{ aws_vpc_cidr_block }}" - tenancy: default - region: "{{ aws_region }}" - tags: - owner: "{{ aws_vpc_name }}" - purpose: "{{ aws_purpose_tag }}" - register: aws_vpc - -- name: AWS | CREATE INFRA | internet gateway - amazon.aws.ec2_vpc_igw: - state: present - vpc_id: "{{ aws_vpc.vpc.id }}" - region: "{{ aws_region }}" - tags: - Name: "{{ aws_vpc_name }}-{{aws_vpc_prefix }}-vpc-igw" - owner: "{{ aws_vpc_name }}" - purpose: "{{ aws_purpose_tag }}" - register: aws_gateway - -- name: Create security group internal - amazon.aws.ec2_group: - state: present - name: "{{ aws_vpc_name }}-{{aws_vpc_prefix }}-sec-group" - region: "{{ aws_region }}" - description: Inbound WinRM and RDP, http for demo servers and internal AD ports - rules: - - proto: tcp - ports: - - 80 # HTTP - - 443 # HTTPS - - 22 # SSH - - 5986 # WinRM - - 3389 # RDP - cidr_ip: 0.0.0.0/0 - - proto: icmp - to_port: -1 - from_port: -1 - cidr_ip: 0.0.0.0/0 - - proto: tcp - ports: - - 80 # HTTP - - 5986 # WinRM - - 3389 # RDP - - 53 # DNS - - 88 # Kerberos Authentication - - 135 # RPC - - 139 # Netlogon - - 389 # LDAP - - 445 # SMB - - 464 # Kerberos Authentication - - 5432 # PostgreSQL - - 636 # LDAPS (LDAP over TLS) - - 873 # Rsync - - 3268-3269 # Global Catalog - - 1024-65535 # Ephemeral RPC ports - cidr_ip: 10.0.0.0/16 - - proto: udp - ports: - - 53 # DNS - - 88 # Kerberos Authentication - - 123 # NTP - - 137-138 # Netlogon - - 389 # LDAP - - 445 # SMB - - 464 # Kerberos Authentication - - 1024-65535 # Ephemeral RPC ports - cidr_ip: 10.0.0.0/16 - rules_egress: - - proto: -1 - cidr_ip: 0.0.0.0/0 - vpc_id: "{{ aws_vpc.vpc.id }}" - tags: - Name: "{{ aws_vpc_name }}-{{aws_vpc_prefix }}-sec-group" - owner: "{{ aws_vpc_name }}" - purpose: "{{ aws_purpose_tag }}" - -- name: Create a subnet on the VPC - amazon.aws.ec2_vpc_subnet: - state: present - vpc_id: "{{ aws_vpc.vpc.id }}" - cidr: "{{ aws_subnet_cidr }}" - region: "{{ aws_region }}" - map_public: yes - tags: - Name: "{{ aws_vpc_name }}-{{aws_vpc_prefix }}-subnet" - owner: "{{ aws_vpc_name }}" - purpose: "{{ aws_purpose_tag }}" - register: aws_subnet - -- name: Create a subnet route table - amazon.aws.ec2_vpc_route_table: - state: present - vpc_id: "{{ aws_vpc.vpc.id }}" - region: "{{ aws_region }}" - subnets: - - "{{ aws_subnet.subnet.id }}" - routes: - - dest: 0.0.0.0/0 - gateway_id: "{{ aws_gateway.gateway_id }}" - tags: - Name: "{{ aws_vpc_name }}-{{aws_vpc_prefix }}-vpc-rtbl" - owner: "{{ aws_vpc_name }}" - purpose: "{{ aws_purpose_tag }}" - -- name: Create AWS keypair - amazon.aws.ec2_key: - name: "{{ aws_vpc_name }}-{{aws_vpc_prefix }}-demo-key" - region: "{{ aws_region }}" - key_material: "{{ aws_public_key }}" - state: present - tags: - owner: "{{ aws_vpc_name }}" - purpose: "{{ aws_purpose_tag }}" \ No newline at end of file diff --git a/cloud/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_vm.yml b/cloud/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_vm.yml deleted file mode 100644 index 2be6bc4..0000000 --- a/cloud/collections/ansible_collections/demo/cloud/roles/aws/tasks/create_vm.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- name: AWS | CREATE VM | get subnet info - amazon.aws.ec2_vpc_subnet_info: - region: "{{ aws_region }}" - filters: - "tag:Name": "{{ aws_vpc_name }}-{{ aws_vpc_prefix }}-subnet" - register: aws_subnet - -- name: AWS | CREATE VM | save subnet id - set_fact: - aws_subnet_id: "{{ aws_subnet.subnets|map(attribute='id')| list | last }}" - -- name: AWS| CREATE VM | find ami - amazon.aws.ec2_ami_info: - region: "{{ aws_region }}" - owners: "{{ aws_image_owners }}" - filters: - name: "{{ aws_image_filter }}" - architecture: "{{ aws_image_architecture }}" - register: amis - -- name: AWS| CREATE VM | save ami - set_fact: - aws_instance_ami: > - {{ amis.images | selectattr('name', 'defined') | sort(attribute='creation_date') | last }} - -- name: AWS| CREATE VM | create instance - amazon.aws.ec2_instance: - network: - assign_public_ip: yes - key_name: "{{ aws_keypair_name }}" - instance_type: "{{ aws_instance_size }}" - image_id: "{{ aws_instance_ami.image_id }}" - region: "{{ aws_region }}" - security_group: "{{ aws_securitygroup_name }}" - tags: - blueprint: "{{ aws_blueprint }}" - purpose: "{{ aws_purpose_tag }}" - env: "{{ aws_env_tag }}" - ansible_group: "{{ aws_ansiblegroup_tag }}" - owner: "{{ aws_vm_owner }}" - info: "This instance was built by Red Hat Product Demos" - Name: "{{ aws_vm_name }}" - wait: "{{ aws_ec2_wait }}" - vpc_subnet_id: "{{ aws_subnet_id }}" - user_data: "{{ lookup('template', aws_userdata_template+'.j2', template_vars=dict(aws_vm_name=vm_name)) }}" - register: aws_vm_output \ No newline at end of file diff --git a/cloud/collections/ansible_collections/demo/cloud/roles/aws/templates/aws_windows_userdata.j2 b/cloud/collections/ansible_collections/demo/cloud/roles/aws/templates/aws_windows_userdata.j2 deleted file mode 100644 index c4671f2..0000000 --- a/cloud/collections/ansible_collections/demo/cloud/roles/aws/templates/aws_windows_userdata.j2 +++ /dev/null @@ -1,29 +0,0 @@ - -# Disable .Net Optimization Service -Get-ScheduledTask *ngen* | Disable-ScheduledTask - -# Disable Windows Auto Updates -# https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/troubleshooting-windows-instances.html#high-cpu-issue -reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v AUOptions /t REG_DWORD /d 1 /f -net stop wuauserv -net start wuauserv - -# Remove policies stopping us from enabling WinRM -reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WinRM\Service" /v AllowBasic /f -reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WinRM\Service" /v AllowUnencryptedTraffic /f -reg delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WinRM\Service" /v DisableRunAs /f - -# Disable Windows Defender Monitoring -Set-MpPreference -DisableRealtimeMonitoring $true - -# Enable WinRM -Invoke-WebRequest -Uri https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile C:\ConfigureRemotingForAnsible.ps1 -C:\ConfigureRemotingForAnsible.ps1 -ForceNewSSLCert -EnableCredSSP - -# add ec2-user -$Password = ConvertTo-SecureString {{ ansible_password }} -AsPlainText -Force -New-LocalUser -Name "ec2-user" -Description "Ansible Service Account" -Password $Password -Add-LocalGroupMember -Group "Administrators" -Member "ec2-user" - -Rename-Computer -NewName {{ aws_vm_name }} -Force -Restart - \ No newline at end of file diff --git a/cloud/collections/ansible_collections/demo/cloud/roles/aws/templates/default.j2 b/cloud/collections/ansible_collections/demo/cloud/roles/aws/templates/default.j2 deleted file mode 100644 index e69de29..0000000 diff --git a/cloud/collections/ansible_collections/demo/cloud/roles/azure/defaults/main.yml b/cloud/collections/ansible_collections/demo/cloud/roles/azure/defaults/main.yml deleted file mode 100644 index e38e0e3..0000000 --- a/cloud/collections/ansible_collections/demo/cloud/roles/azure/defaults/main.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -############## -# Azure Vars -############## -az_region: -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 diff --git a/cloud/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_infra.yml b/cloud/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_infra.yml deleted file mode 100644 index cc655e3..0000000 --- a/cloud/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_infra.yml +++ /dev/null @@ -1,76 +0,0 @@ ---- -- name: AZURE | CREATE INFRA | resource group - azure.azcollection.azure_rm_resourcegroup: - name: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg" - location: "{{ az_region }}" - -- name: AZURE | CREATE INFRA | virtual network - azure.azcollection.azure_rm_virtualnetwork: - resource_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg" - name: "{{ az_rg_name }}-{{ az_rg_prefix }}-vnet" - address_prefixes: "{{ az_vnet_cidr }}" - -- name: AZURE | CREATE INFRA | subnet - azure.azcollection.azure_rm_subnet: - resource_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg" - name: "{{ az_rg_name }}-{{ az_rg_prefix }}-subnet }}" - address_prefix: "{{ az_subnet_cidr }}" - virtual_network: "{{ az_rg_name }}-{{ az_rg_prefix }}-vnet" - -- name: AZURE | CREATE INFRA | security group - azure.azcollection.azure_rm_securitygroup: - resource_group: "{{ az_rg_name }}-{{ az_rg_prefix }}-rg" - name: "{{ az_rg_name }}-{{ az_rg_prefix }}-sec-group" - rules: - - name: External - protocol: Tcp - destination_port_range: - - 80 # HTTP - - 443 # HTTPS - - 5986 # WinRM - - 3389 # RDP - access: Allow - priority: 1001 - direction: Inbound - - name: Ping - protocol: Icmp - access: Allow - priority: 1002 - direction: Inbound - - name: Internal TCP - protocol: Tcp - destination_port_range: - - 80 # HTTP - - 5986 # WinRM - - 3389 # RDP - - 53 # DNS - - 88 # Kerberos Authentication - - 135 # RPC - - 139 # Netlogon - - 389 # LDAP - - 445 # SMB - - 464 # Kerberos Authentication - - 5432 # PostgreSQL - - 636 # LDAPS (LDAP over TLS) - - 873 # Rsync - - 3268-3269 # Global Catalog - - 1024-65535 # Ephemeral RPC ports - access: Allow - priority: 1003 - direction: Inbound - source_address_prefix: "{{ az_vnet_cidr_block }}" - - name: Internal UDP - protocol: Udp - destination_port_range: - - 53 # DNS - - 88 # Kerberos Authentication - - 123 # NTP - - 137-138 # Netlogon - - 389 # LDAP - - 445 # SMB - - 464 # Kerberos Authentication - - 1024-65535 # Ephemeral RPC ports - access: Allow - priority: 1004 - direction: Inbound - source_address_prefix: "{{ az_vnet_cidr_block }}" \ No newline at end of file diff --git a/cloud/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_vm.yml b/cloud/collections/ansible_collections/demo/cloud/roles/azure/tasks/create_vm.yml deleted file mode 100644 index e69de29..0000000 diff --git a/cloud/destroy_vm.yml b/cloud/destroy_vm.yml index 183b221..1c7c3e2 100644 --- a/cloud/destroy_vm.yml +++ b/cloud/destroy_vm.yml @@ -4,9 +4,13 @@ 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: diff --git a/cloud/setup.yml b/cloud/setup.yml index 1d80515..32aa69d 100644 --- a/cloud/setup.yml +++ b/cloud/setup.yml @@ -98,6 +98,28 @@ 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 + - 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/build_report_windows/vars/main.yml b/collections/ansible_collections/demo/patching/roles/build_report_windows/vars/main.yml deleted file mode 100644 index f09b15e..0000000 --- a/collections/ansible_collections/demo/patching/roles/build_report_windows/vars/main.yml +++ /dev/null @@ -1 +0,0 @@ -file_path: /var/www/html \ No newline at end of file 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 deleted file mode 100644 index 12a9a74..0000000 --- a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/tasks/main.yml +++ /dev/null @@ -1,38 +0,0 @@ -- 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/vars/main.yml b/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/vars/main.yml deleted file mode 100644 index f09b15e..0000000 --- a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/vars/main.yml +++ /dev/null @@ -1 +0,0 @@ -file_path: /var/www/html \ No newline at end of file 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..158c560 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" \ No newline at end of file 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..3ecba5e 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,7 @@ - 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/build_report_windows/README.md b/collections/ansible_collections/demo/patching/roles/report_windows/README.md similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/README.md rename to collections/ansible_collections/demo/patching/roles/report_windows/README.md diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/defaults/main.yml b/collections/ansible_collections/demo/patching/roles/report_windows/defaults/main.yml similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/defaults/main.yml rename to collections/ansible_collections/demo/patching/roles/report_windows/defaults/main.yml 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/report_windows/example_results/Ansible Windows Automation Report.png similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/example_results/Ansible Windows Automation Report.png rename to collections/ansible_collections/demo/patching/roles/report_windows/example_results/Ansible Windows Automation Report.png diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/files/css/new.css b/collections/ansible_collections/demo/patching/roles/report_windows/files/css/new.css similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/files/css/new.css rename to collections/ansible_collections/demo/patching/roles/report_windows/files/css/new.css diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/files/redhat-ansible-logo.svg b/collections/ansible_collections/demo/patching/roles/report_windows/files/redhat-ansible-logo.svg similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/files/redhat-ansible-logo.svg rename to collections/ansible_collections/demo/patching/roles/report_windows/files/redhat-ansible-logo.svg diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/files/server.png b/collections/ansible_collections/demo/patching/roles/report_windows/files/server.png similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/files/server.png rename to collections/ansible_collections/demo/patching/roles/report_windows/files/server.png diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/files/webpage_logo.png b/collections/ansible_collections/demo/patching/roles/report_windows/files/webpage_logo.png similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/files/webpage_logo.png rename to collections/ansible_collections/demo/patching/roles/report_windows/files/webpage_logo.png diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/tasks/main.yml b/collections/ansible_collections/demo/patching/roles/report_windows/tasks/main.yml similarity index 54% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/tasks/main.yml rename to collections/ansible_collections/demo/patching/roles/report_windows/tasks/main.yml index f349f23..c2f1479 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_windows/tasks/main.yml +++ b/collections/ansible_collections/demo/patching/roles/report_windows/tasks/main.yml @@ -1,16 +1,19 @@ +--- - name: create HTML report - ansible.builtin.template: + ansible.windows.win_template: src: report.j2 dest: "{{ file_path }}/windows.html" + check_mode: no - name: copy CSS over - ansible.builtin.copy: + ansible.windows.win_copy: src: "css" dest: "{{ file_path }}" directory_mode: true + check_mode: no - name: copy logos over - ansible.builtin.copy: + ansible.windows.win_copy: src: "{{ item }}" dest: "{{ file_path }}" directory_mode: true @@ -18,7 +21,8 @@ - "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://{{ ansible_host }}/windows.html" \ No newline at end of file +#- 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/build_report_windows/templates/header.j2 b/collections/ansible_collections/demo/patching/roles/report_windows/templates/header.j2 similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/templates/header.j2 rename to collections/ansible_collections/demo/patching/roles/report_windows/templates/header.j2 diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/packages.j2 b/collections/ansible_collections/demo/patching/roles/report_windows/templates/packages.j2 similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/templates/packages.j2 rename to collections/ansible_collections/demo/patching/roles/report_windows/templates/packages.j2 diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/report.j2 b/collections/ansible_collections/demo/patching/roles/report_windows/templates/report.j2 similarity index 98% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/templates/report.j2 rename to collections/ansible_collections/demo/patching/roles/report_windows/templates/report.j2 index 96b5f3d..7b9ada5 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/report.j2 +++ b/collections/ansible_collections/demo/patching/roles/report_windows/templates/report.j2 @@ -75,7 +75,7 @@ collapsible: true -{% for windows_host in groups['tag_Windows']|sort %} +{% for windows_host in ansible_play_hosts |sort %}
diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows/templates/services.j2 b/collections/ansible_collections/demo/patching/roles/report_windows/templates/services.j2 similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows/templates/services.j2 rename to collections/ansible_collections/demo/patching/roles/report_windows/templates/services.j2 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/build_report_windows_patch/README.md b/collections/ansible_collections/demo/patching/roles/report_windows_patching/README.md similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows_patch/README.md rename to collections/ansible_collections/demo/patching/roles/report_windows_patching/README.md diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/defaults/main.yml b/collections/ansible_collections/demo/patching/roles/report_windows_patching/defaults/main.yml similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows_patch/defaults/main.yml rename to collections/ansible_collections/demo/patching/roles/report_windows_patching/defaults/main.yml 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/report_windows_patching/example_results/Full_Report.png similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows_patch/example_results/Full_Report.png rename to collections/ansible_collections/demo/patching/roles/report_windows_patching/example_results/Full_Report.png diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/files/css/main.css b/collections/ansible_collections/demo/patching/roles/report_windows_patching/files/css/main.css similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows_patch/files/css/main.css rename to collections/ansible_collections/demo/patching/roles/report_windows_patching/files/css/main.css diff --git a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/files/webpage_logo.png b/collections/ansible_collections/demo/patching/roles/report_windows_patching/files/webpage_logo.png similarity index 100% rename from collections/ansible_collections/demo/patching/roles/build_report_windows_patch/files/webpage_logo.png rename to collections/ansible_collections/demo/patching/roles/report_windows_patching/files/webpage_logo.png 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/build_report_windows_patch/templates/report.j2 b/collections/ansible_collections/demo/patching/roles/report_windows_patching/templates/report.j2 similarity index 85% rename from collections/ansible_collections/demo/patching/roles/build_report_windows_patch/templates/report.j2 rename to collections/ansible_collections/demo/patching/roles/report_windows_patching/templates/report.j2 index 058b0db..3da03ec 100644 --- a/collections/ansible_collections/demo/patching/roles/build_report_windows_patch/templates/report.j2 +++ b/collections/ansible_collections/demo/patching/roles/report_windows_patching/templates/report.j2 @@ -27,16 +27,16 @@ -{% for windows_host in groups['tag_Windows']|sort %} +{% for windows_host in ansible_play_hosts |sort %} {{hostvars[windows_host]['inventory_hostname']}} {{hostvars[windows_host]['ansible_distribution']|default("none")}}