【问题标题】:Ansible Playbook to destroy terraform resourcesAnsible Playbook 销毁 terraform 资源
【发布时间】:2022-07-13 17:02:44
【问题描述】:

我使用触发 terraform 代码的 ansible playbook 创建 Azure 资源。我想破坏资源。下面是创建和销毁的代码。

创建

    - block:
      - name: Run virtual-machine terraform - Planned
        terraform:
          project_path: xxxx
          state: planned
          force_init: true
          plan_file: "xxxx.plan"
          backend_config:
            resource_group_name: "rg-poc-automation"
            storage_account_name: "smartopsazureautomation"
            container_name: "terraformstatefile"
            key: "{{ _customer }}-{{ enviornment }}-vm-config.tfstate" 
      
      - name: Run virtual-machine terraform - Present
        terraform:
          project_path: xxxxx
          state: present
          force_init: true
          plan_file: "xxxxx.plan"
          backend_config:
            resource_group_name: "rg-poc-automation"
            storage_account_name: "smartopsazureautomation"
            container_name: "terraformstatefile"
            key: "{{ _customer }}-{{ enviornment }}-vm-config.tfstate" 

销毁

    - block:   
      - name: Run virtual-machine terraform - Absent
        terraform:
          project_path: xxxxx
          state: absent
          force_init: false
          plan_file: "xxxx.plan"
          backend_config:
            resource_group_name: "rg-poc-automation"
            storage_account_name: "smartopsazureautomation"
            container_name: "terraformstatefile"
            key: "{{ _customer }}-{{ enviornment }}-vm-config.tfstate" 
      environment: "{{ env }}"    

我们在销毁时收到以下错误。这是因为 terraform 最新版本已弃用 -force 并且剧本以某种方式采用它。有没有办法解决它或解决这个问题?

【问题讨论】:

标签: ansible terraform ansible-tower


【解决方案1】:

升级我们的 ansible 版本后它工作正常,因为旧版本没有最新的 terraform 版本更改

【讨论】:

    猜你喜欢
    • 2020-12-27
    • 2020-10-24
    • 2021-02-15
    • 2019-10-25
    • 2019-11-14
    • 1970-01-01
    • 2014-09-05
    • 2019-04-11
    • 2020-03-27
    相关资源
    最近更新 更多