We have a custom fact that we wrote to determine which (business)
environment a specific server belongs to (test, stage, production).
We want to set up puppet environments (again, test, stage, and production).
Is it possible to use our custom fact to set which environment a node
belongs to?
Thanks,
John
----- Original Message -----
> From: "John Kennedy" <skeb...@gmail.com>
> To: puppet-users@googlegroups.com
> Sent: Wednesday, May 2, 2012 11:59:49 AM
> Subject: [Puppet Users] Using fact to determine node environment
> We have a custom fact that we wrote to determine which (business)
> environment a specific server belongs to (test, stage, production).
> We want to set up puppet environments (again, test, stage, and
> production).
> Is it possible to use our custom fact to set which environment a node
> belongs to?
your only option at present is to write out puppet.conf using a template
with your fact
On 2 May 2012 12:19, R.I.Pienaar <r...@devco.net> wrote:
> your only option at present is to write out puppet.conf using a template
> with your fact
We use this approach. The very first run gets called with "--environment
foo" and it sticks. "--environment" can then be called again if it needs to
move to another environment/branch. "puppet.conf" simply contains:
# Make environment "sticky" with each run.
# Populated by `environment` variable from Facter.
environment = <%= @environment %>
On Wed, May 2, 2012 at 4:19 AM, R.I.Pienaar <r...@devco.net> wrote:
> ----- Original Message -----
> > From: "John Kennedy" <skeb...@gmail.com>
> > To: puppet-users@googlegroups.com
> > Sent: Wednesday, May 2, 2012 11:59:49 AM
> > Subject: [Puppet Users] Using fact to determine node environment
> > We have a custom fact that we wrote to determine which (business)
> > environment a specific server belongs to (test, stage, production).
> > We want to set up puppet environments (again, test, stage, and
> > production).
> > Is it possible to use our custom fact to set which environment a node
> > belongs to?
> your only option at present is to write out puppet.conf using a template
> with your fact
Unless something broke it recently, I ran for years with a fact that
returned ":environment" and didn't set it in puppet.conf at all.
On Wed, May 2, 2012 at 11:10 AM, Nigel Kersten <ni...@puppetlabs.com> wrote:
> On Wed, May 2, 2012 at 4:19 AM, R.I.Pienaar <r...@devco.net> wrote:
>> ----- Original Message -----
>> > From: "John Kennedy" <skeb...@gmail.com>
>> > To: puppet-users@googlegroups.com
>> > Sent: Wednesday, May 2, 2012 11:59:49 AM
>> > Subject: [Puppet Users] Using fact to determine node environment
>> > We have a custom fact that we wrote to determine which (business)
>> > environment a specific server belongs to (test, stage, production).
>> > We want to set up puppet environments (again, test, stage, and
>> > production).
>> > Is it possible to use our custom fact to set which environment a node
>> > belongs to?
>> your only option at present is to write out puppet.conf using a template
>> with your fact
> Unless something broke it recently, I ran for years with a fact that
> returned ":environment" and didn't set it in puppet.conf at all.
Nigel,
Thanks for the response. How can I use that fact to set the environment of
a node?
John
----- Original Message -----
> From: "Nigel Kersten" <ni...@puppetlabs.com>
> To: puppet-users@googlegroups.com
> Sent: Wednesday, May 2, 2012 4:10:16 PM
> Subject: Re: [Puppet Users] Using fact to determine node environment
> On Wed, May 2, 2012 at 4:19 AM, R.I.Pienaar < r...@devco.net > wrote:
> ----- Original Message -----
> > From: "John Kennedy" < skeb...@gmail.com >
> > To: puppet-users@googlegroups.com
> > Sent: Wednesday, May 2, 2012 11:59:49 AM
> > Subject: [Puppet Users] Using fact to determine node environment
> > We have a custom fact that we wrote to determine which (business)
> > environment a specific server belongs to (test, stage, production).
> > We want to set up puppet environments (again, test, stage, and
> > production).
> > Is it possible to use our custom fact to set which environment a
> > node
> > belongs to?
> your only option at present is to write out puppet.conf using a
> template
> with your fact
> Unless something broke it recently, I ran for years with a fact that
> returned ":environment" and didn't set it in puppet.conf at all.
yes, it broke. You'll get a mix of files from one environment and classes
from another etc, puppet.conf is the only option now
On Wed, May 2, 2012 at 8:18 AM, R.I.Pienaar <r...@devco.net> wrote:
> ----- Original Message -----
> > From: "Nigel Kersten" <ni...@puppetlabs.com>
> > To: puppet-users@googlegroups.com
> > Sent: Wednesday, May 2, 2012 4:10:16 PM
> > Subject: Re: [Puppet Users] Using fact to determine node environment
> > On Wed, May 2, 2012 at 4:19 AM, R.I.Pienaar < r...@devco.net > wrote:
> > ----- Original Message -----
> > > From: "John Kennedy" < skeb...@gmail.com >
> > > To: puppet-users@googlegroups.com
> > > Sent: Wednesday, May 2, 2012 11:59:49 AM
> > > Subject: [Puppet Users] Using fact to determine node environment
> > > We have a custom fact that we wrote to determine which (business)
> > > environment a specific server belongs to (test, stage, production).
> > > We want to set up puppet environments (again, test, stage, and
> > > production).
> > > Is it possible to use our custom fact to set which environment a
> > > node
> > > belongs to?
> > your only option at present is to write out puppet.conf using a
> > template
> > with your fact
> > Unless something broke it recently, I ran for years with a fact that
> > returned ":environment" and didn't set it in puppet.conf at all.
> yes, it broke. You'll get a mix of files from one environment and classes
> from another etc, puppet.conf is the only option now
I think you're thinking of the ENC setting the environment, not a fact
called 'environment' RI?
----- Original Message -----
> From: "Nigel Kersten" <ni...@puppetlabs.com>
> To: puppet-users@googlegroups.com
> Sent: Wednesday, May 2, 2012 4:24:06 PM
> Subject: Re: [Puppet Users] Using fact to determine node environment
> On Wed, May 2, 2012 at 8:18 AM, R.I.Pienaar < r...@devco.net > wrote:
> ----- Original Message -----
> > From: "Nigel Kersten" < ni...@puppetlabs.com >
> > To: puppet-users@googlegroups.com
> > Sent: Wednesday, May 2, 2012 4:10:16 PM
> > Subject: Re: [Puppet Users] Using fact to determine node
> > environment
> > On Wed, May 2, 2012 at 4:19 AM, R.I.Pienaar < r...@devco.net >
> > wrote:
> > ----- Original Message -----
> > > From: "John Kennedy" < skeb...@gmail.com >
> > > To: puppet-users@googlegroups.com
> > > Sent: Wednesday, May 2, 2012 11:59:49 AM
> > > Subject: [Puppet Users] Using fact to determine node environment
> > > We have a custom fact that we wrote to determine which (business)
> > > environment a specific server belongs to (test, stage,
> > > production).
> > > We want to set up puppet environments (again, test, stage, and
> > > production).
> > > Is it possible to use our custom fact to set which environment a
> > > node
> > > belongs to?
> > your only option at present is to write out puppet.conf using a
> > template
> > with your fact
> > Unless something broke it recently, I ran for years with a fact
> > that
> > returned ":environment" and didn't set it in puppet.conf at all.
> yes, it broke. You'll get a mix of files from one environment and
> classes
> from another etc, puppet.conf is the only option now
> I think you're thinking of the ENC setting the environment, not a
> fact called 'environment' RI?
On Wed, May 2, 2012 at 8:37 AM, R.I.Pienaar <r...@devco.net> wrote:
> > > Unless something broke it recently, I ran for years with a fact
> > > that
> > > returned ":environment" and didn't set it in puppet.conf at all.
> > yes, it broke. You'll get a mix of files from one environment and
> > classes
> > from another etc, puppet.conf is the only option now
> > I think you're thinking of the ENC setting the environment, not a
> > fact called 'environment' RI?
----- Original Message -----
> From: "Nigel Kersten" <ni...@puppetlabs.com>
> To: puppet-users@googlegroups.com
> Sent: Wednesday, May 2, 2012 4:38:38 PM
> Subject: Re: [Puppet Users] Using fact to determine node environment
> On Wed, May 2, 2012 at 8:37 AM, R.I.Pienaar < r...@devco.net > wrote:
> > > Unless something broke it recently, I ran for years with a fact
> > > that
> > > returned ":environment" and didn't set it in puppet.conf at all.
> > yes, it broke. You'll get a mix of files from one environment and
> > classes
> > from another etc, puppet.conf is the only option now
> > I think you're thinking of the ENC setting the environment, not a
> > fact called 'environment' RI?
> nope.
> Anyone got a bug # for this?
pretty sure there was one but couldnt find it so I just knocked up a quick test, this has been discussed to death in the past
class test {
notify{"production test": }
file{"/tmp/envtest":
source =>"puppet:///modules/test/envtest"
}
}
development just changed the notify
when running with --enviornment this works:
% puppet apply --config puppet.conf --environment development test.pp
notice: development test
notice: /Stage[main]/Test/Notify[development test]/message: defined 'message' as 'development test'
notice: /Stage[main]/Test/File[/tmp/envtest]/ensure: defined content as '{md5}e42d5f60192d1f8f94ce446fff3113b0'
notice: Finished catalog run in 0.03 seconds
% cat /tmp/envtest development
% puppet apply --config puppet.conf --environment production test.pp
notice: /Stage[main]/Test/File[/tmp/envtest]/content: content changed '{md5}e42d5f60192d1f8f94ce446fff3113b0' to '{md5}6f03617bce8a5d04fe97df572f273d05'
notice: production test
notice: /Stage[main]/Test/Notify[production test]/message: defined 'message' as 'production test'
notice: Finished catalog run in 0.03 seconds
% cat /tmp/envtest
production
same with a fact and here i am getting development code with production files:
% FACTER_environment=development puppet apply --config puppet.conf test.pp
notice: development test
notice: /Stage[main]/Test/Notify[development test]/message: defined 'message' as 'development test'
notice: Finished catalog run in 0.02 seconds
% cat /tmp/envtest production
----- Original Message -----
> From: "R.I.Pienaar" <r...@devco.net>
> To: puppet-users@googlegroups.com
> Sent: Wednesday, May 2, 2012 4:46:24 PM
> Subject: Re: [Puppet Users] Using fact to determine node environment
> ----- Original Message -----
> > From: "Nigel Kersten" <ni...@puppetlabs.com>
> > To: puppet-users@googlegroups.com
> > Sent: Wednesday, May 2, 2012 4:38:38 PM
> > Subject: Re: [Puppet Users] Using fact to determine node
> > environment
> > On Wed, May 2, 2012 at 8:37 AM, R.I.Pienaar < r...@devco.net >
> > wrote:
> > > > Unless something broke it recently, I ran for years with a fact
> > > > that
> > > > returned ":environment" and didn't set it in puppet.conf at
> > > > all.
> > > yes, it broke. You'll get a mix of files from one environment and
> > > classes
> > > from another etc, puppet.conf is the only option now
> > > I think you're thinking of the ENC setting the environment, not a
> > > fact called 'environment' RI?
> > nope.
> > Anyone got a bug # for this?
> pretty sure there was one but couldnt find it so I just knocked up a
> quick test, this has been discussed to death in the past
should say I am on 2.6.x here, this may well have been fixed in 2.7.x