From 01e963d27760d23a5acb748904e973154660d746 Mon Sep 17 00:00:00 2001 From: abrown38 Date: Wed, 11 Dec 2024 11:59:48 +0000 Subject: [PATCH] End task if VM have already been created --- ansible/playbooks/openstack-vms.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ansible/playbooks/openstack-vms.yml b/ansible/playbooks/openstack-vms.yml index 7733d27..16e3685 100644 --- a/ansible/playbooks/openstack-vms.yml +++ b/ansible/playbooks/openstack-vms.yml @@ -1,9 +1,16 @@ --- - hosts: localhost + vars: + vm_status: "{{ lookup('file', '/deployments/{{ os_project }}-{{ win_project }}/VM_STATUS') }}" vars_files: - ../vars/common.yml - ../vars/{{ project_zone }}.yml tasks: + - name: End early if VM already created + block: + - meta: end_play + when: vm_status == 'created' + - name: Create workbench VMs (ASYNCHRONUS) tags: teardown os_server: @@ -298,4 +305,14 @@ type: server variant: web_proxy os: linux - when: project_zone == 'protected' \ No newline at end of file + 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 \ No newline at end of file