From ef8f3811dd4ad52e1a99e71c4eea2682d3b20c2d Mon Sep 17 00:00:00 2001 From: UNiXMIT <4117073+UNiXMIT@users.noreply.github.com> Date: Thu, 7 Mar 2024 17:06:40 +0000 Subject: [PATCH] Windows multi region --- db/main.yml | 1 + win/ed.yml | 16 ++++++++-------- win/ed50.yml | 2 +- win/ed60.yml | 2 +- win/ed70.yml | 2 +- win/es.yml | 12 ++++++------ win/extend.yml | 4 ++-- win/initial.yml | 30 ++++++++++++++++++++++++++++++ win/main.yml | 9 +++++++++ win/software.yml | 4 ++-- win/system.yml | 1 + win/variables.json | 15 +++++---------- win/vpn.yml | 4 ++-- win/vs.yml | 4 ++-- 14 files changed, 71 insertions(+), 35 deletions(-) create mode 100644 win/initial.yml diff --git a/db/main.yml b/db/main.yml index 682acdb..62e77cd 100644 --- a/db/main.yml +++ b/db/main.yml @@ -157,6 +157,7 @@ msg: - "Instance Name - {{ semaphore_vars.task_details.username|upper }}-{{ imageName }} {{ hostvars[item.public_ip_address].DBSHORT }}" - 'AWS ID - {{ item.instance_id }}' + - 'AWS Region - {{ awsRegion }}' - 'Public IP - {{ item.public_ip_address }}' - 'Public DNS - {{ item.public_dns_name }}' - 'Private IP - {{ item.private_ip_address }}' diff --git a/win/ed.yml b/win/ed.yml index 4f346db..250f7b1 100644 --- a/win/ed.yml +++ b/win/ed.yml @@ -6,7 +6,7 @@ bucket: mturner mode: geturl object: '{{ S3Prefix }}{{ installerNameEDVS }}' - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3edvs @@ -18,7 +18,7 @@ bucket: mturner mode: geturl object: '{{ S3Prefix }}{{ installerNameEDE }}' - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3ede @@ -30,7 +30,7 @@ bucket: mturner mode: geturl object: ED/Licenses/lservrc.net - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3sn @@ -42,7 +42,7 @@ bucket: mturner mode: geturl object: ED/Licenses/LicFile.txt - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3ap @@ -77,7 +77,7 @@ bucket: mturner mode: geturl object: '{{ S3PrefixPU }}{{ installerNameEDVSPU }}' - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3edvspu @@ -89,7 +89,7 @@ bucket: mturner mode: geturl object: '{{ S3PrefixPU }}{{ installerNameEDEPU }}' - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3edepu @@ -109,7 +109,7 @@ - name: Add ED Tags amazon.aws.ec2_tag: aws_profile: '{{ awsProfile }}' - region: '{{ awsRegion }}' + region: "{{ hostvars['localhost']['awsRegion'] }}" resource: '{{ item }}' tags: Name: '{{ semaphore_vars.task_details.username|upper }}-{{ imageName }} {{ productName }}' @@ -123,7 +123,7 @@ - name: Add ED PU Tags amazon.aws.ec2_tag: aws_profile: '{{ awsProfile }}' - region: '{{ awsRegion }}' + region: "{{ hostvars['localhost']['awsRegion'] }}" resource: '{{ item }}' tags: EDVSPU: '{{ installerNameEDVSPU }}' diff --git a/win/ed50.yml b/win/ed50.yml index b81846e..a230944 100644 --- a/win/ed50.yml +++ b/win/ed50.yml @@ -13,7 +13,7 @@ bucket: mturner mode: geturl object: '{{ S3Prefix }}Microsoft.VisualStudio.Setup.Configuration.Native.dll' - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3 diff --git a/win/ed60.yml b/win/ed60.yml index 7812f5d..ac2aaaa 100644 --- a/win/ed60.yml +++ b/win/ed60.yml @@ -13,7 +13,7 @@ bucket: mturner mode: geturl object: '{{ S3Prefix }}Microsoft.VisualStudio.Setup.Configuration.Native.dll' - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3 diff --git a/win/ed70.yml b/win/ed70.yml index ec5ea55..90a7347 100644 --- a/win/ed70.yml +++ b/win/ed70.yml @@ -13,7 +13,7 @@ bucket: mturner mode: geturl object: ED/70/Microsoft.VisualStudio.Setup.Configuration.Native.dll - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3 diff --git a/win/es.yml b/win/es.yml index 82a9af2..8509b29 100644 --- a/win/es.yml +++ b/win/es.yml @@ -6,7 +6,7 @@ bucket: mturner mode: geturl object: '{{ S3Prefix }}{{ installerNameES }}' - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3es @@ -18,7 +18,7 @@ bucket: mturner mode: geturl object: ED/Licenses/lservrc.net - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3sn @@ -30,7 +30,7 @@ bucket: mturner mode: geturl object: ED/Licenses/LicFile.txt - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3ap @@ -60,7 +60,7 @@ bucket: mturner mode: geturl object: '{{ S3PrefixPU }}{{ installerNameESPU }}' - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3espu @@ -75,7 +75,7 @@ - name: Add ES Tags amazon.aws.ec2_tag: aws_profile: '{{ awsProfile }}' - region: '{{ awsRegion }}' + region: "{{ hostvars['localhost']['awsRegion'] }}" resource: '{{ item }}' tags: Name: '{{ semaphore_vars.task_details.username|upper }}-{{ imageName }} {{ productName }}' @@ -88,7 +88,7 @@ - name: Add ES PU Tags amazon.aws.ec2_tag: aws_profile: '{{ awsProfile }}' - region: '{{ awsRegion }}' + region: "{{ hostvars['localhost']['awsRegion'] }}" resource: '{{ item }}' tags: ESPU: '{{ installerNameESPU }}' diff --git a/win/extend.yml b/win/extend.yml index a50f2ed..87b38b5 100644 --- a/win/extend.yml +++ b/win/extend.yml @@ -4,7 +4,7 @@ bucket: mturner mode: geturl object: '{{ S3Prefix }}{{ installerName }}' - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3 @@ -18,7 +18,7 @@ - name: Add extend Tags amazon.aws.ec2_tag: aws_profile: '{{ awsProfile }}' - region: '{{ awsRegion }}' + region: "{{ hostvars['localhost']['awsRegion'] }}" resource: '{{ item }}' tags: Name: '{{ semaphore_vars.task_details.username|upper }}-{{ imageName }} {{ productName }}' diff --git a/win/initial.yml b/win/initial.yml new file mode 100644 index 0000000..2ddf91d --- /dev/null +++ b/win/initial.yml @@ -0,0 +1,30 @@ +- name: EMEA Region + set_fact: + awsRegion: eu-west-2 + availabilityZone: us-west-2a + awsAMI: ami-0be53fc5198dbd294 + securityGroups: '{{ securityGroupsEMEA }}' + when: userRegion | default("1") == "1" + +- name: AMS Region + set_fact: + awsRegion: us-east-2 + availabilityZone: us-east-2a + awsAMI: ami-0e6aa5f69f06ffa91 + securityGroups: '{{ securityGroupsAMS }}' + when: userRegion | default("1") == "2" + +- name: APJ Region + set_fact: + awsRegion: ap-southeast-2 + availabilityZone: ap-southeast-2a + awsAMI: ami-02ed1a17d1bd5f706 + securityGroups: '{{ securityGroupsAPJ }}' + when: userRegion | default("1") == "3" + +- name: Set AWS Facts + set_fact: + instanceType: t3.xlarge + deviceName: /dev/sda1 + volumeType: gp3 + volumeSize: 120 \ No newline at end of file diff --git a/win/main.yml b/win/main.yml index dee9718..feec94b 100644 --- a/win/main.yml +++ b/win/main.yml @@ -1,3 +1,11 @@ +- name: AWS Initial Configuration + hosts: local + gather_facts: no + tasks: + - name: Import initial.yml + import_tasks: initial.yml + tags: default + - name: SSO 2FA hosts: local gather_facts: no @@ -314,6 +322,7 @@ msg: - "Instance Name - {{ semaphore_vars.task_details.username|upper }}-{{ imageName }} {{ hostvars[item.public_ip_address].productName }}" - 'AWS ID - {{ item.instance_id }}' + - 'AWS Region - {{ awsRegion }}' - 'Public IP - {{ item.public_ip_address }}' - 'Public DNS - {{ item.public_dns_name }}' - 'Private IP - {{ item.private_ip_address }}' diff --git a/win/software.yml b/win/software.yml index f0c75ce..3e7b701 100644 --- a/win/software.yml +++ b/win/software.yml @@ -118,7 +118,7 @@ bucket: mturner mode: geturl object: DB2/v11.5.9_nt32_odbc_cli.zip - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s332 @@ -130,7 +130,7 @@ bucket: mturner mode: geturl object: DB2/v11.5.9_ntx64_odbc_cli.zip - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s364 diff --git a/win/system.yml b/win/system.yml index dd06a88..58c34c9 100644 --- a/win/system.yml +++ b/win/system.yml @@ -1,6 +1,7 @@ - name: Set timezone to 'GMT Standard Time' (GMT) community.windows.win_timezone: timezone: GMT Standard Time + when: userRegion | default("1") == "1" - name: Disable Windows Firewall win_firewall: diff --git a/win/variables.json b/win/variables.json index c5e04e5..1166ef2 100644 --- a/win/variables.json +++ b/win/variables.json @@ -3,21 +3,16 @@ "myPassword": "strongPassword", "ansibleUser": "administrator", "imageName": "WINS2022", - "awsAMI": "ami-0d8e82a3d7fda95e0", "keyName": "support", "keyLocation": "~/.ssh/support.pem", - "securityGroups": "['sg-XXXXXX','sg-XXXXXX']", - "awsRegion": "eu-west-2", - "availabilityZone": "eu-west-2a", - "instanceType": "t3.xlarge", - "deviceName": "/dev/sda1", - "volumeType": "gp3", - "volumeSize": 120, + "securityGroupsEMEA": "['sg-XXXXXX','sg-XXXXXX']", + "securityGroupsAMS": "['sg-XXXXXX','sg-XXXXXX']", + "securityGroupsAPJ": "['sg-XXXXXX','sg-XXXXXX']", "awsProfile": "848105473048_Fed_COBOL2_Compute", - "vmCount": 1, + "webAPI": "https://WebAPI.com/", "ssoEmail": "email@domain.com", "ssoPassword": "strongPassword", "ssoMethod": "1", "ssoToken": "XXXXXX", - "webAPI": "https://WebAPI.com/" + "vmCount": 1 } \ No newline at end of file diff --git a/win/vpn.yml b/win/vpn.yml index 66a9489..cea8faf 100644 --- a/win/vpn.yml +++ b/win/vpn.yml @@ -4,7 +4,7 @@ bucket: mturner mode: geturl object: PulseVPN/ps-pulse-win-9.1r15.0-b15819-64bitinstaller.msi - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3 @@ -21,7 +21,7 @@ bucket: mturner mode: geturl object: PulseVPN/MFIPulseVPN.pulsepreconfig - region: '{{ awsRegion }}' + region: eu-west-2 expiry: 4000 sig_v4: true register: s3 diff --git a/win/vs.yml b/win/vs.yml index 971215f..c8fe756 100644 --- a/win/vs.yml +++ b/win/vs.yml @@ -7,7 +7,7 @@ - name: Add VS 2019 Tags amazon.aws.ec2_tag: aws_profile: '{{ awsProfile }}' - region: '{{ awsRegion }}' + region: "{{ hostvars['localhost']['awsRegion'] }}" resource: '{{ item }}' tags: VS: 'Visual Studio Professional 2019' @@ -25,7 +25,7 @@ - name: Add VS 2022 Tags amazon.aws.ec2_tag: aws_profile: '{{ awsProfile }}' - region: '{{ awsRegion }}' + region: "{{ hostvars['localhost']['awsRegion'] }}" resource: '{{ item }}' tags: VS: 'Visual Studio Professional 2022'