james.eckersall@fasthosts.com
2013-Dec-04 10:04 UTC
[Puppet Users] puppetdb missing environment fact
Hi, I''m seeing something rather strange with puppetdb (1.5.2) in regards to the environment fact. On my puppetdb host: If I run the following query: curl -G ''http://localhost:8080/v3/facts'' --data-urlencode ''query=["=", "name", "environment"]'' I would expect to receive the environment fact for every node that I''m managing with puppet (>500). However, that query only returns 11 nodes. These 11 nodes are running puppet 2.7.22. I am in the process of upgrading puppet to 3.3.2 from 2.7.22. All of the nodes running 3.3.2 are missing the environment fact from puppetdb. All the 2.7.22 nodes have the environment fact stored. Can anyone think of a reason why the environment fact is missing for my 3.3.2 nodes? J -- 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+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/0c8c5ba8-a08f-4b87-b817-e52f6806c5bb%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
''environment'' is not a Fact:
laptop:~$ sudo facter -p environment
laptop:~$
It is a configuration parameter of Puppet. I''m not sure why older 2.7
hosts
would be reporting it as a Fact to PuppetDB, unless in 2.7 all top scope
variables were sent this way.
You could use a Fact to pull out what environment an Agent *would* run with
using this Fact code:
#Get the configured environment out of puppet.conf
begin
puppet_environment = ''''
File.open(''/etc/puppet/puppet.conf'').each do |line|
if line =~ /^\s*environment\s*=\s*(\S+)/
puppet_environment = $1
end
end
Facter.add(:puppet_environment) do
setcode do
puppet_environment
end
end
rescue
Facter.warn("puppet_environment.rb failed: #{$!}")
end
On Wednesday, December 4, 2013 10:04:53 AM UTC, james.e...@fasthosts.com
wrote:>
> Hi,
>
> I''m seeing something rather strange with puppetdb (1.5.2) in
regards to
> the environment fact.
>
> On my puppetdb host:
>
> If I run the following query:
>
> curl -G ''http://localhost:8080/v3/facts'' --data-urlencode
''query=["=",
> "name", "environment"]''
>
> I would expect to receive the environment fact for every node that
I''m
> managing with puppet (>500).
>
> However, that query only returns 11 nodes. These 11 nodes are running
> puppet 2.7.22.
>
> I am in the process of upgrading puppet to 3.3.2 from 2.7.22.
>
> All of the nodes running 3.3.2 are missing the environment fact from
> puppetdb. All the 2.7.22 nodes have the environment fact stored.
>
> Can anyone think of a reason why the environment fact is missing for my
> 3.3.2 nodes?
>
> J
>
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/8e47c15c-9395-4a74-8e61-da15ad433688%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
james.eckersall@fasthosts.com
2013-Dec-04 14:27 UTC
[Puppet Users] Re: puppetdb missing environment fact
Thanks Luke.
I just found a bug report describing that this behaviour has changed in 3.x
http://projects.puppetlabs.com/issues/17692
For me, being able to determine the agent environment is very useful.
We use git for the Puppet manifests and each branch is an environment.
So we''ll create new branches to test and deploy new features.
Then when it''s ready to go live to all nodes, we''ll merge that
branch back
into master and remove the feature branch.
I rely on being able to query puppetdb or puppet-dashboard to find out
which nodes are using environment X, so I can safely remove a branch once
there are no nodes using it.
We also manage Puppet with Puppet and set the environment in puppet.conf
based on the current environment. This does still work as the environment
is available in the manifests.
I also found the following code (at
https://groups.google.com/forum/#!topic/puppet-users/AM1o4Khloto) for
turning environment into a fact.
Including it here in case it''s useful to others.
require ''puppet''
Facter.add(''environment'') do
setcode do
Puppet[:environment]
end
end
J
--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/c1146880-5afa-486b-bba0-6b45b9a91153%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.