Skip to content
Snippets Groups Projects
Verified Commit 89ff4ba9 authored by Maarten de Waard's avatar Maarten de Waard :angel:
Browse files

move helmfile related things to its own GitLab CI stage

parent 8ab92b22
No related branches found
No related tags found
No related merge requests found
stages:
- build
- deploy
- setup-cluster
- install-apps
- test
- e2e-test
- cleanup
......@@ -24,7 +25,7 @@ ci_test_image:
- test/requirements.txt
bootstrap:
stage: deploy
stage: setup-cluster
image: "${CI_REGISTRY_IMAGE}/bootstrap-ci"
script:
# Ensure test/ is not world-writable otherwise ansible-playbook refuses to run, see
......@@ -33,7 +34,7 @@ bootstrap:
- cd test/
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- ANSIBLE_HOST_KEY_CHECKING=False python3 -u ./ci-bootstrap.py --create_droplet
- ANSIBLE_HOST_KEY_CHECKING=False python3 -u ./ci-bootstrap.py --create-droplet --skip-tags helmfile
cache:
key: "$CI_PIPELINE_ID"
paths:
......@@ -45,6 +46,15 @@ bootstrap:
expire_in: 1 month
when: always
install:
stage: install-apps
image: "${CI_REGISTRY_IMAGE}/bootstrap-ci"
script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- cd test/
- ansible-playbook --inventory ./inventory.yml --tags helmfile ./bootstrap.yml
testinfra:
stage: test
image: "${CI_REGISTRY_IMAGE}/bootstrap-ci"
......
......@@ -69,17 +69,17 @@ if __name__ == "__main__":
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'--create_droplet',
'--create-droplet',
action='store_true',
help='Create droplet automatically')
group.add_argument(
'--droplet_id',
'--droplet-id',
metavar='ID',
type=int,
help='ID of droplet to deploy to')
parser.add_argument(
'--ssh_key_id',
'--ssh-key-id',
metavar='ID',
type=int,
default=411,
......@@ -95,6 +95,13 @@ if __name__ == "__main__":
action='store_true',
help='Be more verbose')
parser.add_argument(
'--ansible-param',
metavar=['PARAM[=VALUE]'],
action='append',
nargs=1,
help='forward ansible parameters to the ansible-playbook call (two dashes are prepended to PARAM)')
args = parser.parse_args()
verbose = args.verbose
loglevel = logging.DEBUG if verbose else logging.INFO
......@@ -202,6 +209,14 @@ if __name__ == "__main__":
# https://ansible-runner.readthedocs.io/en/latest/intro.html#inputdir
playbook = './bootstrap.yml'
ansible_playbook_cmd = 'ansible-playbook %s' % playbook
if args.ansible_param:
for param in args.ansible_param:
if len(param) > 1:
log.warning('More than 1 parameter. Ignoring the rest! Use '
'--ansible-param several times to supply '
'more than 1 parameter')
param = param[0]
ansible_playbook_cmd += ' --' + param
log.info('Running %s', ansible_playbook_cmd)
......
......@@ -19,7 +19,7 @@ def request_api(resource: str, request_type: str = 'GET',
if 'COSMOS_API_TOKEN' in os.environ:
api_token = os.environ['COSMOS_API_TOKEN']
else:
raise ValueError('Please export the COSMOS_API_TOKEN'
raise ValueError('Please export the COSMOS_API_TOKEN '
'environment variable.')
headers = {'Content-Type': 'application/json',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment