[fix] Playbook setup bug fixes

* Increase timeout for port check
* Exit with non-zero code in user create script if timeout exceeded or error occurs
This commit is contained in:
William Wernert
2020-12-17 12:23:06 -05:00
parent e0dc6cbb41
commit 1f523deaea
2 changed files with 9 additions and 3 deletions

View File

@@ -8,12 +8,12 @@ include:
wait_for_playbook: wait_for_playbook:
cmd.run: cmd.run:
- name: until nc -z {{ MAINIP }} 3200; do sleep 1; done - name: until nc -z {{ MAINIP }} 3200; do sleep 1; done
- timeout: 30 - timeout: 300
- onchanges:
- cmd: create_user
create_user: create_user:
cmd.script: cmd.script:
- source: salt://playbook/files/automation_user_create.sh - source: salt://playbook/files/automation_user_create.sh
- cwd: /root - cwd: /root
- template: jinja - template: jinja
- onchanges:
- cmd: wait_for_playbook

View File

@@ -2,6 +2,8 @@
# {%- set admin_pass = salt['pillar.get']('secrets:playbook_admin', None) -%} # {%- set admin_pass = salt['pillar.get']('secrets:playbook_admin', None) -%}
# {%- set automation_pass = salt['pillar.get']('secrets:playbook_automation', None) %} # {%- set automation_pass = salt['pillar.get']('secrets:playbook_automation', None) %}
set -e
local_salt_dir=/opt/so/saltstack/local local_salt_dir=/opt/so/saltstack/local
try_count=6 try_count=6
@@ -44,7 +46,11 @@ while [[ $try_count -le 6 ]]; do
echo " api_key: ${automation_api_key}" echo " api_key: ${automation_api_key}"
} >> $local_salt_dir/pillar/global.sls } >> $local_salt_dir/pillar/global.sls
fi fi
exit 0
fi fi
((try_count++)) ((try_count++))
sleep "${interval}s" sleep "${interval}s"
done done
# Timeout exceeded, exit with non-zero exit code
exit 1