Hiera.yaml not interpolate variables

611 views
Skip to first unread message

Israel Calvete

unread,
May 8, 2014, 11:21:08 AM5/8/14
to puppet...@googlegroups.com, Fernando Porro
Hi,

This is my hiera config.

---
:backends: - yaml
:hierarchy: - %{::environment}
            - common
:yaml:
  :datadir: "/usr/share/puppet/configuration/%{::environment}/hiera/current/hieradata"
:puppet:
  :datasource: data

It seems if puppet master can't resolve enviroment variable but if I change %{::environment} for a fix value, all works fine.

In a client the error is...

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find data item mysql_monitor_user in any Hiera data file and no default supplied at....

In the puppetmaster ( repupuppet himselft ) the error is ...

err: Could not retrieve catalog from remote server: Error 400 on SERVER: malformed format string - %S at

Both for line...

$cndb_db = hiera('cndb_db')


My hiera version is 1.2.1

My puppet version is 2.7.23

Thanks!!!!


Brendan O'Bra

unread,
May 8, 2014, 12:15:34 PM5/8/14
to puppet...@googlegroups.com
Where is your hiera.yaml located? Default for puppet is /etc/puppet/hiera.yaml


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/c57ff48d-af64-4cb4-a81c-19f98ec5bb5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
GVoice: 707.410.0371 

Israel Calvete

unread,
May 8, 2014, 12:21:05 PM5/8/14
to puppet...@googlegroups.com
Yes, hiera file is in /etc/puppet/hiera.yaml

Jeff Adams

unread,
May 8, 2014, 12:23:36 PM5/8/14
to puppet...@googlegroups.com
Pretty sure I ran across this same issue. Try pulling the :: out of the
variable name. e.g. %{environment}

- Jeff

On 05/08/2014 11:21 AM, Israel Calvete wrote:
> Yes, hiera file is in /etc/puppet/hiera.yaml
>
> On Thursday, May 8, 2014 6:15:34 PM UTC+2, Brendan O'Bra wrote:
>
> Where is your hiera.yaml located? Default for puppet is
> /etc/puppet/hiera.yaml
>
>
> On Thu, May 8, 2014 at 8:21 AM, Israel Calvete <ical...@gmail.com
> <javascript:>> wrote:
>
> Hi,
>
> This is my hiera config.
>
> /---/
> /:backends: - yaml/
> /:hierarchy: - %{::environment}/
> / - common/
> /:yaml:/
> / :datadir:
> "/usr/share/puppet/configuration/%{::environment}/hiera/current/hieradata"/
> /:puppet:/
> / :datasource: data/
>
> It seems if puppet master can't resolve enviroment variable but
> if I change /%{::environment}/ for a fix value, all works fine.
>
> In a client the error is...
>
> /err: Could not retrieve catalog from remote server: Error 400
> on SERVER: Could not find data item mysql_monitor_user in any
> Hiera data file and no default supplied at..../
>
> In the puppetmaster ( repupuppet himselft ) the error is ...
>
> /err: Could not retrieve catalog from remote server: Error 400
> on SERVER: malformed format string - %S at/
>
> Both for line...
>
> /$cndb_db = hiera('cndb_db')/
>
>
> My hiera version is 1.2.1
>
> My puppet version is 2.7.23
>
> Thanks!!!!
>
>
> --
> You received this message because you are subscribed to the
> Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to puppet-users...@googlegroups.com <javascript:>.
> <https://groups.google.com/d/msgid/puppet-users/c57ff48d-af64-4cb4-a81c-19f98ec5bb5b%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
>
>
> --
> GVoice: 707.410.0371
> LinkedIn: http://www.linkedin.com/in/brendanobra
> <http://www.linkedin.com/in/brendanobra>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/0cafffa8-3153-4770-8ef6-d9a0c0d4622d%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/0cafffa8-3153-4770-8ef6-d9a0c0d4622d%40googlegroups.com?utm_medium=email&utm_source=footer>.

twm...@gmail.com

unread,
May 10, 2014, 12:46:18 PM5/10/14
to puppet...@googlegroups.com, Fernando Porro
Try something more like...need quotes afaik.

---
:backends:
  - yaml
:hierarchy:
  - defaults
  - "%{clientcert}"
  - "%{environment}"
  - "users/%{usertype}"
  - global

Andreas Ntaflos

unread,
May 10, 2014, 12:54:34 PM5/10/14
to puppet...@googlegroups.com
On 2014-05-08 17:21, Israel Calvete wrote:
> Hi,
>
> This is my hiera config.
>
> /---/
> /:backends: - yaml/
> /:hierarchy: - %{::environment}/
> / - common/

You must use double quotes when you want interpolation to work. See
http://docs.puppetlabs.com/hiera/1/variables.html#interpolation-tokens

"In YAML files, any string containing an interpolation token must be
quoted in order to comply with the YAML spec. (Under Ruby 1.8,
interpolation tokens in unquoted strings will sometimes work anyway, but
this can’t be relied on.)"

So that should be "%{::environment}", instead of simply %{::environment}.

Andreas

signature.asc
Reply all
Reply to author
Forward
0 new messages