diff --git a/ansible/deploy_all.yml b/ansible/deploy_all.yml index 11645f4..d949184 100644 --- a/ansible/deploy_all.yml +++ b/ansible/deploy_all.yml @@ -4,6 +4,8 @@ connection: local gather_facts: false become: false + vars: + tf_dir: "{{ playbook_dir }}/../terraform" tasks: - name: Create terraform mirror config @@ -19,15 +21,15 @@ } } - - name: Nuclear Cleanup - shell: "rm -rf .terraform .terraform.lock.hcl" + - name: Total Cleanup + shell: "rm -rf .terraform .terraform.lock.hcl terraform.tfstate*" args: - chdir: "{{ playbook_dir }}/../terraform" + chdir: "{{ tf_dir }}" - name: Terraform Init shell: terraform init -reconfigure -no-color args: - chdir: "{{ playbook_dir }}/../terraform" + chdir: "{{ tf_dir }}" environment: TF_CLI_CONFIG_FILE: "/tmp/.terraformrc" TF_HTTP_ADDRESS: "{{ lookup('env', 'TF_HTTP_ADDRESS') }}" @@ -37,8 +39,7 @@ - name: Terraform Apply shell: terraform apply -auto-approve -no-color -lock=false args: - chdir: "{{ playbook_dir }}/../terraform" - register: tf_result + chdir: "{{ tf_dir }}" environment: TF_CLI_CONFIG_FILE: "/tmp/.terraformrc" TF_HTTP_ADDRESS: "{{ lookup('env', 'TF_HTTP_ADDRESS') }}" @@ -48,6 +49,7 @@ TF_VAR_proxmox_api_token_secret: "{{ lookup('env', 'TF_VAR_proxmox_api_token_secret') }}" TF_VAR_proxmox_api_url: "{{ lookup('env', 'TF_VAR_proxmox_api_url') }}" + - name: Dynamically add hosts to Ansible memory add_host: name: "{{ item.name }}"