@@ -5,10 +5,12 @@ export CONSUL_PORT={{ consul_api_port }}
55export CONSUL_HOSTNAME={{ consul_host_address }}
66export VAULT_PORT={{ vault_port }}
77
8- {% if ( S3_ACCESS_KEY is not defined or
9- S3_SECRET_KEY is not defined or
10- AWS_ACCESS_KEY is not defined or
11- AWS_SECRET_KEY is not defined ) %}
8+ {% set has_token = ( s3_access_key is defined and
9+ s3_secret_key is defined and
10+ aws_access_key is defined and
11+ aws_secret_key is defined ) %}
12+
13+ {% if not has_token %}
1214# Create directory for env
1315mkdir -p /opt/runnable/dock-init/consul-resources/vault/{{ node_env }}
1416chown ubuntu:ubuntu /opt/runnable/dock-init/consul-resources/vault/{{ node_env }}
@@ -18,9 +20,6 @@ chmod 0711 /opt/runnable/dock-init/consul-resources/vault/{{ node_env }}
1820{% for item in tokens %}
1921echo {{ item.value }} > /opt/runnable/dock-init/consul-resources/vault/{{ node_env }}/{{ item.file_name }}
2022{% endfor %}
21- {% set hasToken = false %}
22- {% else %}
23- {% set hasToken = true %}
2423{% endif %}
2524
2625# Add upstart files for charon and krain
@@ -42,8 +41,8 @@ start amazon-ssm-agent
4241service krain start
4342service charon start
4443{% if not is_dock_pool %}
45- {% if hasToken %}
46- CONSUL_HOSTNAME={{ consul_host_address }} CONSUL_PORT={{ consul_api_port }} VAULT_PORT={{ vault_port }} S3_ACCESS_KEY={{ S3_ACCESS_KEY }} S3_SECRET_KEY={{ S3_SECRET_KEY }} AWS_ACCESS_KEY={{ AWS_ACCESS_KEY }} AWS_SECRET_KEY={{ AWS_SECRET_KEY }} bash /opt/runnable/dock-init/init.sh | tee /var/log/user-script-dock-init.log
44+ {% if has_token %}
45+ CONSUL_HOSTNAME={{ consul_host_address }} CONSUL_PORT={{ consul_api_port }} VAULT_PORT={{ vault_port }} S3_ACCESS_KEY={{ s3_access_key }} S3_SECRET_KEY={{ s3_secret_key }} AWS_ACCESS_KEY={{ aws_access_key }} AWS_SECRET_KEY={{ aws_secret_key }} bash /opt/runnable/dock-init/init.sh | tee /var/log/user-script-dock-init.log
4746{% else %}
4847CONSUL_HOSTNAME={{ consul_host_address }} CONSUL_PORT={{ consul_api_port }} VAULT_PORT={{ vault_port }} bash /opt/runnable/dock-init/init.sh | tee /var/log/user-script-dock-init.log
4948{% endif %}
0 commit comments