Ask Your Question
2

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

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

Red Cricket gravatar image

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

Hi I have this hiera.yaml ...

---
:backends:
  - http
  - json

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

:hierarchy:
  - 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?

UPDATE:

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

edit retag flag offensive close merge delete

Comments

1

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 -0500 )edit
1

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

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

1 Answer

Sort by ยป oldest newest most voted
2

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

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

Comments

2

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 -0500 )edit
2

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 -0500 )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

2 followers

Stats

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

Seen: 2,135 times

Last updated: May 31 '13