Ask Your Question

why does %{hostname} have no value when used in hiera.yaml

asked 2013-05-30 17:26:12 -0600

Red Cricket gravatar image

updated 2013-05-31 12:27:52 -0600

Hi I have this hiera.yaml ...

  - http
  - json

   :host: mywebserver
   :output: json
      - /perl/cgi/allow-query.cgi
      - /perl/cgi/yum-repo.cgi?hostname=%{::hostname}

  - common

... and I pretty sure %{::hostname} is not right because on my webserver I that the parameter hostname has no value in my access_log file ...

mywebserver XX.XXX.XX.40 - - [30/May/2013:15:15:49 -0700] "GET /perl/cgi/yum-repo.cgi?hostname= HTTP/1.1" 200 168 "-" "-"

... I have tried %{hostname} too but same problem. So what am I doing wrong?


I guess I should mention how I am invoking hiera. I ... (more)

edit retag flag offensive close merge delete



Have you tried different facts just to be sure it works at all (fqdn, ...)? Would be interesting to see the debug logs from a puppet agent run

Daniel gravatar imageDaniel ( 2013-05-31 04:43:56 -0600 )edit

Have you tried wrapping the string w/ the variable in double quotes?

llowder gravatar imagellowder ( 2013-05-31 07:13:24 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-05-31 13:25:40 -0600

Red Cricket gravatar image

Hunner on puppet irc gave me the answer. I need to use ...

  - /perl/cgi/yum-repo.cgi?hostname=%{hostname}

... not ...

  - /perl/cgi/yum-repo.cgi?hostname=%{::hostname}

... in my hiera.yaml file and when I run hiera from the command-line I need to specify hostname like so hiera -c ./hiera.yaml yum_repo hostname=foo.

edit flag offensive delete link more



For anyone who's curious, when hiera runs on the command line, it's not running in the context of Puppet, so it doesn't have access to facter facts ...(more)

Ancillas gravatar imageAncillas ( 2013-06-01 23:35:11 -0600 )edit

You wrote: "... I have tried %{hostname} too but same problem. So what am I doing wrong?". Seems like you already had the right syntax

Daniel gravatar imageDaniel ( 2013-06-05 03:52:22 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2013-05-30 17:26:12 -0600

Seen: 2,814 times

Last updated: May 31 '13