From 7cff418410a4b6bf993c75b8d5eb80e4b6b2c06c Mon Sep 17 00:00:00 2001 From: Sven Ketelsen Date: Tue, 29 Mar 2022 16:54:02 +0200 Subject: [PATCH] chore: dry pattern --- .gitlab-ci.yml | 56 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 925eb41..87dd126 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -57,18 +57,6 @@ builder-job: .run-ansible: image: $AWX_EE_DOCKER_IMAGE_EXTERN:latest - script: - - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' - - eval $(ssh-agent -s) - - 'echo "$GITLAB_SSH_KEY" | tr -d "\r" | ssh-add -' - - mkdir -p ~/.ssh - - chmod 0700 ~/.ssh - - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config' - - ssh-add -L - - echo "${ANSIBLE_VAULT_PASS_DEV}" > /tmp/vault-pass - - export HETZNER_LABEL_SELECTOR="stage=${STAGE}" - after_script: - - rm /tmp/vault-pass tags: - dind - harbor # 05.02.22 TODO some runners run into timeouts @@ -89,7 +77,18 @@ builder-job: extends: .run-ansible stage: run-setup script: + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - 'echo "$GITLAB_SSH_KEY" | tr -d "\r" | ssh-add -' + - mkdir -p ~/.ssh + - chmod 0700 ~/.ssh + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config' + - ssh-add -L + - echo "${ANSIBLE_VAULT_PASS_DEV}" > /tmp/vault-pass + - export HETZNER_LABEL_SELECTOR="stage=${STAGE}" - ansible-playbook -i stage-${STAGE}-netgo-hcloud.yml setup.yml --vault-password-file /tmp/vault-pass -t common -u gitlabci + after_script: + - rm /tmp/vault-pass run-kubernetes-dev: extends: .run-setup @@ -134,7 +133,18 @@ run-kubernetes-prodnso: extends: .run-ansible stage: run-kubernetes script: + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - 'echo "$GITLAB_SSH_KEY" | tr -d "\r" | ssh-add -' + - mkdir -p ~/.ssh + - chmod 0700 ~/.ssh + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config' + - ssh-add -L + - echo "${ANSIBLE_VAULT_PASS_DEV}" > /tmp/vault-pass + - export HETZNER_LABEL_SELECTOR="stage=${STAGE}" - ansible-playbook -i stage-${STAGE}-netgo-hcloud.yml kubernetes.yml --vault-password-file /tmp/vault-pass -u gitlabci + after_script: + - rm /tmp/vault-pass run-kubernetes-dev: extends: .run-kubernetes @@ -179,7 +189,18 @@ run-kubernetes-prodnso: extends: .run-ansible stage: run-management-update script: + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - 'echo "$GITLAB_SSH_KEY" | tr -d "\r" | ssh-add -' + - mkdir -p ~/.ssh + - chmod 0700 ~/.ssh + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config' + - ssh-add -L + - echo "${ANSIBLE_VAULT_PASS_DEV}" > /tmp/vault-pass + - export HETZNER_LABEL_SELECTOR="stage=${STAGE}" - ansible-playbook -i stage-$STAGE smardigo.yml --vault-password-file=/tmp/vault-pass -l management -t update_configurations -u gitlabci + after_script: + - rm /tmp/vault-pass only: changes: - smardigo/**/* @@ -227,7 +248,18 @@ run-management-update-prodnso: extends: .run-ansible stage: run-patchday script: + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - 'echo "$GITLAB_SSH_KEY" | tr -d "\r" | ssh-add -' + - mkdir -p ~/.ssh + - chmod 0700 ~/.ssh + - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config' + - ssh-add -L + - echo "${ANSIBLE_VAULT_PASS_DEV}" > /tmp/vault-pass + - export HETZNER_LABEL_SELECTOR="stage=${STAGE}" - ansible-playbook -i stage-${STAGE}-netgo-hcloud.yml patchday.yml patchday.yml --vault-password-file=/tmp/vault-pass -u gitlabci + after_script: + - rm /tmp/vault-pass when: manual run-patchday-dev: