mirror of
https://git.ecdf.ed.ac.uk/win_automation/windows-ansible.git
synced 2026-10-26 11:27:21 +00:00
New VM improvements
This commit is contained in:
1 parent
ebc1b4901e
commit
3686d7f627
7 files changed
+180
-29
No files matched your search
@@ -63,6 +63,11 @@
|
|||||||
- name: Flush handlers
|
- name: Flush handlers
|
||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
|
|
||||||
|
- name: Pause for 30 seconds to allow changes to activate
|
||||||
|
ansible.builtin.pause:
|
||||||
|
seconds: 30
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- name: Create downtimes for new VMs
|
- name: Create downtimes for new VMs
|
||||||
block:
|
block:
|
||||||
- name: "Schedule downtime on Windows VMs to cover deployment"
|
- name: "Schedule downtime on Windows VMs to cover deployment"
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
cleanup: false
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
---
|
---
|
||||||
- name: Create application VMs (SEQUENTIAL)
|
- name: Create application VMs (SEQUENTIAL)
|
||||||
|
vars:
|
||||||
|
vm_name: "{{ os_project }}-{{ win_project }}-app{{ '%02d' | format(item+1+app_quantity|int) }}"
|
||||||
os_server:
|
os_server:
|
||||||
name: "{{ os_project }}-{{ win_project }}-app{{ '%02d' | format(item+1+app_quantity|int) }}"
|
name: "{{ vm_name }}"
|
||||||
state: "{{ state }}"
|
state: "{{ state }}"
|
||||||
image: "{{ vm_image }}"
|
image: "{{ vm_image }}"
|
||||||
flavor: "{{ user_vm_flavor }}"
|
flavor: "{{ user_vm_flavor }}"
|
||||||
@@ -26,10 +28,27 @@
|
|||||||
$admin = [adsi]("WinNT://./Administrator, user")
|
$admin = [adsi]("WinNT://./Administrator, user")
|
||||||
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
|
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
|
||||||
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('{{ winrm_script_url }}'))
|
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('{{ winrm_script_url }}'))
|
||||||
|
when:
|
||||||
|
- "vm_name not in groups['meta-type_client']|default([])"
|
||||||
|
- cleanup == 'false'
|
||||||
loop: "{{ range(new_app_quantity|int)|list }}"
|
loop: "{{ range(new_app_quantity|int)|list }}"
|
||||||
|
|
||||||
- name: Increase application quantity variable
|
- name: cleanup
|
||||||
ansible.builtin.lineinfile:
|
block:
|
||||||
path: /deployments/{{ os_project }}-{{ win_project }}/ansible/vars/common.yml
|
- name: delete metadata from instance
|
||||||
regexp: '^app_quantity:\s*\d+'
|
vars:
|
||||||
line: "app_quantity: {{ app_quantity + new_app_quantity | int }}"
|
vm_name: "{{ os_project }}-{{ win_project }}-app{{ '%02d' | format(item+1+app_quantity|int) }}"
|
||||||
|
openstack.cloud.server_metadata:
|
||||||
|
state: absent
|
||||||
|
cloud: "{{ os_project }}"
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
meta:
|
||||||
|
new_vm:
|
||||||
|
loop: "{{ range(new_app_quantity|int)|list }}"
|
||||||
|
|
||||||
|
- name: Increase application quantity variable
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /deployments/{{ os_project }}-{{ win_project }}/ansible/vars/common.yml
|
||||||
|
regexp: '^app_quantity:\s*\d+'
|
||||||
|
line: "app_quantity: {{ app_quantity + new_app_quantity | int }}"
|
||||||
|
when: cleanup == 'true'
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
---
|
---
|
||||||
- name: Create gpu VMs (SEQUENTIAL)
|
- name: Create gpu VMs (SEQUENTIAL)
|
||||||
|
vars:
|
||||||
|
vm_name: "{{ os_project }}-{{ win_project }}-gpu{{ '%02d' | format(item+1+gpu_quantity|int) }}"
|
||||||
os_server:
|
os_server:
|
||||||
name: "{{ os_project }}-{{ win_project }}-gpu{{ '%02d' | format(item+1+gpu_quantity|int) }}"
|
name: "{{ vm_name }}"
|
||||||
state: "{{ state }}"
|
state: "{{ state }}"
|
||||||
image: "{{ vm_image }}"
|
image: "{{ vm_image }}"
|
||||||
flavor: "{{ user_vm_flavor }}"
|
flavor: "{{ user_vm_flavor }}"
|
||||||
@@ -26,10 +28,27 @@
|
|||||||
$admin = [adsi]("WinNT://./Administrator, user")
|
$admin = [adsi]("WinNT://./Administrator, user")
|
||||||
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
|
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
|
||||||
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('{{ winrm_script_url }}'))
|
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('{{ winrm_script_url }}'))
|
||||||
|
when:
|
||||||
|
- "vm_name not in groups['meta-type_client']|default([])"
|
||||||
|
- cleanup == 'false'
|
||||||
loop: "{{ range(new_gpu_quantity|int)|list }}"
|
loop: "{{ range(new_gpu_quantity|int)|list }}"
|
||||||
|
|
||||||
- name: Increase gpu quantity variable
|
- name: cleanup
|
||||||
ansible.builtin.lineinfile:
|
block:
|
||||||
path: /deployments/{{ os_project }}-{{ win_project }}/ansible/vars/common.yml
|
- name: delete metadata from instance
|
||||||
regexp: '^gpu_quantity:\s*\d+'
|
vars:
|
||||||
line: "gpu_quantity: {{ gpu_quantity + new_gpu_quantity | int }}"
|
vm_name: "{{ os_project }}-{{ win_project }}-gpu{{ '%02d' | format(item+1+gpu_quantity|int) }}"
|
||||||
|
openstack.cloud.server_metadata:
|
||||||
|
state: absent
|
||||||
|
cloud: "{{ os_project }}"
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
meta:
|
||||||
|
new_vm:
|
||||||
|
loop: "{{ range(new_gpu_quantity|int)|list }}"
|
||||||
|
|
||||||
|
- name: Increase gpu quantity variable
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /deployments/{{ os_project }}-{{ win_project }}/ansible/vars/common.yml
|
||||||
|
regexp: '^gpu_quantity:\s*\d+'
|
||||||
|
line: "gpu_quantity: {{ gpu_quantity + new_gpu_quantity | int }}"
|
||||||
|
when: cleanup == 'true'
|
||||||
@@ -1,15 +1,25 @@
|
|||||||
---
|
---
|
||||||
- import_tasks: workbench.yml
|
- name: Create VMs
|
||||||
when: new_wb_quantity|int > 0
|
block:
|
||||||
|
- import_tasks: workbench.yml
|
||||||
|
when: new_wb_quantity|int > 0
|
||||||
|
|
||||||
- import_tasks: application.yml
|
- import_tasks: application.yml
|
||||||
when: new_app_quantity|int > 0
|
when: new_app_quantity|int > 0
|
||||||
|
|
||||||
- import_tasks: gpu.yml
|
- import_tasks: gpu.yml
|
||||||
when: new_gpu_quantity|int > 0
|
when: new_gpu_quantity|int > 0
|
||||||
|
|
||||||
- name: Set Password Status
|
- name: Set Password Status
|
||||||
replace:
|
replace:
|
||||||
path: /deployments/{{ os_project }}-{{ win_project }}/PASSWORD
|
path: /deployments/{{ os_project }}-{{ win_project }}/PASSWORD
|
||||||
regexp: '^finished$'
|
regexp: '^finished$'
|
||||||
replace: 'pending'
|
replace: 'pending'
|
||||||
|
when:
|
||||||
|
- new_wb_quantity|int > 0
|
||||||
|
- new_app_quantity|int > 0
|
||||||
|
- new_gpu_quantity|int > 0
|
||||||
|
when: cleanup == 'false'
|
||||||
|
|
||||||
|
- import_tasks: metadata.yml
|
||||||
|
when: cleanup == 'true'
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
---
|
||||||
|
- name: delete metadata from instance
|
||||||
|
vars:
|
||||||
|
vm_name: "{{ os_project }}-{{ win_project }}-wb{{ '%02d' | format(item+1+wb_quantity|int) }}"
|
||||||
|
openstack.cloud.server_metadata:
|
||||||
|
state: absent
|
||||||
|
cloud: "{{ os_project }}"
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
meta:
|
||||||
|
new_vm:
|
||||||
|
loop: "{{ range(new_wb_quantity|int)|list }}"
|
||||||
|
|
||||||
|
- name: Increase workbench quantity variable
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /deployments/{{ os_project }}-{{ win_project }}/ansible/vars/common.yml
|
||||||
|
regexp: '^wb_quantity:\s*\d+'
|
||||||
|
line: "wb_quantity: {{ wb_quantity + new_wb_quantity | int }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: delete metadata from application VMs
|
||||||
|
vars:
|
||||||
|
vm_name: "{{ os_project }}-{{ win_project }}-app{{ '%02d' | format(item+1+app_quantity|int) }}"
|
||||||
|
openstack.cloud.server_metadata:
|
||||||
|
state: absent
|
||||||
|
cloud: "{{ os_project }}"
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
meta:
|
||||||
|
new_vm:
|
||||||
|
loop: "{{ range(new_app_quantity|int)|list }}"
|
||||||
|
|
||||||
|
- name: Increase workbench quantity variable
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /deployments/{{ os_project }}-{{ win_project }}/ansible/vars/common.yml
|
||||||
|
regexp: '^wb_quantity:\s*\d+'
|
||||||
|
line: "wb_quantity: {{ app_quantity + new_app_quantity | int }}"
|
||||||
|
|
||||||
|
- name: delete metadata from instance
|
||||||
|
vars:
|
||||||
|
vm_name: "{{ os_project }}-{{ win_project }}-gpu{{ '%02d' | format(item+1+gpu_quantity|int) }}"
|
||||||
|
openstack.cloud.server_metadata:
|
||||||
|
state: absent
|
||||||
|
cloud: "{{ os_project }}"
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
meta:
|
||||||
|
new_vm:
|
||||||
|
loop: "{{ range(new_gpu_quantity|int)|list }}"
|
||||||
|
|
||||||
|
- name: Increase workbench quantity variable
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /deployments/{{ os_project }}-{{ win_project }}/ansible/vars/common.yml
|
||||||
|
regexp: '^gpu_quantity:\s*\d+'
|
||||||
|
line: "wb_quantity: {{ gpu_quantity + new_gpu_quantity | int }}"
|
||||||
|
|
||||||
|
|
||||||
|
#- name: Remove temporary metadata
|
||||||
|
# tags: remove_metadata
|
||||||
|
# block:
|
||||||
|
# - name: Remove new metadata tag from GPU VMs
|
||||||
|
# shell: |
|
||||||
|
# export OS_CLIENT_CONFIG_FILE=/deployments/{{ os_project }}-{{ win_project }}/clouds.yaml
|
||||||
|
# export OS_CLOUD={{ os_project }}
|
||||||
|
# openstack server unset --property new_vm "{{ os_project }}-{{ win_project }}-wb{{ '%02d' | format(item+1|int) }}"
|
||||||
|
# loop: "{{ range(wb_quantity|int)|list }}"
|
||||||
|
#
|
||||||
|
# - name: Remove new metadata tag from GPU VMs
|
||||||
|
# shell: |
|
||||||
|
# export OS_CLIENT_CONFIG_FILE=/deployments/{{ os_project }}-{{ win_project }}/clouds.yaml
|
||||||
|
# export OS_CLOUD={{ os_project }}
|
||||||
|
# openstack server unset --property new_vm "{{ os_project }}-{{ win_project }}-app{{ '%02d' | format(item+1|int) }}"
|
||||||
|
# loop: "{{ range(app_quantity|int)|list }}"
|
||||||
|
#
|
||||||
|
# - name: Remove new metadata tag from GPU VMs
|
||||||
|
# shell: |
|
||||||
|
# export OS_CLIENT_CONFIG_FILE=/deployments/{{ os_project }}-{{ win_project }}/clouds.yaml
|
||||||
|
# export OS_CLOUD={{ os_project }}
|
||||||
|
# openstack server unset --property new_vm "{{ os_project }}-{{ win_project }}-gpu{{ '%02d' | format(item+1|int) }}"
|
||||||
|
# loop: "{{ range(gpu_quantity|int)|list }}"
|
||||||
|
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
---
|
---
|
||||||
- name: Create workbench VMs (SEQUENTIAL)
|
- name: Create workbench VMs (SEQUENTIAL)
|
||||||
|
vars:
|
||||||
|
vm_name: "{{ os_project }}-{{ win_project }}-wb{{ '%02d' | format(item+1+wb_quantity|int) }}"
|
||||||
os_server:
|
os_server:
|
||||||
name: "{{ os_project }}-{{ win_project }}-wb{{ '%02d' | format(item+1+wb_quantity|int) }}"
|
name: "{{ vm_name }}"
|
||||||
state: "{{ state }}"
|
state: "{{ state }}"
|
||||||
image: "{{ vm_image }}"
|
image: "{{ vm_image }}"
|
||||||
flavor: "{{ user_vm_flavor }}"
|
flavor: "{{ user_vm_flavor }}"
|
||||||
@@ -26,10 +28,27 @@
|
|||||||
$admin = [adsi]("WinNT://./Administrator, user")
|
$admin = [adsi]("WinNT://./Administrator, user")
|
||||||
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
|
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
|
||||||
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('{{ winrm_script_url }}'))
|
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('{{ winrm_script_url }}'))
|
||||||
|
when:
|
||||||
|
- "vm_name not in groups['meta-type_client']|default([])"
|
||||||
|
- cleanup == 'false'
|
||||||
loop: "{{ range(new_wb_quantity|int)|list }}"
|
loop: "{{ range(new_wb_quantity|int)|list }}"
|
||||||
|
|
||||||
- name: Increase workbench quantity variable
|
- name: cleanup
|
||||||
ansible.builtin.lineinfile:
|
block:
|
||||||
path: /deployments/{{ os_project }}-{{ win_project }}/ansible/vars/common.yml
|
- name: delete metadata from instance
|
||||||
regexp: '^wb_quantity:\s*\d+'
|
vars:
|
||||||
line: "wb_quantity: {{ wb_quantity + new_wb_quantity | int }}"
|
vm_name: "{{ os_project }}-{{ win_project }}-wb{{ '%02d' | format(item+1+wb_quantity|int) }}"
|
||||||
|
openstack.cloud.server_metadata:
|
||||||
|
state: absent
|
||||||
|
cloud: "{{ os_project }}"
|
||||||
|
name: "{{ vm_name }}"
|
||||||
|
meta:
|
||||||
|
new_vm:
|
||||||
|
loop: "{{ range(new_wb_quantity|int)|list }}"
|
||||||
|
|
||||||
|
- name: Increase workbench quantity variable
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /deployments/{{ os_project }}-{{ win_project }}/ansible/vars/common.yml
|
||||||
|
regexp: '^wb_quantity:\s*\d+'
|
||||||
|
line: "wb_quantity: {{ wb_quantity + new_wb_quantity | int }}"
|
||||||
|
when: cleanup == 'true'
|
||||||
Reference in new issue
Block a user