From 2587cb4acf44d9b64ff2cabab8b056f66812d45b Mon Sep 17 00:00:00 2001 From: Sofer Athlan-Guyot Date: Wed, 31 Jan 2018 12:43:01 +0100 Subject: [PATCH] [FFU] Hook to allow user to pass a custom script for repo switching. This allow the user to use whatever script is necessary to switch repo in its own infrastructure during fast forward upgrade. Change-Id: Ie74106de7a4d5cd761c2bd836c2aa03efa7ac091 --- puppet/services/tripleo-packages.yaml | 35 +++++++++++++++++++ ...cript-to-switch-repo-a65db91760b46ec2.yaml | 30 ++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 releasenotes/notes/ffu-custom-script-to-switch-repo-a65db91760b46ec2.yaml diff --git a/puppet/services/tripleo-packages.yaml b/puppet/services/tripleo-packages.yaml index 60d1f4ba4d..fe28e11892 100644 --- a/puppet/services/tripleo-packages.yaml +++ b/puppet/services/tripleo-packages.yaml @@ -37,9 +37,20 @@ parameters: FastForwardRepoType: default: 'tripleo-repos' type: string + constraints: + - allowed_values: ['tripleo-repos', 'custom-script'] FastForwardRepoArgs: default: {'tripleo_repos': {'ocata': '-b ocata current', 'pike': '-b pike current', 'queens': '-b queens current'}} type: json + FastForwardCustomRepoScriptContent: + default: | + #!/bin/bash + set -e + echo "If you use FastForwardRepoType 'custom-script' you have to provide the upgrade repo script content." + echo "It will be installed as /root/ffu_upgrade_repo.sh on the node" + echo "and passed the upstream name (ocata, pike, queens) of the release as first argument" + exit 1 + type: string outputs: role_data: @@ -119,6 +130,18 @@ outputs: - step|int == 3 - ffu_packages_apply|bool - fast_forward_repo_type == 'tripleo-repos' + - block: + - name: Create custom Script for upgrading repo. + copy: + dest: /root/ffu_update_repo.sh + content: {get_param: FastForwardCustomRepoScriptContent} + mode: 0700 + - name: Execute custom script for upgrading repo. + shell: "/root/ffu_update_repo.sh {{release}}" + when: + - step|int == 3 + - ffu_packages_apply|bool + - fast_forward_repo_type == 'custom-script' fast_forward_post_upgrade_tasks: - name: Register repo type and args set_fact: @@ -140,3 +163,15 @@ outputs: when: - ffu_packages_apply|bool - fast_forward_repo_type == 'tripleo-repos' + + - block: + - name: Create custom Script for upgrading repo. + copy: + dest: /root/ffu_update_repo.sh + content: {get_param: FastForwardCustomRepoScriptContent} + mode: 0700 + - name: Execute custom script for upgrading repo. + shell: "/root/ffu_update_repo.sh {{release}}" + when: + - ffu_packages_apply|bool + - fast_forward_repo_type == 'custom-script' diff --git a/releasenotes/notes/ffu-custom-script-to-switch-repo-a65db91760b46ec2.yaml b/releasenotes/notes/ffu-custom-script-to-switch-repo-a65db91760b46ec2.yaml new file mode 100644 index 0000000000..c8ee0c1d3f --- /dev/null +++ b/releasenotes/notes/ffu-custom-script-to-switch-repo-a65db91760b46ec2.yaml @@ -0,0 +1,30 @@ +--- +features: + + - | + The user can now use a custom script to switch repo during the + fast forward upgrade. He/She has to set ``FastForwardRepoType`` + to ``custom-script`` and set + ``FastForwardCustomRepoScriptContent`` to a string representing a + shell script. That script will be executed on each node and given + the upstream name of the release as the first argument (ocata, + pike, queens in that order). Here is an example that describes + its interface. + + .. code-block:: bash + + #!/bin/bash + case $1 in + ocata) + curl -o /etc/yum.repos.d/ocata.repo http://somewhere.com/my-Ocata.repo; + yum clean metadata; + pike) + curl -o /etc/yum.repos.d/pike.repo http://somewhere.com/my-Pike.repo; + yum clean metadata; + queens) + curl -o /etc/yum.repos.d/pike.repo http://somewhere.com/my-Queens.repo; + yum clean metadata; + *) + echo "unknown release $1" >&2 + exit 1 + esac