diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 166530b609089c4368ff35949e24d081264e968a..37ae15da8b12b848bffe2d557be10a4eb0c0463a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -669,6 +669,8 @@ stages: # - if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) && $CI_COMMIT_TAG - if: $CI_COMMIT_TAG before_script: + - apt-get update + - apt-get install ansible -y # Use Gitlab protected variable to provide key - echo "$DEPLOY_KEY" > id_rsa - chmod 400 id_rsa @@ -676,14 +678,15 @@ stages: # Add ssh key to agent - eval $(ssh-agent) - ssh-add id_rsa - # Prevent error of ansible being run in world writeable directory - - chmod o-w . + - ansible --version script: - echo "Deploying version $CI_COMMIT_TAG" - - cd deploy || exit 1 + - cd deploy + # Prevent error of ansible being run in world writeable directory + - chmod o-w . - echo "[all]" > hosts - echo "stat ansible_host=$DEPLOY_HOST ansible_user=$DEPLOY_USER" >> hosts - - ansible-playbook deploy.yml --extra-vars station_version=$CI_COMMIT_TAG --extra-vars station_config=CS001_ConfigDb.json + - ansible-playbook -v deploy.yml --extra-vars station_version=$CI_COMMIT_TAG --extra-vars station_config=CS001_ConfigDb.json .deploy_l2ts_base: extends: .base_deploy variables: diff --git a/deploy/deploy.yml b/deploy/deploy.yml index e0c5ce6936a98e0995cc38a352caaf7848fa1660..86b6d45891c1e5079fd2aa9b76fc247ab1d99087 100644 --- a/deploy/deploy.yml +++ b/deploy/deploy.yml @@ -13,15 +13,13 @@ failed_when: git_installed.rc not in [0,1] register: git_installed - name: Register tango directory status - shell: cd ~/tango + shell: cd ~/git/tango args: chdir: ~ changed_when: false failed_when: tango_directory.rc not in [0,1] register: tango_directory - name: Register pending changes - changed_when: false - failed_when: pending_changes.rc not in [0,1] shell: | git status | grep Changes ret=$? @@ -31,8 +29,11 @@ fi exit 0 args: - chdir: ~/tango + chdir: ~/git/tango + changed_when: false + failed_when: pending_changes.rc not in [0,1] register: pending_changes + - debug: var=pending_changes - name: Check make installation status fail: msg: "Make does not appear to be installed!" @@ -53,27 +54,32 @@ changed_when: false shell: "make stop" args: - chdir: ~/tango/docker-compose + chdir: ~/git/tango/docker-compose + - name: Git Fetch All + changed_when: false + shell: "git fetch --all" + args: + chdir: ~/git/tango - name: Update Sources changed_when: false shell: "git checkout {{ station_version }}" args: - chdir: ~/tango + chdir: ~/git/tango - name: Pull Images changed_when: false shell: "make pull" args: - chdir: ~/tango/docker-compose + chdir: ~/git/tango/docker-compose - name: Build Images changed_when: false shell: "make build" args: - chdir: ~/tango/docker-compose + chdir: ~/git/tango/docker-compose - name: Start Database changed_when: false shell: "make minimal" args: - chdir: ~/tango/docker-compose + chdir: ~/git/tango/docker-compose - name: Wait for databaseds ansible.builtin.wait_for: port: 10000 @@ -82,14 +88,14 @@ changed_when: false shell: "./sbin/load_ConfigDb.sh CDB/LOFAR_ConfigDb.json" args: - chdir: ~/tango/ + chdir: ~/git/tango/ - name: Update Station Database Config changed_when: false shell: "./sbin/load_ConfigDb.sh CDB/stations/{{ station_config }}" args: - chdir: ~/tango/ + chdir: ~/git/tango/ - name: Start Station changed_when: false shell: "make start" args: - chdir: ~/tango/docker-compose + chdir: ~/git/tango/docker-compose