From a60418e6dbc1f3707092f5cb45e8b6afa206ac82 Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Mon, 31 Mar 2025 11:34:22 +0200 Subject: [PATCH] feat: add gitigore file --- .gitignore | 1 + .gitlab/deployment.yaml | 34 +++++++++++----------------------- 2 files changed, 12 insertions(+), 23 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..904cae8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.ansible diff --git a/.gitlab/deployment.yaml b/.gitlab/deployment.yaml index 0d7226d..84dec1b 100644 --- a/.gitlab/deployment.yaml +++ b/.gitlab/deployment.yaml @@ -1,5 +1,4 @@ --- - # deploy ansible/roles/common code deployment: stage: "deployment" @@ -9,35 +8,24 @@ deployment: rules: # run only on push to default branch - - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + - if: + '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == + $CI_DEFAULT_BRANCH' - when: "never" # prepare ssh before_script: - # prepare ssh - | - # prepare ssh - mkdir -p ~/.ssh - chmod 700 ~/.ssh - echo "$SSH_CONFIG" > ~/.ssh/config - echo "$SSH_DEPLOYMENT_KEY" > ~/.ssh/id_ed25519 - chmod 600 ~/.ssh/id_ed25519 + # prepare ssh + mkdir -p ~/.ssh + chmod 700 ~/.ssh + echo "$SSH_CONFIG" > ~/.ssh/config + echo "$SSH_DEPLOYMENT_KEY" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 # deployment commands script: - - | - # git cleanup - ssh $SSH_DEPLOYMENT_USER@$ANSIBLE_SERVER "sudo /usr/bin/git -C /etc/ansible/roles/common reset --hard HEAD --quiet" - ssh $SSH_DEPLOYMENT_USER@$ANSIBLE_SERVER "sudo /usr/bin/git -C /etc/ansible/roles/common clean -fx" - ssh $SSH_DEPLOYMENT_USER@$ANSIBLE_SERVER "sudo /usr/bin/git -C /etc/ansible/roles/common clean -fd" - - - | - # print deployment details - ssh $SSH_DEPLOYMENT_USER@$ANSIBLE_SERVER "echo Deploying commit id $CI_COMMIT_SHORT_SHA with message: $CI_COMMIT_MESSAGE" - - - | - # download deployment - ssh $SSH_DEPLOYMENT_USER@$ANSIBLE_SERVER "sudo /usr/bin/git -C /etc/ansible/roles/common fetch --quiet" - ssh $SSH_DEPLOYMENT_USER@$ANSIBLE_SERVER "sudo /usr/bin/git -C /etc/ansible/roles/common checkout $CI_COMMIT_SHORT_SHA --quiet" + # install ansible roles dependancies + ssh $SSH_DEPLOYMENT_USER@$ANSIBLE_SERVER "sudo /usr/local/bin/ansible-galaxy install -r /etc/ansible/roles/requirements.yaml"