From d249f0b2fcf0f88ccb522d3acb568af41943cb5d Mon Sep 17 00:00:00 2001 From: Pragadeeswaran Sathyanarayanan Date: Fri, 17 May 2024 08:58:22 +0530 Subject: [PATCH] Fix multiattach volume type create playbook For uni* jobs none of the cifmw_install_yamls_* variables are set as the deployment is done via devscripts role. This causes a failure when executing the hook. This patch sets the default value of the namespace to openstack. Signed-off-by: Pragadeeswaran Sathyanarayanan --- .../cinder_multiattach_volume_type.yml | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/hooks/playbooks/cinder_multiattach_volume_type.yml b/hooks/playbooks/cinder_multiattach_volume_type.yml index 627bfb5743..4479f29145 100644 --- a/hooks/playbooks/cinder_multiattach_volume_type.yml +++ b/hooks/playbooks/cinder_multiattach_volume_type.yml @@ -5,16 +5,27 @@ tasks: - name: Set the multiattach volume type name ansible.builtin.set_fact: - cifmw_volume_multiattach_type: "{{ cifmw_volume_multiattach_type|default('multiattach') }}" + cifmw_volume_multiattach_type: >- + {{ + cifmw_volume_multiattach_type | default('multiattach') + }} - name: Set a multiattach volume type and create it if needed + vars: + _namespace: >- + {{ + cifmw_install_yamls_defaults['NAMESPACE'] | default('openstack') + }} environment: KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" PATH: "{{ cifmw_path }}" ansible.builtin.shell: | - oc -n {{ cifmw_install_yamls_defaults['NAMESPACE'] }} rsh openstackclient \ - openstack volume type show {{ cifmw_volume_multiattach_type }} &>/dev/null || \ - oc -n {{ cifmw_install_yamls_defaults['NAMESPACE'] }} rsh openstackclient \ - openstack volume type create {{ cifmw_volume_multiattach_type }} - oc -n {{ cifmw_install_yamls_defaults['NAMESPACE'] }} rsh openstackclient \ - openstack volume type set --property multiattach=" True" {{ cifmw_volume_multiattach_type }} + set -xe -o pipefail + oc project {{ _namespace }} + oc rsh openstackclient \ + openstack volume type show {{ cifmw_volume_multiattach_type }} &>/dev/null || \ + oc rsh openstackclient \ + openstack volume type create {{ cifmw_volume_multiattach_type }} + oc rsh openstackclient \ + openstack volume type set --property multiattach=" True" \ + {{ cifmw_volume_multiattach_type }}