This repository has been archived by the owner on Dec 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvm-reset.yml
52 lines (46 loc) · 1.5 KB
/
vm-reset.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
- name: Deploy three VMs with Terraform
hosts: localhost
tags: terraform, vms
tasks:
- name: Prompt for confirmation
ansible.builtin.pause:
prompt: "This will remove all VMs and DELETE ALL DATA. Type 'yes' in all caps to confirm"
register: confirmation
run_once: true
delegate_to: localhost
- name: Fail if confirmation is not 'YES'
ansible.builtin.fail:
msg: "Confirmation not 'YES'"
when:
- confirmation.user_input != "YES"
- name: Prompt for confirmation
ansible.builtin.pause:
prompt: "ARE YOU SURE? Type 'yes' in all caps to confirm"
register: confirmation_2
run_once: true
delegate_to: localhost
- name: Fail if confirmation is not 'YES'
ansible.builtin.fail:
msg: "Confirmation not 'YES'"
when:
- confirmation_2.user_input != "YES"
- name: Delete Terraform project
cloud.terraform.terraform:
project_path: "{{ lookup('env', 'PWD') }}/terraform/vms"
state: absent
force_init: true
variables_files:
- "{{ lookup('env', 'PWD') }}/terraform/vms/env/vars.tfvars"
variables:
libvirt_uri: "{{ libvirt_connection_uri }}"
- name: Remove tfstate file
ansible.builtin.file:
path: "{{ playbook_dir }}/../../terraform/{{ item }}"
state: absent
run_once: true
delegate_to: localhost
loop:
- rancher/terraform.tfstate
- rancher/terraform.tfstate.backup
...