summaryrefslogtreecommitdiff
path: root/playbooks/stop_start_openbook.yaml
blob: 83c1d5798479b82031b1d0e14ea0ddf5c4ae6588 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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"