diff --git a/roles/build/templates/thehive/Dockerfile.j2 b/roles/build/templates/thehive/Dockerfile.j2 index d5599c7af533d465888eee5c08b4e3ebce1b5178..870e3ac179c6ee643639f63d0b69eff9ed900f95 100644 --- a/roles/build/templates/thehive/Dockerfile.j2 +++ b/roles/build/templates/thehive/Dockerfile.j2 @@ -1,9 +1,6 @@ FROM {{repo}}/openjdk:{{version}}{{suffix}} USER root -#COPY thehive.repo /etc/yum.repos.d/thehive.repo -#COPY supervisord.conf /etc/supervisord.conf -#COPY start.sh /start.sh RUN echo "[thehive-project]" > /etc/yum.repos.d/thehive.repo && \ echo "enabled=1" >> /etc/yum.repos.d/thehive.repo && \ echo "priority=1" >> /etc/yum.repos.d/thehive.repo && \ @@ -12,7 +9,7 @@ RUN echo "[thehive-project]" > /etc/yum.repos.d/thehive.repo && \ echo "gpgcheck=1" >> /etc/yum.repos.d/thehive.repo && \ yum install -y epel-release && \ rpm --import https://raw.githubusercontent.com/TheHive-Project/TheHive/master/PGP-PUBLIC-KEY && \ - yum install -y thehive4 supervisor daemonize vim net-tools telnet htop && \ + yum install -y thehive4 supervisor daemonize vim net-tools telnet htop rsync && \ mkdir -p /opt/thp_data/files/thehive && \ chown -R thehive:thehive /opt/thp_data/files/thehive && \ mkdir -p /home/thehive && \ @@ -21,5 +18,3 @@ RUN echo "[thehive-project]" > /etc/yum.repos.d/thehive.repo && \ EXPOSE 9000 COPY thehivesupervisord.conf /etc/supervisord.conf ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] -#USER thehive -# ENTRYPOINT ["/start.sh"] diff --git a/roles/build/templates/thehive/start.sh b/roles/build/templates/thehive/start.sh deleted file mode 100644 index fa91e921956d5d2d6fa1be6812a9794071b20965..0000000000000000000000000000000000000000 --- a/roles/build/templates/thehive/start.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -export CASSANDRA_HOME=/usr/share/cassandra -export CASSANDRA_CONF=$CASSANDRA_HOME/conf -export CASSANDRA_INCLUDE=$CASSANDRA_HOME/cassandra.in.sh -log_file=/var/log/cassandra/cassandra.log -pid_file=/var/run/cassandra/cassandra.pid -lock_file=/var/lock/subsys/cassandra -CASSANDRA_PROG=/usr/sbin/cassandra - -$CASSANDRA_PROG -p $pid_file > $log_file 2>&1 diff --git a/roles/build/templates/thehive/supervisord.conf b/roles/build/templates/thehive/supervisord.conf deleted file mode 100644 index d1f405eb91d5bae99af653dae0d5c246ae723f08..0000000000000000000000000000000000000000 --- a/roles/build/templates/thehive/supervisord.conf +++ /dev/null @@ -1,10 +0,0 @@ -[supervisord] -loglevel=debug -nodaemon=true -[program:cassandra] -user=cassandra -directory=/usr/share/cassandra -stdout_logfile=/var/log/cassandra/cassandra.log -redirect_stderr=true -environment=CASSANDRA_HOME="/usr/share/cassandra",CASSANDRA_CONF="/usr/share/cassandra/conf",CASSANDRA_INCLUDE="$CASSANDRA_HOME/cassandra.in.sh" -command=/usr/sbin/cassandra -p /var/run/cassandra/cassandra.pid diff --git a/roles/build/templates/thehive/thehive.repo b/roles/build/templates/thehive/thehive.repo deleted file mode 100644 index ff3806454fc41de2193c94a2a4da095b763d95bf..0000000000000000000000000000000000000000 --- a/roles/build/templates/thehive/thehive.repo +++ /dev/null @@ -1,7 +0,0 @@ -[thehive-project] -enabled=1 -priority=1 -name=TheHive-Project RPM repository -baseurl=http://rpm.thehive-project.org/stable/noarch -gpgcheck=1 - diff --git a/roles/thehive/tasks/main.yml b/roles/thehive/tasks/main.yml index b9ed5b556d84247e796a26e2718a3515312a3a5c..a0f7edf3191254869b03c63056db742bacb7b71e 100644 --- a/roles/thehive/tasks/main.yml +++ b/roles/thehive/tasks/main.yml @@ -1,37 +1,18 @@ --- -- name: Configure TheHive - remote_user: thehive - template: - src: application.conf.j2 - dest: /etc/thehive/application.conf +- include: start.yml tags: - - start - -- name: Start TheHive - remote_user: root - command: "supervisorctl start thehive" + - start +- include: stop.yml tags: - - start - -- name: Wait for TheHive - remote_user: root - wait_for: - host: "{{groups['thehive'][0]}}" - port: 9000 - state: started - delay: 5 + - stop + - stop-thehive +- 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" - tags: - - start - -- name: Stop TheHive - remote_user: root - command: "supervisorctl stop thehive" + - update-config + - update-thehive-config +- include: restart.yml tags: - - stop + - restart + - restart-thehive diff --git a/roles/thehive/tasks/restart.yml b/roles/thehive/tasks/restart.yml new file mode 100644 index 0000000000000000000000000000000000000000..f3b364456e14669dfcbfa61f9ce9a5ff7646c30c --- /dev/null +++ b/roles/thehive/tasks/restart.yml @@ -0,0 +1,13 @@ +--- + +- name: Restart TheHive + remote_user: root + command: "supervisorctl restart thehive" + +- name: Wait for TheHive + remote_user: root + wait_for: + host: "{{groups['thehive'][0]}}" + port: 9000 + state: started + delay: 5 diff --git a/roles/thehive/tasks/start.yml b/roles/thehive/tasks/start.yml new file mode 100644 index 0000000000000000000000000000000000000000..e1766f59bccd2e836a8a0f50f39e6e210da43f7f --- /dev/null +++ b/roles/thehive/tasks/start.yml @@ -0,0 +1,29 @@ +--- + +- name: Configure TheHive + remote_user: thehive + template: + src: application.conf.j2 + dest: /etc/thehive/application.conf + +- name: Start TheHive + remote_user: root + command: "supervisorctl start thehive" + +- name: Wait for TheHive + remote_user: root + wait_for: + host: "{{groups['thehive'][0]}}" + port: 9000 + state: started + delay: 5 + +- name: Set Autostart for supervisord's services + replace: + path: /etc/supervisord.conf + regexp: '^autostart=false$' + replace: 'autostart=true' + +- name: Stop TheHive + remote_user: root + command: "supervisorctl stop thehive" diff --git a/roles/thehive/tasks/stop.yml b/roles/thehive/tasks/stop.yml new file mode 100644 index 0000000000000000000000000000000000000000..87d605a59f69355208b4fe84b707d6b94c478c0c --- /dev/null +++ b/roles/thehive/tasks/stop.yml @@ -0,0 +1,5 @@ +--- + +- name: Stop TheHive + remote_user: root + command: "supervisorctl stop thehive" diff --git a/roles/thehive/tasks/update-config.yml b/roles/thehive/tasks/update-config.yml new file mode 100644 index 0000000000000000000000000000000000000000..7b02823bbe7e65d60fc9352e732800cb4622b365 --- /dev/null +++ b/roles/thehive/tasks/update-config.yml @@ -0,0 +1,7 @@ +--- + +- name: Configure TheHive + remote_user: thehive + template: + src: application.conf.j2 + dest: /etc/thehive/application.conf diff --git a/soctools.yml b/soctools.yml index b798d970dce03e6edda46f5a489dfcf466eb1e23..142b7e51d7771420c3e818ad90aef726683a9546 100644 --- a/soctools.yml +++ b/soctools.yml @@ -6,12 +6,12 @@ - name: Stop soctools cluster import_playbook: stopsoctools.yml - when: "'stop' in ansible_run_tags" + when: "'stop' in ansible_run_tags or 'stop-thehive' in ansible_run_tags or 'stop-keycloak' in ansible_run_tags" - name: Update soctools cluster configs import_playbook: update-config-soctools.yml - when: "'update-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" - name: restart soctools cluster servics import_playbook: restart-soctools.yml - when: "'restart' in ansible_run_tags" + when: "'restart' in ansible_run_tags or 'restart-thehive' in ansible_run_tags or 'restart-keycloak' in ansible_run_tags"