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].
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.


[main]
pluginsync=true
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
storeconfigs=true

templatedir=/srv/puppet/templates
modulepath=/srv/puppet/environments/$environment/modules:/srv/puppet/modules

[production]
manifest=/srv/puppet/manifests/production.pp

[testdmz]
manifest=/srv/puppet/manifests/testdmz.pp

[agent]
server=puppet-p-01.kamago.net
environment=production
pluginsync=true

[master]
# These are needed when the puppetmaster is run by passenger
# and can safely be removed if webrick is used.
ssl_client_header = SSL_CLIENT_S_DN 
ssl_client_verify_header = SSL_CLIENT_VERIFY

storeconfigs=true
dbadapter=mysql
dbserver=mysql.kamago.net
dbuser=puppet
dbpassword=nope

Attachment: hiera.yaml
Description: application/yaml

[main]                                                                          
                                                                      
pluginsync=true
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
storeconfigs=true
 
templatedir=/srv/puppet/templates
modulepath=/srv/puppet/environments/$environment/modules:/srv/puppet/modules
 
[production]
manifest=/srv/puppet/manifests/production.pp
 
[testdmz]
manifest=/srv/puppet/manifests/testdmz.pp
 
[agent]
server=puppet-t-01.kamago.net
environment=testdmz
pluginsync=true
 
[master]
# These are needed when the puppetmaster is run by passenger
# and can safely be removed if webrick is used.
ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY
 
storeconfigs=true
dbadapter=mysql
dbserver=mysql.kamago.net
dbuser=puppet
dbpassword=nope

Reply via email to