summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jjb/yaml/ob-ctl.yaml60
-rw-r--r--salt/openbook/ansible/files/ob-ctl.sh14
-rw-r--r--salt/openbook/ansible/files/stop_start_openbook.yaml10
3 files changed, 79 insertions, 5 deletions
diff --git a/jjb/yaml/ob-ctl.yaml b/jjb/yaml/ob-ctl.yaml
new file mode 100644
index 0000000..15db290
--- /dev/null
+++ b/jjb/yaml/ob-ctl.yaml
@@ -0,0 +1,60 @@
+---
+- project:
+ name: "ob-ctl"
+ jobs:
+ - "ob-ctl-{branch}-{action}":
+ branch: "unstable"
+ action: "stop"
+ - "ob-ctl-{branch}-{action}":
+ branch: "unstable"
+ action: "start"
+ - "ob-ctl-{branch}-{action}":
+ branch: "unstable"
+ action: "restart"
+ - "ob-ctl-{branch}-{action}":
+ branch: "develop"
+ action: "stop"
+ - "ob-ctl-{branch}-{action}":
+ branch: "develop"
+ action: "start"
+ - "ob-ctl-{branch}-{action}":
+ branch: "develop"
+ action: "restart"
+ - "ob-ctl-{branch}-{action}":
+ branch: "stage"
+ action: "stop"
+ - "ob-ctl-{branch}-{action}":
+ branch: "stage"
+ action: "start"
+ - "ob-ctl-{branch}-{action}":
+ branch: "stage"
+ action: "restart"
+ - "ob-ctl-{branch}-{action}":
+ branch: "master"
+ action: "stop"
+ - "ob-ctl-{branch}-{action}":
+ branch: "master"
+ action: "start"
+ - "ob-ctl-{branch}-{action}":
+ branch: "master"
+ action: "restart"
+
+- job-template:
+ name: "ob-ctl-{branch}-{action}"
+ project-type: freestyle
+ node: openbook_v4
+ properties:
+ - build-discarder:
+ days-to-keep: 0
+ num-to-keep: 1
+ artifact-days-to-keep: 0
+ - build-blocker:
+ use-build-blocker: true
+ blocking-jobs:
+ - ".*ob-pipeline"
+ - "ob-deploy-branch.*"
+ block_level: 'GLOBAL'
+ queue-scanning: 'BUILDABLE'
+ builders:
+ - shell: |
+ ./ob-ctl.sh {branch} {action}
diff --git a/salt/openbook/ansible/files/ob-ctl.sh b/salt/openbook/ansible/files/ob-ctl.sh
new file mode 100644
index 0000000..6a2a108
--- /dev/null
+++ b/salt/openbook/ansible/files/ob-ctl.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+branch="${1}"
+action="${2}"
+buildroot="$(pwd)"
+
+pushd ${buildroot}/conf
+cp ${HOME}/env.yaml.openbook .
+rm -f env.yaml
+ln -s env.yaml.openbook env.yaml
+popd
+pushd ${buildroot}
+ansible-playbook -i inventory_json_${branch}.rb -e "action=${action}" openbook_stop_start.yaml
+popd
diff --git a/salt/openbook/ansible/files/stop_start_openbook.yaml b/salt/openbook/ansible/files/stop_start_openbook.yaml
index 83c1d57..376d1f5 100644
--- a/salt/openbook/ansible/files/stop_start_openbook.yaml
+++ b/salt/openbook/ansible/files/stop_start_openbook.yaml
@@ -2,9 +2,9 @@
- name: "Verify action to take"
hosts: localhost
tasks:
- - name: "Check that -e 'action=[stop|start]' was passed in"
- fail: msg="The variable 'action' was not passed in with a value of 'stop' or 'start' on the command line."
- when: action not in ["stop", "start"]
+ - name: "Check that -e 'action=[stop|start|restart]' was passed in"
+ fail: msg="The variable 'action' was not passed in with a value of 'stop', 'start' or 'restart' on the command line."
+ when: action not in ["stop", "start", "restart"]
- name: "Stop Openbook"
hosts: "{{ groups['target']|sort(reverse=True) }}"
@@ -17,7 +17,7 @@
docker stop ${cont}
done
docker container prune -f
- when: action == "stop"
+ when: action in ["stop", "restart"]
- name: "Start Openbook"
hosts: "{{ groups['target']|sort }}"
@@ -25,4 +25,4 @@
tasks:
- name: "Start Openbook"
shell: /etc/init.d/openbook start
- when: action == "start"
+ when: action in ["start", "restart"]