Tom Printy
Tom Printy

Reputation: 91

Stopping A Google Compute Resource with Ansible

It is great that you can create a new GCP instance with Ansible but how do you terminate the instance?

I don't see a command to do this.

Upvotes: 2

Views: 273

Answers (1)

Tom Printy
Tom Printy

Reputation: 91

Ok so it appears that all you have to do is set the state of the resource to "absent"

So it would look something like:

- name: detroy instance
  gcp_compute_instance:
     state: absent
     name: "{{servername}}"
     zone: "{{ zone }}"
     project: "{{ gcp_project }}"
     auth_kind: "{{ gcp_cred_kind }}"
     service_account_file: "{{ gcp_cred_file }}"

Upvotes: 2

Related Questions