New VM improvements

This commit is contained in:
abrown38 committed 2025-01-06 16:06:23 +00:00
1 parent ebc1b4901e
commit 3686d7f627
7 files changed
+180 -29

No files matched your search

+25 -6
View File
@@ -1,7 +1,9 @@
---
- name: Create application VMs (SEQUENTIAL)
vars:
vm_name: "{{ os_project }}-{{ win_project }}-app{{ '%02d' | format(item+1+app_quantity|int) }}"
os_server:
name: "{{ os_project }}-{{ win_project }}-app{{ '%02d' | format(item+1+app_quantity|int) }}"
name: "{{ vm_name }}"
state: "{{ state }}"
image: "{{ vm_image }}"
flavor: "{{ user_vm_flavor }}"
@@ -26,10 +28,27 @@
$admin = [adsi]("WinNT://./Administrator, user")
$admin.PSBase.Invoke("SetPassword", "{{ vm_initial_password }}")
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 }}"
- 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 }}"
- name: cleanup
block:
- name: delete metadata from instance
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 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'