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

L2SS-983: Partial Ansible Deploy

parent c3039043
No related branches found
No related tags found
1 merge request!469L2SS-983: Deployment through environments and ansible
...@@ -27,5 +27,8 @@ tangostationcontrol/docs/build ...@@ -27,5 +27,8 @@ tangostationcontrol/docs/build
**/pending_log_messages.db **/pending_log_messages.db
**/.eggs **/.eggs
deploy/*.retry
deploy/hosts
docker-compose/alerta-web/alerta-secrets.json docker-compose/alerta-web/alerta-secrets.json
docker-compose/tmp docker-compose/tmp
...@@ -668,14 +668,28 @@ stages: ...@@ -668,14 +668,28 @@ stages:
rules: rules:
# - 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:
# Use Gitlab protected variable to provide key
- echo "$DEPLOY_KEY" > id_rsa
- chmod 400 id_rsa
- ssh-keygen -y -f id_rsa > id_rsa.pub
# 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 .
script: script:
- echo "start" - echo "Deploying version $CI_COMMIT_TAG"
- echo "ssh $DEPLOY_USER @ $DEPLOY_HOST" - cd deploy || exit 1
- 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
.deploy_l2ts_base: .deploy_l2ts_base:
extends: .base_deploy extends: .base_deploy
variables: variables:
DEPLOY_USER: $L2TS_USERNAME DEPLOY_USER: $L2TS_USERNAME
DEPLOY_HOST: $L2TS_HOSTNAME DEPLOY_HOST: $L2TS_HOSTNAME
DEPLOY_KEY: $L2TS_DEPLOY_KEY
deploy_l2ts_stop: deploy_l2ts_stop:
extends: .deploy_l2ts_base extends: .deploy_l2ts_base
environment: environment:
......
[defaults]
host_key_checking = False
inventory = hosts
---
- name: StationControl Early Deployment
hosts: all
tasks:
- name: Register git installation status
command: which git
changed_when: false
failed_when: git_installed.rc not in [0,1]
register: git_installed
- name: Register tango directory status
shell: cd ~/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=$?
echo $ret
if [ $ret -eq 0 ]; then
exit 1
fi
exit 0
args:
chdir: ~/tango
register: pending_changes
- name: Check git installation status
fail:
msg: "Git does not appear to be installed!"
when: git_installed.rc not in [0]
- name: Check tango directory status
fail:
msg: "Tango directory appears to be missing!"
when: tango_directory.rc not in [0]
- name: Check pending changes
fail:
msg: "Deployment repository seems to have pending changes!"
when: pending_changes not in [0]
- name: Update sources
changed_when: false
shell: "git checkout v{{ station_version }}"
args:
chdir: ~/tango
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment