how to create a GCP disk from a GCP snapshot

38 views
Skip to first unread message

thor01

unread,
May 9, 2021, 10:02:05 AM5/9/21
to Ansible Project
Hi all, I am new to Ansible and I am trying to figure out who to create a GCP disk from a GCP snapshot, using the gcp_compute_disk module. I am using the following documentation: https://docs.ansible.com/ansible/latest/collections/google/cloud/gcp_compute_snapshot_module.html
I created the playbook below, but it only creates an empty new disk, not a disk from the snapshot. My ansible version is 2.9.20. Thank you.

- name: Create GCP snapshots
  hosts: localhost
  gather_facts: yes
  vars:
      gcp_project: test-project
      gcp_cred_kind: serviceaccount
      gcp_cred_file: /etc/ansible/keys/ansible-test-project-service-account-key.json
      zone: "us-central1-a"
      region: "us-central1"
      instancename: "test-instance"
      snapshot:

  tasks:
  
   - name: create data disk from a snapshot
     gcp_compute_disk:
       name: "{{ instancename }}-data-1"
       description: "{{ instancename }}-data-1"
       zone: "{{ zone }}"
       project: "{{ gcp_project }}"
       auth_kind: "{{ gcp_cred_kind }}"
       service_account_file: "{{ gcp_cred_file }}"
       source_snapshot: "{{ snapshot }}"
       labels:
         usage: test-label
       state: present
     register: disk_data

Reply all
Reply to author
Forward
0 new messages