tripleo-quickstart-extras/roles/overcloud-prep-config/templates/overcloud-custom-tht-script...

72 lines
2.8 KiB
Django/Jinja

#!/bin/bash
set -eux
### --start_docs
## --------------------------------------------------
## Checkout custom tripleo heat templates
## --------------------------------------------------
## ########################
## Prepare Your Environment
## ########################
{% if overcloud_templates_repo is defined and overcloud_templates_path is defined %}
## * Clone the t-h-t templates if needed.
## ::
rm -rf {{ overcloud_templates_path }}
git clone {% if overcloud_templates_branch is defined %}-b {{ overcloud_templates_branch }} \
--single-branch{% endif %} {{ overcloud_templates_repo }} {{ overcloud_templates_path }}
{% if overcloud_templates_refspec is defined %}
## * Checkout an open t-h-t review if specified
## (this will stomp on the overcloud_templates_branch, so only one should be used).
## ::
pushd {{overcloud_templates_path}}
git fetch {{ overcloud_templates_repo }} {{ overcloud_templates_refspec }} && git checkout FETCH_HEAD
popd
{% endif %}
{% if not composable_scenario|trim == '' %}
## * If desired composable scenario isn't present in the checked-out
## code, but is present in RPM, copy the scenario from RPM location.
## ::
if [ ! -e "{{ overcloud_templates_path }}/ci/environments/{{ composable_scenario }}" \
-a -e "/usr/share/openstack-tripleo-heat-templates/ci/environments/{{ composable_scenario }}" ]; then
cp "/usr/share/openstack-tripleo-heat-templates/ci/environments/{{ composable_scenario }}" \
"{{ overcloud_templates_path }}/ci/environments/{{ composable_scenario }}"
fi
{% endif %}
{% if not upgrade_composable_scenario|trim == '' %}
if [ ! -e "{{ overcloud_templates_path }}/ci/environments/{{ upgrade_composable_scenario }}" \
-a -e "/usr/share/openstack-tripleo-heat-templates/ci/environments/{{ upgrade_composable_scenario }}" ]; then
cp "/usr/share/openstack-tripleo-heat-templates/ci/environments/{{ upgrade_composable_scenario }}" \
"{{ overcloud_templates_path }}/ci/environments/{{ upgrade_composable_scenario }}"
fi
{% endif %}
{% endif %}
{% if download_overcloud_templates_rpm is defined and overcloud_templates_path is defined %}
## * Download the t-h-t package.
## ::
rm -rf downloaded-tht-rpm
rm -rf {{ overcloud_templates_path }}
mkdir {{ working_dir }}/downloaded-tht-rpm
pushd {{ working_dir }}/downloaded-tht-rpm
tht_rpm_name=$(curl {{ tht_rpm_url }} | grep "openstack-tripleo-heat-templates" | grep "noarch.rpm" | grep -v "tripleo-heat-templates-compat" | sed "s/^.*>openstack-tripleo-heat-templates/openstack-tripleo-heat-templates/" | cut -d "<" -f1)
curl -o {{ working_dir }}/downloaded-tht-rpm/$tht_rpm_name {{ tht_rpm_url }}/$tht_rpm_name
## * Unpack tht sources
## ::
rpm2cpio $(ls -1 *.rpm | grep $tht_rpm_name) | cpio -ivdm
cp -R usr/share/openstack-tripleo-heat-templates {{ overcloud_templates_path }}
popd
{% endif %}
### --stop_docs