From dba26456f48e82889bf63b425c27a79f710e07cf Mon Sep 17 00:00:00 2001
From: Benjamin Bertrand <benjamin.bertrand@esss.se>
Date: Thu, 15 Feb 2018 14:18:55 +0100
Subject: [PATCH] Use tower-cli to trigger Ansible job

tower-cli easily allows to:
- pass extra variables to the job
- wait for the job to complete

Deploy to staging on tags as well.
---
 .gitlab-ci.yml | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0620ba3..2dcd8d0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -53,17 +53,22 @@ release-image:
 deploy-staging:
   <<: *runner_tags
   stage: deploy
-  before_script:
-    - apk add --update curl
-    - curl -s -o /tmp/functions.sh ${ICS_SHARED_GITLAB_CI_FUNCTIONS}
-    - . /tmp/functions.sh
+  image: registry.esss.lu.se/ics-docker/tower-cli:3.2
+  before_script: []
   script:
-    - launch_job_template deploy-csentry-staging
+    - >
+      tower-cli job launch
+      -h icsv-awx01.esss.lu.se
+      -u ${ANSIBLE_AWX_USERNAME}
+      -p ${ANSIBLE_AWX_PASSWORD}
+      -J deploy-csentry-staging
+      -e "csentry_tag=$CI_COMMIT_REF_NAME" --monitor
   environment:
     name: staging
     url: https://csentry-test.esss.lu.se
   only:
     - master
+    - tags
 
 pages:
   <<: *runner_tags
-- 
GitLab