aboutsummaryrefslogtreecommitdiffhomepage
path: root/files
diff options
context:
space:
mode:
authorGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>2018-02-22 11:53:19 +0100
committerGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>2018-02-22 11:57:08 +0100
commitf7dd5848f817bb42cb06eadc5444ec390aa813ba (patch)
tree7459517d6b8b850959313d5c30f25f18fcda5531 /files
parent4882b0d33ce42a3b01ac9689d1809e362f314d3f (diff)
downloadansible-clever-f7dd5848f817bb42cb06eadc5444ec390aa813ba.tar.gz
ansible-clever-f7dd5848f817bb42cb06eadc5444ec390aa813ba.tar.zst
ansible-clever-f7dd5848f817bb42cb06eadc5444ec390aa813ba.zip
Migrating single tasks file to a galaxy role
Diffstat (limited to 'files')
-rw-r--r--files/clever-set-domain.sh11
-rw-r--r--files/clever-set-drain.sh11
-rw-r--r--files/clever-wait-deploy.sh50
3 files changed, 72 insertions, 0 deletions
diff --git a/files/clever-set-domain.sh b/files/clever-set-domain.sh
new file mode 100644
index 0000000..bf63be0
--- /dev/null
+++ b/files/clever-set-domain.sh
@@ -0,0 +1,11 @@
1#!/bin/bash -e
2
3function checkDomain {
4 clever domain | grep "${DOMAIN}"
5}
6
7function setDomain {
8 clever domain add "${DOMAIN}"
9}
10
11checkDomain || setDomain
diff --git a/files/clever-set-drain.sh b/files/clever-set-drain.sh
new file mode 100644
index 0000000..405cb28
--- /dev/null
+++ b/files/clever-set-drain.sh
@@ -0,0 +1,11 @@
1#!/bin/bash -e
2
3function checkDrain {
4 clever drain | grep "${SYSLOG_UDP_SERVER}"
5}
6
7function setDrain {
8 clever drain create UDPSyslog "udp://${SYSLOG_UDP_SERVER}"
9}
10
11checkDrain || setDrain
diff --git a/files/clever-wait-deploy.sh b/files/clever-wait-deploy.sh
new file mode 100644
index 0000000..99088cc
--- /dev/null
+++ b/files/clever-wait-deploy.sh
@@ -0,0 +1,50 @@
1#!/bin/bash -e
2
3function deploying {
4 checkStatus "$1" "IN PROGRESS"
5}
6
7function deployed {
8 checkStatus "$1" "OK"
9}
10
11function inactive {
12 local commit="$1"
13 [[ "$(clever activity | grep "$commit" | grep "DEPLOY" | wc -l)" == "0" ]]
14}
15
16function checkStatus {
17 local commit="$1"
18 local status="$2"
19 [[ "$(clever activity | grep "$commit" | grep "${status}\s\+DEPLOY" | wc -l)" == "1" ]]
20}
21
22function check {
23 local timeout=600 # 10 minutes
24 local commit="$1"
25 local samplingTime=5
26
27 echo "Waiting for deployment start..."
28 while inactive "$commit" -a $timeout -gt 0
29 do
30 sleep $samplingTime
31 let "timeout-=$samplingTime"
32 done
33
34 # Wait for completion
35 echo "Deployement in progress..."
36 while deploying "$commit" -a $timeout -gt 0
37 do
38 sleep $samplingTime
39 let "timeout-=$samplingTime"
40 done
41
42 if [ $samplingTime -eq 0 ]
43 then
44 echo "Timeout"
45 fi
46
47 deployed "$commit"
48}
49
50check "$(git rev-parse HEAD)"