diff options
Diffstat (limited to 'salt/openbook/ansible/files')
| -rw-r--r-- | salt/openbook/ansible/files/openbook.yaml | 44 | ||||
| -rw-r--r-- | salt/openbook/ansible/files/stop_start_openbook.yaml | 27 |
2 files changed, 47 insertions, 24 deletions
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" |
