Hi Pablo,

The Puppet backend accepts a 'datasource' parameter whose value will be the
class name for where it will look for Puppet variables.  Take my hiera.yaml
for example:

---
:backends: - puppet
:puppet:
        :datasource: data

I'm telling it to look for a <modulename>::data class, and to check within
that class for Puppet variables.  Given that setup, I can do the following:

# <modulepath>/puppetbackend/manifests/init.pp
class puppetbackend {
  $stuff = hiera('variable')

  notify { "Stuff is: ${stuff}": }
}

# <modulepath>/puppetbackend/manifests/data.pp
class puppetbackend::data {
  $variable = 'foo'
}

Then if I run: " puppet apply -v -e 'include puppetbackend' " I will get:

notice: Stuff is: foo
notice: /Stage[main]/Puppetbackend/Notify[Stuff is: foo]/message: defined
'message' as 'Stuff is: foo'
notice: Finished catalog run in 0.06 seconds

Does that help you out?




On Sat, Mar 17, 2012 at 2:29 AM, Pablo Fernandez <pablo.fernan...@cscs.ch>wrote:

> **
>
> Hi all,
>
>
>
> I am trying to understand how does hiera puppet backend work, so I created
> the following example:
>
>
>
> hiera.yaml has only:
>
> ---
>
> :backends:
>
> - puppet
>
>
>
> ---
>
>
>
> And the node:
>
> node 'testnode' {
>
> $variable = 'kk'
>
> $thing = hiera ("variable")
>
> notify { "note: $thing": }
>
> }
>
>
>
> I don't want to use the yaml backend for now, just want to grab variables
> from within puppet. But then I run the agent, and it "Could not find data
> item variable in any Hiera data file".
>
>
>
> This probably means I am completely lost. I did not put any hierarchy,
> because I don't want to use the yaml backend, and I don't know why else
> would I need it.
>
>
>
> Could anyone shed some light on me, please?
>
>
>
> Thanks,
> Pablo
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>



-- 

Gary Larizza
Professional Services Engineer
Puppet Labs

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to