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