diff --git a/tasks/persistent_cloud.yml b/tasks/persistent_cloud.yml index 8ca5a5c688..cc4ac87e07 100644 --- a/tasks/persistent_cloud.yml +++ b/tasks/persistent_cloud.yml @@ -44,11 +44,21 @@ # instance can be both id and name, volume must be id # volume must be id -- local_action: shell nova --os-auth-url="{{os_auth_url}}" --os-username="admin" --os-password="{{ADMIN_PASS}}" --os-tenant-name={{inventory_tenant}} volume-list | grep ' {{item.volume_id}} ' | grep 'available' && nova --os-auth-url="{{os_auth_url}}" --os-username="admin" --os-password="{{ADMIN_PASS}}" --os-tenant-name={{inventory_tenant}} volume-attach "{{inventory_instance_name}}" "{{item.volume_id}}" "{{item.device}}" +# +# Check that the volume is available +# +- local_action: shell nova --os-auth-url="{{os_auth_url}}" --os-username="admin" --os-password="{{ADMIN_PASS}}" --os-tenant-name={{inventory_tenant}} volume-list | grep ' {{item.volume_id}} ' | grep 'available' with_items: "{{volumes}}" - ignore_errors: yes + register: volume_available when: volumes is defined +# +# If it is attach it. +# +- local_action: shell nova --os-auth-url="{{os_auth_url}}" --os-username="admin" --os-password="{{ADMIN_PASS}}" --os-tenant-name={{inventory_tenant}} volume-attach "{{inventory_instance_name}}" "{{item.volume_id}}" "{{item.device}}" + with_items: "{{volumes}}" + when: volume_available|success + - name: wait for he host to be hot local_action: wait_for host={{ public_ip }} port=22 delay=1 timeout=600 when: host_is_up|failed