Skip to content
Snippets Groups Projects
Commit ac4ec956 authored by Temur Maisuradze's avatar Temur Maisuradze
Browse files

start stop restart and update scripts for haproxy

parent 205afeac
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,9 @@ To update configuration files for all docker containers together, run the follow
To update configuration files only for specific services, run the following commands:
ansible-playbook -i inventories soctools.yml -t update-keycloak-config
ansible-playbook -i inventories soctools.yml -t update-thehive-config
ansible-playbook -i inventories soctools.yml -t update-cortex-config
ansible-playbook -i inventories soctools.yml -t update-cassandra-config
ansible-playbook -i inventories soctools.yml -t update-haproxy-config
Restart services inside docker containers using Ansible
......@@ -29,6 +32,9 @@ To restart services for all docker containers together, run the following comman
To restart services only for specific docker containers, run the following commands:
ansible-playbook -i inventories soctools.yml -t restart-keycloak
ansible-playbook -i inventories soctools.yml -t restart-thehive
ansible-playbook -i inventories soctools.yml -t restart-cortex
ansible-playbook -i inventories soctools.yml -t restart-cassandra
ansible-playbook -i inventories soctools.yml -t restart-haproxy
Stop services inside docker containers using Ansible
----------------------------------------------------
......@@ -37,6 +43,9 @@ To stop services for all docker containers together, run the following command:
To stop services only for specific docker containers, run the following commands:
ansible-playbook -i inventories soctools.yml -t stop-keycloak
ansible-playbook -i inventories soctools.yml -t stop-thehive
ansible-playbook -i inventories soctools.yml -t stop-cortex
ansible-playbook -i inventories soctools.yml -t stop-cassandra
ansible-playbook -i inventories soctools.yml -t stop-haproxy
Restart services inside docker containers manually
--------------------------------------------------
......
......@@ -25,6 +25,7 @@ RUN \
pcre2-devel \
daemonize \
supervisor \
rsync \
pth-devel && \
`# Install newest openssl...` \
wget -O /tmp/openssl.tgz https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz && \
......
---
# tasks file for haproxy
- name: Copy haproxy configuration file
template:
src: haproxy.cfg.j2
dest: /usr/local/etc/haproxy/haproxy.cfg
- include: start.yml
tags:
- start
- name: Create required directories
file:
path: "{{ item }}"
state: directory
mode: 0755
owner: root
group: root
with_items:
- /opt/haproxy
- /etc/ssl/haproxy
tags:
- start
- name: Generate dhparam file for haproxy
shell: "openssl dhparam -out /usr/local/etc/haproxy/dhparam.pem 2048"
tags:
- start
- name: Copy haproxy certificates
copy:
src: "{{ item }}"
dest: "/opt/haproxy/{{ item }}"
mode: 0600
with_items:
- "{{ inventory_hostname }}.crt"
- "{{ inventory_hostname }}.key"
tags:
- start
- name: Combine crt and key for haproxy
assemble:
src: /opt/haproxy
dest: /etc/ssl/haproxy/{{ inventory_hostname }}.crt
owner: root
mode: 0600
- start
- include: stop.yml
tags:
- start
- name: Delete temporary files and directory
file:
path: "{{ item }}"
state: absent
with_items:
- /opt/haproxy/{{ inventory_hostname }}.crt
- /opt/haproxy/{{ inventory_hostname }}.key
- /opt/haproxy
tags:
- start
- name: Start haproxy
shell: "supervisorctl start haproxy"
- stop
- stop-haproxy
- include: update-config.yml
tags:
- start
- name: Set Autostart for supervisord's services
shell: "sed -i 's/autostart=false/autostart=true/g' /etc/supervisord.conf"
- update-config
- update-haproxy-config
- include: restart.yml
tags:
- start
- name: Stop haproxy
command: "supervisorctl stop haproxy"
tags:
- stop
- restart
- restart-haproxy
---
# tasks file for haproxy
- name: Restart haproxy
shell: "supervisorctl restart haproxy"
---
# tasks file for haproxy
- name: Copy haproxy configuration file
template:
src: haproxy.cfg.j2
dest: /usr/local/etc/haproxy/haproxy.cfg
- name: Create required directories
file:
path: "{{ item }}"
state: directory
mode: 0755
owner: root
group: root
with_items:
- /opt/haproxy
- /etc/ssl/haproxy
- name: Generate dhparam file for haproxy
shell: "openssl dhparam -out /usr/local/etc/haproxy/dhparam.pem 2048"
- name: Copy haproxy certificates
copy:
src: "{{ item }}"
dest: "/opt/haproxy/{{ item }}"
mode: 0600
with_items:
- "{{ inventory_hostname }}.crt"
- "{{ inventory_hostname }}.key"
- name: Combine crt and key for haproxy
assemble:
src: /opt/haproxy
dest: /etc/ssl/haproxy/{{ inventory_hostname }}.crt
owner: root
mode: 0600
- name: Delete temporary files and directory
file:
path: "{{ item }}"
state: absent
with_items:
- /opt/haproxy/{{ inventory_hostname }}.crt
- /opt/haproxy/{{ inventory_hostname }}.key
- /opt/haproxy
- name: Start haproxy
shell: "supervisorctl start haproxy"
- name: Set Autostart for supervisord's services
replace:
path: /etc/supervisord.conf
regexp: '^autostart=false$'
replace: 'autostart=true'
---
# tasks file for haproxy
- name: Stop haproxy
command: "supervisorctl stop haproxy"
---
# tasks file for haproxy
- name: Copy haproxy configuration file
template:
src: haproxy.cfg.j2
dest: /usr/local/etc/haproxy/haproxy.cfg
......@@ -6,12 +6,12 @@
- name: Stop soctools cluster
import_playbook: stopsoctools.yml
when: "'stop' in ansible_run_tags or 'stop-thehive' in ansible_run_tags or 'stop-keycloak' in ansible_run_tags"
when: "'stop' in ansible_run_tags or 'stop-thehive' in ansible_run_tags or 'stop-keycloak' in ansible_run_tags or 'stop-cortex' in ansible_run_tags or 'stop-haproxy' in ansible_run_tags or 'stop-cassandra' in ansible_run_tags"
- name: Update soctools cluster configs
import_playbook: update-config-soctools.yml
when: "'update-config' in ansible_run_tags or 'update-keycloak-config' in ansible_run_tags or 'update-thehive-config' in ansible_run_tags"
when: "'update-config' in ansible_run_tags or 'update-keycloak-config' in ansible_run_tags or 'update-thehive-config' in ansible_run_tags or 'update-cortex-config' in ansible_run_tags or 'update-haproxy-config' in ansible_run_tags or 'update-cassandra-config' in ansible_run_tags"
- name: restart soctools cluster servics
import_playbook: restart-soctools.yml
when: "'restart' in ansible_run_tags or 'restart-thehive' in ansible_run_tags or 'restart-keycloak' in ansible_run_tags"
when: "'restart' in ansible_run_tags or 'restart-thehive' in ansible_run_tags or 'restart-keycloak' in ansible_run_tags or 'restart-cortex' in ansible_run_tags or 'restart-haproxy' in ansible_run_tags or 'restart-cassandra' in ansible_run_tags"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment