From baf5be1a3a6cffc37d3a99d63c6cd75beb12cc45 Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Wed, 23 Dec 2020 20:14:46 -0500 Subject: [PATCH] Return adequate exit code when init fails; Logs output of init scripts for troubleshooting failed installations --- salt/thehive/init.sls | 4 ++-- salt/thehive/scripts/cortex_init | 6 ++++-- salt/thehive/scripts/hive_init | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/salt/thehive/init.sls b/salt/thehive/init.sls index c89017dda..6c3d4d5ac 100644 --- a/salt/thehive/init.sls +++ b/salt/thehive/init.sls @@ -123,7 +123,7 @@ cortexscript: - source: salt://thehive/scripts/cortex_init - cwd: /opt/so - template: jinja - - hide_output: True + - hide_output: False so-thehive: docker_container.running: @@ -148,7 +148,7 @@ thehivescript: - source: salt://thehive/scripts/hive_init - cwd: /opt/so - template: jinja - - hide_output: True + - hide_output: False {% else %} diff --git a/salt/thehive/scripts/cortex_init b/salt/thehive/scripts/cortex_init index e7f78400e..a7f7f2727 100644 --- a/salt/thehive/scripts/cortex_init +++ b/salt/thehive/scripts/cortex_init @@ -58,6 +58,7 @@ cortex_init(){ touch /opt/so/state/cortex.txt else echo "We experienced an issue connecting to Cortex!" + exit 1 fi } @@ -65,10 +66,11 @@ if [ -f /opt/so/state/cortex.txt ]; then cortex_clean exit 0 else - if wait_for_web_response http://{{MANAGERIP}}:9400 '"status":"green"'; then + if wait_for_web_response http://{{MANAGERIP}}:9400/_cluster/health '"status":"green"'; then cortex_init cortex_clean else - echo "TheHive Elasticsearch server is not ready; unable to proceed with cortex init." + echo "TheHive Elasticsearch server is not ready; unable to proceed with Cortex init." + exit 1 fi fi diff --git a/salt/thehive/scripts/hive_init b/salt/thehive/scripts/hive_init index 70b770a1c..855d0d4f6 100755 --- a/salt/thehive/scripts/hive_init +++ b/salt/thehive/scripts/hive_init @@ -36,6 +36,7 @@ thehive_init(){ touch /opt/so/state/thehive.txt else echo "We experienced an issue connecting to TheHive!" + exit 1 fi } @@ -43,10 +44,11 @@ if [ -f /opt/so/state/thehive.txt ]; then thehive_clean exit 0 else - if wait_for_web_response http://{{MANAGERIP}}:9400 '"status":"green"'; then + if wait_for_web_response http://{{MANAGERIP}}:9400/_cluster/health '"status":"green"'; then thehive_init thehive_clean else - echo "TheHive Elasticsearch server is not ready; unable to proceed with hive init." + echo "TheHive Elasticsearch server is not ready; unable to proceed with TheHive init." + exit 1 fi fi