Skip to content
Snippets Groups Projects
Commit 90b5fa5b authored by Corné Lukken's avatar Corné Lukken
Browse files

L2SS-983: Install ansible in gitlab-ci

parent 0c6d815e
No related branches found
No related tags found
1 merge request!469L2SS-983: Deployment through environments and ansible
......@@ -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:
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment