blockscout-terraform/roles/attach_existing_rds/tasks/main.yml

39 lines
1.3 KiB
YAML
Raw Normal View History

- name: Local or remote backend selector (remote)
template:
src: roles/main_infra/templates/remote-backend-selector.tf.j2
dest: roles/main_infra/files/remote-backend-selector.tf
when:
- backend|bool == true
- name: Local or remote backend selector (local)
file:
state: absent
dest: roles/main_infra/files/remote-backend-selector.tf
when:
- backend | default ('false') | bool != true
- name: Generating variables file
template:
src: roles/main_infra/templates/terraform.tfvars.j2
dest: roles/main_infra/files/terraform.tfvars
- name: Generating backend file
template:
src: roles/main_infra/templates/backend.tfvars.j2
dest: roles/main_infra/files/backend.tfvars
when: backend|bool == true
#Workaround since terraform module return unexpected error.
- name: Initialize Terraform
shell: "echo yes | {{ terraform_location }} init{{ ' -backend-config=backend.tfvars' if backend|bool == true else '' }}"
args:
chdir: "roles/main_infra/files"
- name: Attach existing DB instances
shell: "echo yes | {{ terraform_location }} import aws_db_instance.default[{{ index }}] {{ prefix }}-{{ item.value }}"
args:
chdir: "roles/main_infra/files"
loop: "{{ chain_db_id|dict2items }}"
loop_control:
index_var: index