【发布时间】: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-galaxy collection list | grep community.general,似乎-force参数的弃用已经在模块的代码中出现了很长时间:github.com/ansible-collections/community.general/blob/…
标签: ansible terraform ansible-tower