summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pillar/openbook/ci.sls58
-rw-r--r--salt/openbook/ansible/files/openbook.yaml44
-rw-r--r--salt/openbook/ansible/files/stop_start_openbook.yaml27
-rw-r--r--salt/openbook/ci/files/openbook.gentoo31
-rw-r--r--salt/openbook/ci/files/openbook.gentoo.openrc.debug17
-rw-r--r--salt/openbook/ci/files/openbook.gentoo.openrc.start16
-rw-r--r--salt/openbook/ci/files/openbook.gentoo.systemd.debug10
-rw-r--r--salt/openbook/ci/files/openbook.gentoo.systemd.start10
-rw-r--r--salt/openbook/ci/files/openbook.redhat.debug (renamed from salt/openbook/ci/files/openbook.redhat)6
-rw-r--r--salt/openbook/ci/files/openbook.redhat.start26
-rw-r--r--salt/openbook/ci/files/openbook.ubuntu.debug (renamed from salt/openbook/ci/files/openbook.ubuntu)6
-rw-r--r--salt/openbook/ci/files/openbook.ubuntu.start22
12 files changed, 197 insertions, 76 deletions
diff --git a/pillar/openbook/ci.sls b/pillar/openbook/ci.sls
index 37bf397..becd50c 100644
--- a/pillar/openbook/ci.sls
+++ b/pillar/openbook/ci.sls
@@ -30,27 +30,67 @@ ci:
is_template: False
relative_to_buildroot: True
ansible: True
- openbook_ubuntu:
- name: openbook.ubuntu
+ openbook_ubuntu_start:
+ name: openbook.ubuntu.start
path: .
- source: openbook.ubuntu
+ source: openbook.ubuntu.start
mode: "0755"
is_template: True
relative_to_buildroot: True
ansible: True
- openbook_redhat:
- name: openbook.redhat
+ openbook_ubuntu_debug:
+ name: openbook.ubuntu.debug
path: .
- source: openbook.redhat
+ source: openbook.ubuntu.debug
mode: "0755"
is_template: True
relative_to_buildroot: True
ansible: True
- openbook_gentoo:
- name: openbook.gentoo
+ openbook_redhat_start:
+ name: openbook.redhat.start
path: .
- source: openbook.gentoo
+ source: openbook.redhat.start
mode: "0755"
is_template: True
relative_to_buildroot: True
ansible: True
+ openbook_redhat_debug:
+ name: openbook.redhat.debug
+ path: .
+ source: openbook.redhat.debug
+ mode: "0755"
+ is_template: True
+ relative_to_buildroot: True
+ ansible: True
+ openbook_gentoo_openrc_start:
+ name: openbook.gentoo.openrc.start
+ path: .
+ source: openbook.gentoo.openrc.start
+ mode: "0755"
+ is_template: True
+ relative_to_buildroot: True
+ ansible: True
+ openbook_gentoo_openrc_debug:
+ name: openbook.gentoo.openrc.debug
+ path: .
+ source: openbook.gentoo.openrc.debug
+ mode: "0755"
+ is_template: True
+ relative_to_buildroot: True
+ ansible: True
+ openbook_gentoo_systemd_start:
+ name: openbook.gentoo.systemd.start
+ path: .
+ source: openbook.gentoo.systemd.start
+ mode: "0644"
+ is_template: True
+ relative_to_buildroot: True
+ ansible: True
+ openbook_gentoo_systemd_debug:
+ name: openbook.gentoo.systemd.debug
+ path: .
+ source: openbook.gentoo.systemd.debug
+ mode: "0644"
+ is_template: True
+ relative_to_buildroot: True
+ ansible: True
diff --git a/salt/openbook/ansible/files/openbook.yaml b/salt/openbook/ansible/files/openbook.yaml
index a2d9688..1614194 100644
--- a/salt/openbook/ansible/files/openbook.yaml
+++ b/salt/openbook/ansible/files/openbook.yaml
@@ -117,7 +117,8 @@
owner: root
group: root
with_items:
- - { src: ci/{{ pillar["ci"]["files"]["openbook_ubuntu"]["path"] }}/{{ pillar["ci"]["files"]["openbook_ubuntu"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" }
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_ubuntu_start"]["path"] }}/{{ pillar["ci"]["files"]["openbook_ubuntu_start"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" }
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_ubuntu_debug"]["path"] }}/{{ pillar["ci"]["files"]["openbook_ubuntu_debug"]["name"] }}, dest: /etc/init.d/openbook-debug, mode: "0755" }
when: ansible_distribution == "Ubuntu"
- name: "Create Openbook init script: Redhat"
@@ -128,7 +129,8 @@
owner: root
group: root
with_items:
- - { src: ci/{{ pillar["ci"]["files"]["openbook_redhat"]["path"] }}/{{ pillar["ci"]["files"]["openbook_redhat"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" }
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_redhat_start"]["path"] }}/{{ pillar["ci"]["files"]["openbook_redhat_start"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" }
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_redhat_debug"]["path"] }}/{{ pillar["ci"]["files"]["openbook_redhat_debug"]["name"] }}, dest: /etc/init.d/openbook-debug, mode: "0755" }
when: ansible_distribution == "RedHat" or ansible_distribution == "CentOS"
- name: "Create Openbook init script: Gentoo"
@@ -139,12 +141,25 @@
owner: root
group: root
with_items:
- - { src: ci/{{ pillar["ci"]["files"]["openbook_gentoo"]["path"] }}/{{ pillar["ci"]["files"]["openbook_gentoo"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" }
- when: ansible_distribution == "Gentoo"
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_gentoo_openrc_start"]["path"] }}/{{ pillar["ci"]["files"]["openbook_gentoo_openrc_start"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" }
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_gentoo_openrc_debug"]["path"] }}/{{ pillar["ci"]["files"]["openbook_gentoo_openrc_debug"]["name"] }}, dest: /etc/init.d/openbook-debug, mode: "0755" }
+ when: ansible_distribution == "Gentoo" and ansible_service_mgr == "openrc"
+
+ - name: "Create Openbook systemd scripts: Gentoo"
+ template:
+ src: "../templates/{% raw %}{{ item.src }}{% endraw %}"
+ dest: "{% raw %}{{ item.dest }}{% endraw %}"
+ mode: "{% raw %}{{ item.mode }}{% endraw %}"
+ owner: root
+ group: root
+ with_items:
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_gentoo_systemd_start"]["path"] }}/{{ pillar["ci"]["files"]["openbook_gentoo_systemd_start"]["name"] }}, dest: /etc/systemctl/system/openbook.service, mode: "0644" }
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_gentoo_systemd_debug"]["path"] }}/{{ pillar["ci"]["files"]["openbook_gentoo_systemd_debug"]["name"] }}, dest: /etc/systemctl/system/openbook-debug.service, mode: "0644" }
+ when: ansible_distribution == "Gentoo" and ansible_service_mgr == "systemd"
- name: "Add service script to systemd"
shell: systemctl enable openbook
- when: ansible_distribution == "Ubuntu" or ansible_distribution == "RedHat" or ansible_distribution == "CentOS"
+ when: ansible_distribution == "Ubuntu" or ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or (ansible_distribution == "Gentoo" and ansible_service_mgr == "systemd")
- name: "Enable openbook service"
service:
@@ -165,16 +180,7 @@
when: openbook_install_database|string() == "True"
- name: "Stop Openbook"
- hosts: "{% raw %}{{ groups['target']|sort(reverse=True) }}{% endraw %}"
- serial: 1
- tasks:
- - name: "Stop Openbook"
- shell: |
- /etc/init.d/openbook stop
- for cont in $(docker ps | grep -v 'COMMAND' | awk '{print $1}'); do
- docker stop ${cont}
- done
- docker container prune -f
+ include: stop_start_openbook.yaml action=stop
- name: "Install Openbook"
hosts: target
@@ -216,9 +222,5 @@
executable: /bin/bash
- name: "Start Openbook"
- hosts: "{% raw %}{{ groups['target']|sort }}{% endraw %}"
- serial: 1
- tasks:
- - name: "Start Openbook"
- shell: /etc/init.d/openbook start
- when: openbook_start_app == True
+ include: stop_start_openbook.yaml action=start
+ when: openbook_start_app == True
diff --git a/salt/openbook/ansible/files/stop_start_openbook.yaml b/salt/openbook/ansible/files/stop_start_openbook.yaml
index c34a7ff..abe4be4 100644
--- a/salt/openbook/ansible/files/stop_start_openbook.yaml
+++ b/salt/openbook/ansible/files/stop_start_openbook.yaml
@@ -12,12 +12,23 @@
serial: 1
tasks:
- name: "Stop Openbook"
+ service:
+ name: "{{ item.name }}"
+ state: stopped
+ runlevel: "{{ item.runlevel }}"
+ with_items:
+ - { name: openbook, runlevel: default }
+ - { name: openbook-debug, runlevel: default }
+ ignore_errors: True
+ when: action == "stop"
+
+ - name: "Delete Openbook containers"
shell: |
- /etc/init.d/openbook stop
for cont in $(docker ps | grep -v 'COMMAND' | awk '{print $1}'); do
docker stop ${cont}
done
docker container prune -f
+ ignore_errors: True
when: action in ["stop", "restart"]
- name: "Start Openbook"
@@ -25,9 +36,19 @@
serial: 1
tasks:
- name: "Start Openbook"
- shell: /etc/init.d/openbook start
+ service:
+ name: "{{ item.name }}"
+ state: started
+ runlevel: "{{ item.runlevel }}"
+ with_items:
+ - { name: openbook, runlevel: default }
when: action in ["start", "restart"] and extra_args != "debug"
- name: "Start Openbook in debug mode"
- shell: /etc/init.d/openbook debug
+ service:
+ name: "{{ item.name }}"
+ state: started
+ runlevel: "{{ item.runlevel }}"
+ with_items:
+ - { name: openbook-debug, runlevel: default }
when: action in ["start", "restart"] and extra_args == "debug"
diff --git a/salt/openbook/ci/files/openbook.gentoo b/salt/openbook/ci/files/openbook.gentoo
deleted file mode 100644
index 62dd27a..0000000
--- a/salt/openbook/ci/files/openbook.gentoo
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/sbin/openrc-run
-
-extra_commands="debug test_database"
-
-depend() {
- need docker
-}
-
-start() {
- ebegin "Starting Openbook"
- {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} start
- eend $?
-}
-
-debug() {
- ebegin "Starting Openbook in debug mode"
- {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} debug
- eend $?
-}
-
-stop() {
- ebegin "Stopping Openbook"
- {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} stop
- eend $?
-}
-
-test_database() {
- ebegin "Testing database"
- {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} test_database
- eend $?
-}
diff --git a/salt/openbook/ci/files/openbook.gentoo.openrc.debug b/salt/openbook/ci/files/openbook.gentoo.openrc.debug
new file mode 100644
index 0000000..75d7bc9
--- /dev/null
+++ b/salt/openbook/ci/files/openbook.gentoo.openrc.debug
@@ -0,0 +1,17 @@
+#!/sbin/openrc-run
+
+depend() {
+ need docker
+}
+
+start() {
+ ebegin "Starting Openbook"
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} debug
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping Openbook"
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} stop
+ eend $?
+}
diff --git a/salt/openbook/ci/files/openbook.gentoo.openrc.start b/salt/openbook/ci/files/openbook.gentoo.openrc.start
new file mode 100644
index 0000000..e2ee244
--- /dev/null
+++ b/salt/openbook/ci/files/openbook.gentoo.openrc.start
@@ -0,0 +1,16 @@
+#!/sbin/openrc-run
+
+depend() {
+ need docker
+}
+
+start() {
+ ebegin "Starting Openbook"
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} start
+ eend $?
+}
+stop() {
+ ebegin "Stopping Openbook"
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} stop
+ eend $?
+}
diff --git a/salt/openbook/ci/files/openbook.gentoo.systemd.debug b/salt/openbook/ci/files/openbook.gentoo.systemd.debug
new file mode 100644
index 0000000..69642b7
--- /dev/null
+++ b/salt/openbook/ci/files/openbook.gentoo.systemd.debug
@@ -0,0 +1,10 @@
+[Unit]
+Description=Openbook
+After=network.target nss-lookup.target docker.target
+
+[Service]
+Type=forking
+ExecStart={{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} debug
+
+[Install]
+WantedBy=multi-user.target
diff --git a/salt/openbook/ci/files/openbook.gentoo.systemd.start b/salt/openbook/ci/files/openbook.gentoo.systemd.start
new file mode 100644
index 0000000..35f067a
--- /dev/null
+++ b/salt/openbook/ci/files/openbook.gentoo.systemd.start
@@ -0,0 +1,10 @@
+[Unit]
+Description=Openbook
+After=network.target nss-lookup.target docker.target
+
+[Service]
+Type=forking
+ExecStart={{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} start
+
+[Install]
+WantedBy=multi-user.target
diff --git a/salt/openbook/ci/files/openbook.redhat b/salt/openbook/ci/files/openbook.redhat.debug
index 5f3f934..b91bd94 100644
--- a/salt/openbook/ci/files/openbook.redhat
+++ b/salt/openbook/ci/files/openbook.redhat.debug
@@ -15,17 +15,11 @@
case $1 in
start*)
- {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} start
- ;;
- debug*)
{{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} debug
;;
stop*)
{{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} stop
;;
- test_database*)
- {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} test_database
- ;;
*)
{{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} help
;;
diff --git a/salt/openbook/ci/files/openbook.redhat.start b/salt/openbook/ci/files/openbook.redhat.start
new file mode 100644
index 0000000..d4e4937
--- /dev/null
+++ b/salt/openbook/ci/files/openbook.redhat.start
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# openbook
+#
+# chkconfig: 2345 10 90
+# description: Manage the Openbook application
+#
+### BEGIN INIT INFO
+# Provides: openbook
+# Required-Start: docker
+# Required-Stop: docker
+# Short-Description: Bring up/down networking
+# Description: Manage the Openbook application
+### END INIT INFO
+
+case $1 in
+ start*)
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} start
+ ;;
+ stop*)
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} stop
+ ;;
+ *)
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} help
+ ;;
+esac
diff --git a/salt/openbook/ci/files/openbook.ubuntu b/salt/openbook/ci/files/openbook.ubuntu.debug
index 6c50c76..b99726f 100644
--- a/salt/openbook/ci/files/openbook.ubuntu
+++ b/salt/openbook/ci/files/openbook.ubuntu.debug
@@ -11,17 +11,11 @@
case $1 in
start*)
- {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} start
- ;;
- debug*)
{{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} debug
;;
stop*)
{{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} stop
;;
- test_database*)
- {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} test_database
- ;;
*)
{{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} help
;;
diff --git a/salt/openbook/ci/files/openbook.ubuntu.start b/salt/openbook/ci/files/openbook.ubuntu.start
new file mode 100644
index 0000000..51141e5
--- /dev/null
+++ b/salt/openbook/ci/files/openbook.ubuntu.start
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: openbook
+# Required-Start: docker
+# Required-Stop: docker
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Manage the Openbook application
+### END INIT INFO
+
+case $1 in
+ start*)
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} start
+ ;;
+ stop*)
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} stop
+ ;;
+ *)
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} help
+ ;;
+esac