End task if VM have already been created

This commit is contained in:
abrown38 committed 2024-12-11 11:59:48 +00:00
1 parent fa8520a079
commit 01e963d277
1 file changed
+18 -1
+18 -1
View File
@@ -1,9 +1,16 @@
--- ---
- hosts: localhost - hosts: localhost
vars:
vm_status: "{{ lookup('file', '/deployments/{{ os_project }}-{{ win_project }}/VM_STATUS') }}"
vars_files: vars_files:
- ../vars/common.yml - ../vars/common.yml
- ../vars/{{ project_zone }}.yml - ../vars/{{ project_zone }}.yml
tasks: tasks:
- name: End early if VM already created
block:
- meta: end_play
when: vm_status == 'created'
- name: Create workbench VMs (ASYNCHRONUS) - name: Create workbench VMs (ASYNCHRONUS)
tags: teardown tags: teardown
os_server: os_server:
@@ -298,4 +305,14 @@
type: server type: server
variant: web_proxy variant: web_proxy
os: linux os: linux
when: project_zone == 'protected' when: project_zone == 'protected'
- name: Set VM Status
vars:
ansible_connection: local
replace:
path: /deployments/{{ os_project }}-{{ win_project }}/VM_STATUS
regexp: '^pending$'
replace: 'created'
delegate_to: localhost
run_once: True