IBM-Cloud / ansible-collection-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
70 stars 73 forks source link

ibm_is_snapshot - Add Support for Timeouts #69

Open DanielFarrarCO opened 3 years ago

DanielFarrarCO commented 3 years ago

Running this on a VSI disk with a large amount of data:

- name: Create Snapshot
  ibm.cloudcollection.ibm_is_snapshot:
    name: "snapshot-name"
    resource_group: "{{ibm_resource_group_info.resource.id}}"
    source_volume: "{{item.volume_id}}"
    region: "{{vdc_region}}"
  with_items: "{{vm_info.resource.volume_attachments}}"

Returns this error:

Error: timeout while waiting for state to become 'stable, failed' (last state: 'pending', timeout: 10m0s)

Per this thread, the Terraform module should support timeout values and that is being added to the documentation. [(https://github.com/IBM-Cloud/terraform-provider-ibm/issues/2989)] Reading through the code I didn't see that timeout create/update/delete is supported in this ansible module. If we can update the module to support the backend terraform timeout that would be great!

Current workaround is to create the snapshot in async mode with polling 0, then loop check on the snapshot status until it is stable:

- name: Create Snapshot
  ibm.cloudcollection.ibm_is_snapshot:
    name: "{{item.volume_name}}-{{job_weekday}}-{{job_date}}-{{job_time_stamp}}"
    resource_group: "{{ibm_resource_group_info.resource.id}}"
    source_volume: "{{item.volume_id}}"
    region: "{{vdc_region}}"
  when: take_snapshot
  register: snapshots
  async: 3600
  poll: 0
  delegate_to: localhost
  with_items: "{{vm_info.resource.volume_attachments}}"

- name: Check Snapshots
  ibm.cloudcollection.ibm_is_snapshot_info:
    name: "{{item.volume_name}}-{{job_weekday}}-{{job_date}}-{{job_time_stamp}}"
    region: "{{vdc_region}}"
  when: take_snapshot
  register: snapshot_progress
  delay: 60
  retries: 60
  until:
    - snapshot_progress.rc == 0
    - snapshot_progress.resource.lifecycle_state == "stable"
  delegate_to: localhost
  with_items: "{{vm_info.resource.volume_attachments}}"