---
- name: create temp instance for gold image creation
  hosts: localhost
  roles:
  - role: deployment-create
    deployment_name: tmp-instance
  post_tasks:
  - name: refresh gce inventory
    command: '{{ inventory_dir }}/gce/hosts/gce.py --refresh-cache'
    changed_when: false
  - meta: refresh_inventory
  - name: configure ssh for temp instance
    include_role:
      name: ssh-config-tmp-instance
  - name: wait for the temp instance to come up
    wait_for:
      host: '{{ hostvars[prefix + "-tmp-instance"]["gce_public_ip"] }}'
      port: 22
      state: started

- name: modify temp instance
  hosts: '{{ prefix }}-tmp-instance'
  roles:
  - gold-image-instance

- name: create gold image from temp instance disk
  hosts: localhost
  roles:
  - role: deployment-delete
    deployment_name: tmp-instance
  - ssh-config-tmp-instance-delete
  - gold-image
