-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathiac.yaml
More file actions
52 lines (43 loc) · 1.35 KB
/
iac.yaml
File metadata and controls
52 lines (43 loc) · 1.35 KB
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: Create terraform variables file
connection: local
hosts: localhost
gather_facts: false
tasks:
- name: Installing terraform provider
ansible.builtin.command:
cmd: "terraform init"
chdir: "files/tf/"
register: output
- name: Terraform init output
debug:
var: output.stdout_lines
- name: Create workspace
ignore_errors: true
ansible.builtin.command:
cmd: "terraform workspace new {{ pop }}-{{ stage }}"
chdir: "files/tf/"
register: output
- name: Change to workspace
ansible.builtin.command:
cmd: "terraform workspace select {{ pop }}-{{ stage }}"
chdir: "files/tf/"
register: output
- name: Create *.auto.tfvars file
ansible.builtin.template:
src: auto.tfvars.j2
dest: "files/tf/{{ pop }}_{{ stage }}.auto.tfvars"
mode: '0644'
- name: Planning using terraform vars
ansible.builtin.command:
cmd: "terraform plan -var-file={{ pop }}_{{ stage }}.auto.tfvars -out {{ pop }}_{{ stage }}_plan"
chdir: "files/tf/"
register: output
# - name: Deploying terraform resources
# community.general.terraform:
# project_path: "files/tf/"
# state: present
# register: output
- name: Terraform output
debug:
var: output.stdout_lines