Skip to content

Commit fcdce1b

Browse files
committed
Safely expand ansible-runner settings defaults
Set the runner defaults in the entrypoint before running envsubst so settings expansion avoids eval while preserving the existing fallback values. jira: OSPRH-32790 Signed-off-by: rabi <ramishra@redhat.com>
1 parent 8a04184 commit fcdce1b

2 files changed

Lines changed: 29 additions & 9 deletions

File tree

openstack_ansibleee/edpm_entrypoint.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
#!/usr/bin/env bash
22

33
# Adding edpm ansible-runner specific scripts here
4+
# Set defaults before expanding the settings template.
5+
: "${RUNNER_IDLE_TIMEOUT:=600}"
6+
: "${RUNNER_JOB_TIMEOUT:=3600}"
7+
: "${RUNNER_PEXPECT_TIMEOUT:=10}"
8+
: "${RUNNER_PEXPECT_USE_POLL:=True}"
9+
: "${RUNNER_SUPPRESS_OUTPUT_FILE:=False}"
10+
: "${RUNNER_SUPPRESS_ANSIBLE_OUTPUT:=False}"
11+
: "${RUNNER_FACT_CACHE:=fact_cache}"
12+
: "${RUNNER_FACT_CACHE_TYPE:=jsonfile}"
13+
14+
export \
15+
RUNNER_IDLE_TIMEOUT \
16+
RUNNER_JOB_TIMEOUT \
17+
RUNNER_PEXPECT_TIMEOUT \
18+
RUNNER_PEXPECT_USE_POLL \
19+
RUNNER_SUPPRESS_OUTPUT_FILE \
20+
RUNNER_SUPPRESS_ANSIBLE_OUTPUT \
21+
RUNNER_FACT_CACHE \
22+
RUNNER_FACT_CACHE_TYPE
23+
424
# Expand the variables
5-
eval "echo \"$(cat /runner/env/settings)\"" > /runner/env/settings
25+
envsubst < /runner/env/settings > /runner/env/settings.tmp && mv /runner/env/settings.tmp /runner/env/settings
626

727
if [ -n "$RUNNER_INVENTORY" ]; then
828
echo "---" > /runner/inventory/inventory.yaml

openstack_ansibleee/settings

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
# If no output is detected from ansible in this number of seconds the execution will
22
# be terminated.
3-
idle_timeout: ${RUNNER_IDLE_TIMEOUT:-600}
3+
idle_timeout: ${RUNNER_IDLE_TIMEOUT}
44
# The maximum amount of time to allow the job to run for, exceeding this and the
55
# execution will be terminated.
6-
job_timeout: ${RUNNER_JOB_TIMEOUT:-3600}
6+
job_timeout: ${RUNNER_JOB_TIMEOUT}
77

88
# Number of seconds for the internal pexpect command to wait to block on
99
# input before continuing.
10-
pexpect_timeout: ${RUNNER_PEXPECT_TIMEOUT:-10}
10+
pexpect_timeout: ${RUNNER_PEXPECT_TIMEOUT}
1111
# Use poll() function for communication with child processes instead of select().
1212
# select() is used when the value is set to False. select() has a known limitation of
1313
# using only up to 1024 file descriptors.
14-
pexpect_use_poll: ${RUNNER_PEXPECT_USE_POLL:-True}
14+
pexpect_use_poll: ${RUNNER_PEXPECT_USE_POLL}
1515

1616
# Allow output from ansible to not be streamed to the stdout or stderr files inside
1717
# of the artifacts directory.
18-
suppress_output_file: ${RUNNER_SUPPRESS_OUTPUT_FILE:-False}
18+
suppress_output_file: ${RUNNER_SUPPRESS_OUTPUT_FILE}
1919
# Allow output from ansible to not be printed to the screen.
20-
suppress_ansible_output: ${RUNNER_SUPPRESS_ANSIBLE_OUTPUT:-False}
20+
suppress_ansible_output: ${RUNNER_SUPPRESS_ANSIBLE_OUTPUT}
2121

2222
# The directory relative to artifacts where jsonfile fact caching will be stored.
2323
# Defaults to fact_cache. This is ignored if fact_cache_type is different than jsonfile.
24-
fact_cache: ${RUNNER_FACT_CACHE:-'fact_cache'}
24+
fact_cache: ${RUNNER_FACT_CACHE}
2525
# The type of fact cache to use. Defaults to jsonfile.
26-
fact_cache_type: ${RUNNER_FACT_CACHE_TYPE:-'jsonfile'}
26+
fact_cache_type: ${RUNNER_FACT_CACHE_TYPE}

0 commit comments

Comments
 (0)