Create all common VMs in 1 loop

This commit is contained in:
abrown38 committed 2024-06-17 10:56:50 +01:00
1 parent 9be0203d35
commit 18ca147d07
2 files changed
+4 -50

No files matched your search

+3 -48
View File
@@ -234,7 +234,7 @@
- name: Common VMs
block:
- name: Create Common VMs (DCs, Fileservers, WSUS, Chocolatey)
- name: Create Common VMs
tags: teardown
os_server:
name: "{{ item.name }}"
@@ -261,7 +261,7 @@
$admin = [adsi]("WinNT://./Administrator, user")
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible-documentation/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))
loop: "{{ standard_vms1 }}"
loop: "{{ standard_vms }}"
async: 900
poll: 0
@@ -273,52 +273,7 @@
type: server
vm_state: active
register: common_status
until: 'common_status.servers|length == 3'
retries: 100
delay: 60
- name: Common VMs
block:
- name: Create Common VMs (DCs, Fileservers, WSUS, Chocolatey)
tags: teardown
os_server:
name: "{{ item.name }}"
state: "{{ state }}"
image: "{{ vm_image }}"
flavor: 3661211f-673a-4777-8857-fd243d6c407d
timeout: 3600
boot_from_volume: true
volume_size: 40
terminate_volume: yes
security_groups:
- domain_member
- "{{ item.security_group }}"
network: "{{ os_network }}"
metadata:
name: "{{ item.meta_name }}"
win_project: "{{ win_project }}"
type: server
variant: "{{ item.security_group }}" # just happens to match maybe change???
os: windows
userdata: |
#ps1
Rename-Computer "{{ win_project }}-{{ item.meta_name }}"
$admin = [adsi]("WinNT://./Administrator, user")
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/ansible/ansible-documentation/devel/examples/scripts/ConfigureRemotingForAnsible.ps1'))
loop: "{{ standard_vms2 }}"
async: 900
poll: 0
- name: Wait for common VMs to build
os_server_info:
name: "{{ os_project }}-{{ win_project }}-*"
filters:
metadata:
type: server
vm_state: active
register: common_status2
until: 'common_status2.servers|length == 6'
until: 'common_status.servers|length == 6'
retries: 100
delay: 60
+1 -2
View File
@@ -17,11 +17,10 @@ gpu_flavor: 3661211f-673a-4777-8857-fd243d6c407d # CHANGE THIS
filetransfer_user: file-transfer
standard_vms1:
standard_vms:
- { name: "{{ os_project }}-{{ win_project }}-dc01", security_group: "domain_controller", meta_name: dc01 }
- { name: "{{ os_project }}-{{ win_project }}-dc02", security_group: "domain_controller", meta_name: dc02 }
- { name: "{{ os_project }}-{{ win_project }}-fs01", security_group: "file_server", meta_name: fs01 }
standard_vms2:
- { name: "{{ os_project }}-{{ win_project }}-fs02", security_group: "file_server", meta_name: fs02 }
- { name: "{{ os_project }}-{{ win_project }}-wsus", security_group: "wsus_server", meta_name: wsus }
- { name: "{{ os_project }}-{{ win_project }}-choc", security_group: "chocolatey_server", meta_name: choc }