From e92ab898c1b2d75ba0907de3d83d70926b936c30 Mon Sep 17 00:00:00 2001 From: Carlos Konstanski Date: Thu, 26 Oct 2017 13:03:27 -0600 Subject: write a playbook for shutting down and starting up Openbook Closes-Bug: IS-25 --- salt/openbook/ansible/files/openbook.yaml | 2 +- .../ansible/files/openbook_stop_start.yaml | 10 ++++++++ .../ansible/files/stop_start_openbook.yaml | 28 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 salt/openbook/ansible/files/openbook_stop_start.yaml create mode 100644 salt/openbook/ansible/files/stop_start_openbook.yaml (limited to 'salt/openbook') diff --git a/salt/openbook/ansible/files/openbook.yaml b/salt/openbook/ansible/files/openbook.yaml index 81addbd..b6f4c21 100644 --- a/salt/openbook/ansible/files/openbook.yaml +++ b/salt/openbook/ansible/files/openbook.yaml @@ -162,7 +162,7 @@ shell: | /etc/init.d/openbook stop for cont in $(docker ps | grep -v 'COMMAND' | awk '{print $1}'); do - docker stop $cont + docker stop ${cont} done docker container prune -f diff --git a/salt/openbook/ansible/files/openbook_stop_start.yaml b/salt/openbook/ansible/files/openbook_stop_start.yaml new file mode 100644 index 0000000..045f7a9 --- /dev/null +++ b/salt/openbook/ansible/files/openbook_stop_start.yaml @@ -0,0 +1,10 @@ +--- +### +# Use this paybook to stop, start and restart openbook cleanly. +# +# Required variables to be passed in the command line via -e: +# action=[stop|start|restart] +### + +- name: "Stop/Start Openbook" + include: playbooks/stop_start_openbook.yaml diff --git a/salt/openbook/ansible/files/stop_start_openbook.yaml b/salt/openbook/ansible/files/stop_start_openbook.yaml new file mode 100644 index 0000000..83c1d57 --- /dev/null +++ b/salt/openbook/ansible/files/stop_start_openbook.yaml @@ -0,0 +1,28 @@ +--- +- 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: "Stop Openbook" + hosts: "{{ groups['target']|sort(reverse=True) }}" + 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 + when: action == "stop" + +- name: "Start Openbook" + hosts: "{{ groups['target']|sort }}" + serial: 1 + tasks: + - name: "Start Openbook" + shell: /etc/init.d/openbook start + when: action == "start" -- cgit v1.3