On Wed, Jul 30, 2014 at 08:47:23PM +0100, Karolis Pabijanskas wrote: > Thanks! I knew it was something simple! I just did not restart the puppet > master.... that was all.. hiera works fine with or without the quotes > though and they are not required.
I've had some troubles using all-numeric strings ("1234") unquoted in templates, where they are interpreted as integers. Not that I'm the expert, but it's worth considering that ruby variables in templates are typed, but puppet variables in manifests aren't, and will need more care when writing yaml for templates. Consider how you'll need to use to_s or to_i in a template: --- integer: 1234 string: "1234" $ readyaml /tmp/yaml1 {"integer"=>1234, "string"=>"1234"} Obviously I'm not the expert, it's just a bit of a pain. $ cat bin/readyaml #!/usr/bin/env ruby require 'pp' require 'yaml' data = File.read(ARGV[0]) yaml = YAML.load(data) pp yaml > Thanks again for the tip! > > Karolis > > On 30 July 2014 19:03, Garrett Honeycutt <[1]g...@garretthoneycutt.com> > wrote: > > On 7/30/14 1:23 PM, Johan De Wit wrote: > > Hi, > > > > always use quotes when using facts etc in hiera : > > > > :hierarchy: > > - "%{operatingsystem}" > > - default > > > > hth > > > > Johan > > > > On 30/07/14 18:21, Karolis Pabijanskas wrote: > >> Hi All, > >> > >> I am sure this is going to be something completely stupid, but I just > >> can't find the issue :) > >> > >> I have a very simple module that that needs a different filepath > >> depending on the operating system, so I'm trying to call: > >> > >> $global_bashrc_file = hiera("global_bashrc_file") > >> > >> from my module. > >> > >> The hierarchy at the moment is very simple: > >> > >> :hierarchy: > >> - %{operatingsystem} > >> - default > >> > >> Calling notify from the module works just fine and brings back CentOS > >> as my operating system. CentOS.yaml does exist in the datadir and > >> does contain the variable. Running hiera in through the shell does > >> indeed show it working and returns the correct variable: > >> > >> # hiera global_bashrc_file operatingsystem=CentOS > >> /etc/bashrc > >> > >> But when trying to get this value via puppet, I just get an error: > >> Error: Could not retrieve catalog from remote server: Error 400 on > >> SERVER: Could not find data item global_bashrc_file in any Hiera data > >> file and no default supplied at blah > >> > >> It does work perfectly fine if I place the variable in default.yaml, > >> but if I move it to the os-specific yaml it just shouts at me that I > >> have not declared it... Just seems like $operatingsystem does not get > >> passed on from puppet, even though: > >> # facter operatingsystem > >> CentOS > >> > >> and notify '{ "${operatingsystem": }' in puppet works. > >> > >> As mentioned, I am sure I am missing something very trivial, but > maybe > >> one of you enlightened ones can point me in the right direction! > >> > >> puppet version is 3.6.2 > >> hiera version i 1.3.4 > >> > >> Thanks in advance! > >> > >> Karolis > >> > > Hi, > > Good eye on the quotes, Johan. Whenever you change hiera.yaml, be sure > to restart the puppet master. > > Best regards, > -g > > -- > Garrett Honeycutt > @learnpuppet > Puppet Training with LearnPuppet.com > Mobile: [2]+1.206.414.8658 > -- > 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 [3]puppet-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > > [4]https://groups.google.com/d/msgid/puppet-users/53D93388.9060604%40garretthoneycutt.com. > For more options, visit [5]https://groups.google.com/d/optout. > > -- > 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 [6]puppet-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > > [7]https://groups.google.com/d/msgid/puppet-users/CANYNSSJAz1YOn6cnm0oSiG7KNehqu60TEyHq_hum2T5O97xycQ%40mail.gmail.com. > For more options, visit [8]https://groups.google.com/d/optout. > > References > > Visible links > 1. mailto:g...@garretthoneycutt.com > 2. file:///tmp/tel:%2B1.206.414.8658 > 3. mailto:puppet-users%2bunsubscr...@googlegroups.com > 4. > https://groups.google.com/d/msgid/puppet-users/53D93388.9060604%40garretthoneycutt.com > 5. https://groups.google.com/d/optout > 6. mailto:puppet-users+unsubscr...@googlegroups.com > 7. > https://groups.google.com/d/msgid/puppet-users/CANYNSSJAz1YOn6cnm0oSiG7KNehqu60TEyHq_hum2T5O97xycQ%40mail.gmail.com?utm_medium=email&utm_source=footer > 8. https://groups.google.com/d/optout -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/20140730200307.GA15568%40iniquitous.heresiarch.ca. For more options, visit https://groups.google.com/d/optout.