From 4ed8d5e0ab745ba1165205c4e65450a9c4555c6c Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Sat, 25 Jun 2016 17:26:01 +0000 Subject: [PATCH] Rework the persistent volume attach to not have errors that are ignored. --- tasks/persistent_cloud.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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