On Fri, Sep 7, 2012 at 1:36 AM, Stefan Goethals <[email protected]> wrote:
> Hello,
>
> "This is a known limitation and the data bindings were not
> meant to support the puppet backend."
>
> ??? Can you elaborate on this please ?
>
> The puppet backend just makes Hiera awesome for supplying defaults.
> Puppet not supporting the puppet backend for Hiera sounds weird to me.
>

You are right that it allowed a way of supplying defaults that didn't
have to live inside the class, but that is the same problem that the
data bindings are trying to solve. With the puppet backend you would
have done:

  class example::data {
    $var = 'foo'
  }

  class example($param = hiera('var')) { }

That will still work. The point of the data bindings, however, was to
get rid of these explicit calls to hiera. So now you can just put the
default inline:

  class example($param = 'foo') { }

That way there is no tying of the manifest code to Hiera. Module
authors can put sane defaults in for parameters, and consumers of the
module can use data bindings to set a value for them. Both the puppet
backend and the data bindings were trying to achieve similar ends:
separate data from code. The data bindings do this by extending the
language and providing an extension point in puppet where you can plug
in your own data lookup services. The puppet backend was a hack that
depended on knowledge about puppet that leaked through to the
implementation of the backend, which was never supposed to be
available. We made the decision to not continue leaking this
information in the data bindings code so that it would be less tied to
the internals of puppet. That had the effect of cutting off the puppet
backend, which we did not consider a problem since we wanted to
promote the pure data bindings going forward.

I'm not sure if this clears anything up. Does it make a bit more sense?

> Regards,
>
> Stefan - Zipkid - Goethals.
>
>
> On Thu, Sep 6, 2012 at 7:25 PM, Andy Parker <[email protected]> wrote:
>>
>> On Thu, Sep 6, 2012 at 6:45 AM, Stefan Goethals <[email protected]> wrote:
>> > Hello,
>> >
>> > I am testing Puppet 3 with the built in hiera bindings.
>> >
>>
>> Great! Thanks for trying it out and giving some feedback
>>
>> > The yaml backend seems to work ok, though with renamed variables
>> > compared to
>> > using the hiera() functions.
>> >
>>
>> Yes. The data bindings will construct the fully qualified name of the
>> variable (so class pt3 ($var) {} looks up pt3::var) in order to make
>> sure that they are kept unique.
>>
>> > What does not seem to work for me is the puppet backend.
>> >
>>
>> This is because of the name of the variables that are looked up. The
>> puppet backend will try to lookup pt3::data the variable named
>> pt3::var. This is a known limitation and the data bindings were not
>> meant to support the puppet backend.
>>
>> > I have been using it without problems in puppet 2.7.x.
>> >
>>
>> The way you were using it in 2.7.x should continue to work. And your
>> output below indicates that it still does.
>>
>> > What i expect to see is the 'Debug: hiera(): Looking for data in
>> > p3t::data'like when using hiera().
>> >
>> > What i see is this 'Debug: hiera(): Looking for data in fake::data'
>> >
>> > As a result the file modules/p3t/manifests/data.pp is never queried when
>> > using the 'class p3t ( $somevar = '' )' syntax.
>> >
>> > The code is the following.
>> > hiera.yaml
>> >>
>> >> ---
>> >> :hierarchy:
>> >>   - common
>> >>
>> >> :backends:
>> >>   - puppet
>> >>
>> >>
>> >> :puppet:
>> >>   datasource: data
>> >
>> >
>> > modules/p3t/manifests/init.pp
>> >>
>> >> # 2 tries... (1 at a time of course..)
>> >>
>> >>
>> >> class p3t  ( $somevar = '' )
>> >> class p3t  ( $somevar = hiera('somevar','') )
>> >>
>> >>
>> >> {
>> >>   notify { "test: $somevar": }
>> >> }
>> >>
>> >
>> > puppept_backend.rb
>> >
>> >       def hierarchy(scope, override)
>> >         begin
>> >           data_class = Config[:puppet][:datasource] || "data"
>> >         rescue
>> >           data_class = "data"
>> >         end
>> >
>> >         # added Debug output here...
>> >         Hiera.debug( " scope :#{scope}: " )
>> >         Hiera.debug( " scope.resource :#{scope.resource}: " )
>> >         Hiera.debug( " scope.resource.name :#{scope.resource.name}: " )
>> >
>> >
>> >         calling_class = scope.resource.name.to_s.downcase
>> >>
>> >>         calling_module = calling_class.split("::").first
>> >
>> >
>> > server output
>> >>
>> >> # result of using class p3t  ( $somevar = '' )
>> >>
>> >> Debug: Automatically imported p3t from p3t into production
>> >> Debug: hiera(): Hiera Puppet backend starting
>> >> Debug: hiera(): Looking up p3t::somevar in Puppet backend
>> >> Debug: hiera():  scope
>> >> :#<Puppet::Indirector::Hiera::FakeScope:0x7f03abf1fdf0>:
>> >> Debug: hiera():  scope.resource :#<struct #<Class:0x7f03abf22de8>
>> >> name="fake">:
>> >> Debug: hiera():  scope.resource.name :fake:
>> >> Debug: hiera(): Looking for data in data::common
>> >> Debug: hiera(): Found data in class data::common
>> >> Debug: hiera(): Looking for data in fake::data
>> >> Debug: hiera(): Found data in class fake::data
>> >> Compiled catalog for pm3.lan.super-visions.com in environment
>> >> production
>> >> in 0.15 seconds
>> >>
>> >>
>> >>
>> >> # and using class p3t  ( $somevar = hiera('somevar','') )
>> >>
>> >>
>> >> Debug: Automatically imported p3t from p3t into production
>> >> Debug: hiera(): Hiera Puppet backend starting
>> >> Debug: hiera(): Looking up p3t::somevar in Puppet backend
>> >> Debug: hiera():  scope
>> >> :#<Puppet::Indirector::Hiera::FakeScope:0x7f79f7558390>:
>> >> Debug: hiera():  scope.resource :#<struct #<Class:0x7f79f7560b58>
>> >> name="fake">:
>> >> Debug: hiera():  scope.resource.name :fake:
>> >> Debug: hiera(): Looking for data in data::common
>> >> Debug: hiera(): Found data in class data::common
>> >> Debug: hiera(): Looking for data in fake::data
>> >> Debug: hiera(): Found data in class fake::data
>> >> Debug: hiera(): Looking up somevar in Puppet backend
>> >> Debug: hiera():  scope :Scope(Class[P3t]):
>> >> Debug: hiera():  scope.resource :Class[P3t]:
>> >> Debug: hiera():  scope.resource.name :P3t:
>> >> Debug: hiera(): Looking for data in data::common
>> >> Debug: importing '/etc/puppet-modules/p3t/manifests/data.pp' in
>> >> environment production
>> >> Debug: hiera(): Looking for data in p3t::data
>> >> Compiled catalog for pm3.lan.super-visions.com in environment
>> >> production
>> >> in 0.16 seconds
>> >
>> >
>> > Regards,
>> >
>> > Stefan - Zipkid - Goethals.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Puppet Developers" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to
>> > [email protected].
>> > For more options, visit this group at
>> > http://groups.google.com/group/puppet-dev?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Developers" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/puppet-dev?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/puppet-dev?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to