Merge "[FFU] Hook to allow user to pass a custom script for repo switching."

This commit is contained in:
Zuul 2018-03-21 14:40:16 +00:00 committed by Gerrit Code Review
commit 51537c0e4b
2 changed files with 65 additions and 0 deletions

View File

@ -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'

View File

@ -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