Guidelines

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
738 views
738 views

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 (115)
2 18 33
edit history

Please log in or register to answer this question.

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 (115)
2 18 33
edit history
...