deploy.py: allow to pull specific branches of playbooks
From problems come issues, from issues come MR and the related branches. When it comes to testing changes before merging, things become quite tedious: we usually edit deploy.py
in order for the built ansible-pull
commands to use the specific branch(es). More than often we forget to comment out the auto_update_deploy_script
call which cancels the previous step.
It would be convenient to allow the deploy.py
script to accept branch pointers.
Proposed solutions
Parameterize branches
Example call:
deploy.py --olip-pre-install-branch=99-some-issue --olip-deploy-branch=123-some-related-issue
This solution requires more argparse
code, such as:
parser.add_argument(
'--olip-pre-intall-branch',
type=str,
default='master',
help="olip-pre-install playbook branch to pull from."
)
Use Env vars
Example call:
OLIP_PRE_INSTALL_BRANCH=99-some-issue OLIP_DEPLOY_BRANCH=123-some-related-issue deploy.py
This solution only implies a bunch of variables declarations, such as:
olip_pre_install_branch = os.environ.get('OLIP_PRE_INSTALL_BRANCH', 'master')
This one has my preference:
- the added code portion is more compact (3 lines instead of 18)
- easy to set within the CI Variables, instead of parsing "something" then build the
deploy.py
command line
Use parameters AND env vars
This is quite a common pattern, where env vars override the defaults, and are in turn superseded by command line arguments.
However my feeling is we don't have any scenario this would be needed - yet. It may be required later when we make use of these vars in some tests, and will be addressed at this point.