This site is for tech Q&A. Please keep your posts focused on the subject at hand.

Ask one question at a time. Don't conflate multiple problems into a single question.

Make sure to include all relevant information in your posts. Try to avoid linking to external sites.

Links to documentation are fine, but in addition you should also quote the relevant parts in your posts.

0 votes

We're automatically deploying readiness checks on our servers. The checks are defined in Hiera and deployed with Puppet. One of these checks involves a curl command that should return the HTTP status code:

curl -sSLI -o /dev/null -w '%{http_code}' "https://$(hostname -f)/"

However, Hiera interpolates %{...} expressions, so the statement is rendered as

curl -sSLI -o /dev/null -w '' "https://$(hostname -f)/"

and the check fails.

Escaping the percent character or a curly bracket with a backslash doesn't seem to work, neither does doubling the percent character:

  • -w '\%{http_code}' turns into -w '\'
  • -w '%\{http_code}' turns into -w '%\{http_code}'
  • -w '%%{http_code}' turns into -w '%'

How do I prevent Hiera from trying to interpolate the string %{http_code}?

in Sysadmin
by (100)
1 4 11
edit history

Your answer


Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
By submitting this post you agree to our Terms & Conditions.
To avoid this verification in future, please log in or register.

1 Answer

0 votes

Unfortunately Hiera doesn't allow escaping interpolation expressions with an escape character. Instead you have to use the literal interpolation function:

curl -sSLI -o /dev/null -w '%{literal('%')}{http_code}' "https://$(hostname -f)/"
by (100)
1 4 11
edit history