I'm using %{environment} in my hiera config with hiera 1.1 and puppet 3.1.0,
and it works fine for me.
I have it in the datadir just like you have it, a pretty similar setup really.
So I don't know why it works for me and not you.
We do set the environment from the agent side though, not from the master side
if that makes any difference.
--
Erik Dalén
On Monday 11 March 2013 at 22:26, Grégory Oestreicher wrote:
> Hi Andy,
>
> I totally forgot to describe what I was trying to do and my setup, which may
> have blurred the message a bit.
>
> I have two environments, 'production' and 'testdmz', and a single Hiera YAML
> backend for both. Each environment has its own Puppet master, each one
> serving
> an environment, but both of them are pulling their data from the same source
> (a single Git repository with multiple branches).
>
> So puppet-test is in environment 'testdmz' and puppet-prod in environment
> 'production'. I attach the shared hiera.yaml config as well as both puppet
> master conf files. A note about the master confs: although the MySQL server
> host name is the same they are both different, each environment being served
> by
> its own DNS.
>
> The issue I have is that in hiera.yaml %{environment} is never set to
> 'testdmz' in hiera.yaml *only* on the master. On the agents everything is
> working fine.
>
> To exhibit this behavior I added in each Hiera backend the key 'teststring'
> with the value "you're in production" for the 'production' environment and
> "you're in testdmz" for the 'testdmz' environment, with this simple
> declaration:
> file { '/tmp/envtest':
> ensure => file,
> content => hiera( 'teststring' ),
> }
>
> When running this on the master, using 'puppet agent --test' the file
> /tmp/envtest contains "you're in production". On the puppet clients
> everything
> is working fine.
>
> Le lundi 11 mars 2013 09:55:57 Andy Parker a écrit :
> >
> > > Looking into the issue here's what I found. In puppet/resource.rb:321 (in
> > > Puppet::Resource#lookup_external_default_for) the scope object is used to
> > > initialize a Puppet::DataBinding::Variables, and from then on
> > > scope['environment'] will be used to access the environment. However this
> > > never returns the value of the current node env, which is rightly returned
> > > when using scope.environment.to_s.
> >
> >
> >
> > That is troubling. If the scope does not return the correct
> > environment, then the $environment variable in manifests will also not
> > be correct.
>
>
>
> Thinking again about this, it may be possible that the environment is wrong
> in
> other places, such as when expanding the modulepath in puppet.conf as another
>
> error disappeared once I applied this fix, but I didn't give it a second
> thought.
>
> Just to explain differently the problem is not that the environment is wrong
> (well, it is, but not that much), it's that it's incoherent inside the same
> object (Puppet::Parser::Scope), i.e. that scope['environment'] is different
> from scope.environment.name.to_s (the latter is alway correct). I'm not sure
> if this was clear in my previous message.
>
> > Thank you for working on this and sharing what you found. Would you be
> > able to work with us to come up with a complete fix for this?
>
>
>
> Sure, just shout.
>
> > A quick search on Redmine brought up:
> >
> > * http://projects.puppetlabs.com/issues/19396
>
> Maybe, I'm also using ActiveRecord stored configs. Testing PuppetDB is on my
> todo list.
>
> Cheers,
> Grégory
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> (mailto:[email protected]).
> To post to this group, send email to [email protected]
> (mailto:[email protected]).
> Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> Attachments:
> - master-prod-puppet.conf
>
> - hiera.yaml
>
> - master-testdmz-puppet.conf
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.