mirror of
https://git.ecdf.ed.ac.uk/win_automation/windows-ansible.git
synced 2026-10-26 14:17:21 +00:00
New role to build new use vms
This commit is contained in:
1 parent
30aa6c5aad
commit
ebc1b4901e
5 files changed
+129
No files matched your search
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- hosts: "localhost"
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- ../vars/common.yml
|
||||
- ../vars/{{ project_zone }}.yml
|
||||
roles:
|
||||
- role: win_vms
|
||||
tags: win_vms
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
- name: Create application VMs (SEQUENTIAL)
|
||||
os_server:
|
||||
name: "{{ os_project }}-{{ win_project }}-app{{ '%02d' | format(item+1+app_quantity|int) }}"
|
||||
state: "{{ state }}"
|
||||
image: "{{ vm_image }}"
|
||||
flavor: "{{ user_vm_flavor }}"
|
||||
timeout: 900
|
||||
boot_from_volume: true
|
||||
volume_size: 40
|
||||
terminate_volume: yes
|
||||
security_groups:
|
||||
- domain_member
|
||||
- user_vms
|
||||
network: "{{ os_network }}"
|
||||
metadata:
|
||||
name: "app{{ '%02d' | format(item+1+app_quantity|int) }}"
|
||||
win_project: "{{ win_project }}"
|
||||
type: client
|
||||
variant: application
|
||||
os: windows
|
||||
new_vm: "true" # Tag to target only new VMs
|
||||
userdata: |
|
||||
#ps1
|
||||
Rename-Computer "{{ win_project }}-app{{ '%02d' | format(item+1+app_quantity|int) }}"
|
||||
$admin = [adsi]("WinNT://./Administrator, user")
|
||||
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
|
||||
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('{{ winrm_script_url }}'))
|
||||
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 }}"
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
- name: Create gpu VMs (SEQUENTIAL)
|
||||
os_server:
|
||||
name: "{{ os_project }}-{{ win_project }}-gpu{{ '%02d' | format(item+1+gpu_quantity|int) }}"
|
||||
state: "{{ state }}"
|
||||
image: "{{ vm_image }}"
|
||||
flavor: "{{ user_vm_flavor }}"
|
||||
timeout: 900
|
||||
boot_from_volume: true
|
||||
volume_size: 40
|
||||
terminate_volume: yes
|
||||
security_groups:
|
||||
- domain_member
|
||||
- user_vms
|
||||
network: "{{ os_network }}"
|
||||
metadata:
|
||||
name: "gpu{{ '%02d' | format(item+1+gpu_quantity|int) }}"
|
||||
win_project: "{{ win_project }}"
|
||||
type: client
|
||||
variant: gpu
|
||||
os: windows
|
||||
new_vm: "true" # Tag to target only new VMs
|
||||
userdata: |
|
||||
#ps1
|
||||
Rename-Computer "{{ win_project }}-gpu{{ '%02d' | format(item+1+gpu_quantity|int) }}"
|
||||
$admin = [adsi]("WinNT://./Administrator, user")
|
||||
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
|
||||
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('{{ winrm_script_url }}'))
|
||||
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 }}"
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- import_tasks: workbench.yml
|
||||
when: new_wb_quantity|int > 0
|
||||
|
||||
- import_tasks: application.yml
|
||||
when: new_app_quantity|int > 0
|
||||
|
||||
- import_tasks: gpu.yml
|
||||
when: new_gpu_quantity|int > 0
|
||||
|
||||
- name: Set Password Status
|
||||
replace:
|
||||
path: /deployments/{{ os_project }}-{{ win_project }}/PASSWORD
|
||||
regexp: '^finished$'
|
||||
replace: 'pending'
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
- name: Create workbench VMs (SEQUENTIAL)
|
||||
os_server:
|
||||
name: "{{ os_project }}-{{ win_project }}-wb{{ '%02d' | format(item+1+wb_quantity|int) }}"
|
||||
state: "{{ state }}"
|
||||
image: "{{ vm_image }}"
|
||||
flavor: "{{ user_vm_flavor }}"
|
||||
timeout: 900
|
||||
boot_from_volume: true
|
||||
volume_size: 40
|
||||
terminate_volume: yes
|
||||
security_groups:
|
||||
- domain_member
|
||||
- user_vms
|
||||
network: "{{ os_network }}"
|
||||
metadata:
|
||||
name: "wb{{ '%02d' | format(item+1+wb_quantity|int) }}"
|
||||
win_project: "{{ win_project }}"
|
||||
type: client
|
||||
variant: workbench
|
||||
os: windows
|
||||
new_vm: "true" # Tag to target only new VMs
|
||||
userdata: |
|
||||
#ps1
|
||||
Rename-Computer "{{ win_project }}-wb{{ '%02d' | format(item+1+wb_quantity|int) }}"
|
||||
$admin = [adsi]("WinNT://./Administrator, user")
|
||||
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
|
||||
Invoke-Expression ((New-Object System.Net.Webclient).DownloadString('{{ winrm_script_url }}'))
|
||||
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 }}"
|
||||
Reference in new issue
Block a user