create common VMs in 2 batches using async (WIP)

This commit is contained in:
abrown38 committed 2024-04-19 10:04:00 +00:00
1 parent a911929a5c
commit 9000343151
2 files changed
+96 -46

No files matched your search

+94 -45
View File
@@ -34,7 +34,9 @@
async: 900
poll: 0
register: async_wb
when: 'wb_quantity|int <= 5'
when:
- 'wb_quantity|int <= 5'
- 'wb_quantity|int > 1'
- name: Create workbench VMs (SEQUENTIAL)
os_server:
@@ -106,7 +108,9 @@
async: 900
poll: 0
register: async_app
when: 'app_quantity|int <= 5'
when:
- 'app_quantity|int <= 5'
- 'app_quantity|int > 1'
- name: Create application VMs (SEQUENTIAL)
os_server:
@@ -178,7 +182,9 @@
async: 900
poll: 0
register: async_gpu
when: 'gpu_quantity|int <= 5'
when:
- 'gpu_quantity|int <= 5'
- 'gpu_quantity|int > 1'
- name: Create GPU VMs (SEQUENTIAL)
os_server:
@@ -220,47 +226,90 @@
delay: 60
when: 'async_gpu.skipped == false'
- name: Common VMs
block:
- name: Create Common VMs (DCs, Fileservers, WSUS, Chocolatey)
openstack.cloud.server:
name: "{{ item.name }}"
state: "{{ state }}"
image: c5d5abb3-c15a-4870-b9b7-89873ae9a9a6
flavor: 3661211f-673a-4777-8857-fd243d6c407d
timeout: 900
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_vms }}"
async: 900
poll: 0
- name: Wait for common VMs to build
os_server_info:
name: "{{ os_project }}-{{ win_project }}-*"
filters:
- name: Common VMs
block:
- name: Create Common VMs (DCs, Fileservers, WSUS, Chocolatey)
os_server:
name: "{{ item.name }}"
state: "{{ state }}"
image: c5d5abb3-c15a-4870-b9b7-89873ae9a9a6
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
vm_state: active
register: common_status
until: 'common_status.servers|length == 6'
retries: 100
delay: 60
# Add async to this task for speed. can openstack handle 6 at once or split 3 3???
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_vms1 }}"
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_status
until: 'common_status.servers|length == 3'
retries: 100
delay: 60
- name: Common VMs
block:
- name: Create Common VMs (DCs, Fileservers, WSUS, Chocolatey)
os_server:
name: "{{ item.name }}"
state: "{{ state }}"
image: c5d5abb3-c15a-4870-b9b7-89873ae9a9a6
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'
retries: 100
delay: 60
+2 -1
View File
@@ -15,10 +15,11 @@ server_vm_flavor: 3661211f-673a-4777-8857-fd243d6c407d
user_vm_flavor: 3661211f-673a-4777-8857-fd243d6c407d
gpu_flavor: 3661211f-673a-4777-8857-fd243d6c407d # CHANGE THIS
standard_vms:
standard_vms1:
- { 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 }