#--------------------------------------------------- # Terraform #--------------------------------------------------- --- - name: Terraform | Step 001 Deploy Infrastructure hosts: localhost connection: local gather_facts: false become: false vars_files: - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_vars.yml" - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_secret_vars.yml" tags: - step001 - deploy_infrastructure tasks: - name: Terraform | Check if Terraform is installed command: terraform version register: terraform_check tags: - step001 - name: Terraform | Install Terraform fail: msg: "You need to install Terraform" when: terraform_check.stdout.find('is not installed') != -1 tags: - step001 - name: Terraform | Template Terraform files locally to run template: dest: "{{ terraform_working_dir }}/{{ workshop_prefix }}/aws.tf" src: "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/files/cloud_providers/aws.tf.j2" tags: - step001 - name: Terraform | Template terraform.tfvars template: dest: "{{ terraform_working_dir }}/{{ workshop_prefix }}/terraform.tfvars" src: "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/files/cloud_providers/terraform.tfvars.j2" tags: - step001 - name: Terraform | Run Terraform command: terraform apply chdir="{{ terraform_working_dir }}/{{ workshop_prefix }}" tags: - step001 - name: Terraform | Wait for AWS AMIs to become initialized pause: minutes=2 tags: - step001