无法使用ansible停止现有的gcp实例



我正在尝试使用ansible停止现有的gcp实例。以下是我使用的剧本:

- name: Stop an instance
hosts: virtualmachines
gather_facts: false
tasks:
- name: Stop an instance
google.cloud.gcp_compute_instance:
project: <project name>
machine_type: <type>
name: <name>
zone: <zone>
service_account_file: <file_path>
auth_kind: "serviceaccount"
status: stopped
state: present
deletion_protection: true

当我运行playbook时,我得到以下响应,但是实例没有停止。

PLAY [Stop an instance] *****************************************************************************************************************************************************************
TASK [Stop an instance] *****************************************************************************************************************************************************************
changed: [vm01]
PLAY RECAP ******************************************************************************************************************************************************************************
vm01                       : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

我认为你需要使用status: STOPPING来获得这个工作

---
- name: Stop an instance
hosts: virtualmachines
gather_facts: false
tasks:
- name: Stop an instance
google.cloud.gcp_compute_instance:
project: <project name>
machine_type: <type>
name: <name>
zone: <zone>
service_account_file: <file_path>
auth_kind: "serviceaccount"
status: STOPPING
deletion_protection: true

有效的状态选项包括:" PROVISIONING ", " STAGING ", " RUNNING ", " stopped ", " SUSPENDED ", " SUSPENDED ", " TERMINATED "

按doc

相关内容

  • 没有找到相关文章

最新更新