Skip to content

Commit f8368f0

Browse files
committed
Clean up output of puppet_runonce task
- Do not use color codes, as this makes the output difficult to read when returned by Bolt. - Do not print <space><newline>, since this combination will prevent Ruby's yaml emitter from using the block form (which is easier to read when newlines are involved). This doesn't have an immediate impact since we will be seeing the error in JSON, probably, but it potentially heads off confusion in the future if we choose to emit yaml instead.
1 parent c9f86fc commit f8368f0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tasks/puppet_runonce.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Wait for up to five minutes for an in-progress Puppet agent run to complete
66
# TODO: right now the check is just for lock file existence. Improve the check
77
# to account for situations where the lockfile is stale.
8-
echo -n "Check for and wait up to 5 minutes for in-progress run to complete: "
8+
echo -n "Check for and wait up to 5 minutes for in-progress run to complete"
99
lockfile=$(/opt/puppetlabs/bin/puppet config print agent_catalog_run_lockfile)
1010
n=0
1111
until [ $n -ge 300 ]
@@ -17,6 +17,11 @@ do
1717
done
1818
echo
1919

20+
# Notes:
21+
# - Do not run with color, as the color codes can make interpreting output when
22+
# passed through Bolt difficult.
23+
# - Without --detailed-exitcodes, the `puppet agent` command will return 0 even
24+
# if there are a resource failures. So, use --detailed-exitcodes.
2025
/opt/puppetlabs/bin/puppet agent \
2126
--onetime \
2227
--verbose \
@@ -25,11 +30,11 @@ echo
2530
--no-splay \
2631
--no-use_cached_catalog \
2732
--detailed-exitcodes \
33+
--color false \
2834
$NOOP_FLAG
2935

30-
# Without --detailed-exitcodes, the `puppet agent` command will return 0 even
31-
# if there are resource failures. Use --detailed-exitcodes but only exit
32-
# non-zero if an error occurred. Changes (code 2) are not errors.
36+
# Only exit non-zero if an error occurred. Changes (detailed exit code 2) are
37+
# not errors.
3338
exitcode=$?
3439
if [ $exitcode -eq 0 -o $exitcode -eq 2 ]; then
3540
exit 0

0 commit comments

Comments
 (0)