FAQ
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

John Kennedy

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

Search Discussions

  • R.I.Pienaar at May 2, 2012 at 11:19 am

    ----- Original Message -----
    From: "John Kennedy" <skebi69@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

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Dan Carley at May 2, 2012 at 11:42 am

    On 2 May 2012 12:19, R.I.Pienaar 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 %>

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Nigel Kersten at May 2, 2012 at 3:10 pm
    On Wed, May 2, 2012 at 4:19 AM, R.I.Pienaar wrote:
    ----- Original Message -----
    From: "John Kennedy" <skebi69@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.

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • John Kennedy at May 2, 2012 at 3:15 pm
    On Wed, May 2, 2012 at 11:10 AM, Nigel Kersten wrote:
    On Wed, May 2, 2012 at 4:19 AM, R.I.Pienaar wrote:


    ----- Original Message -----
    From: "John Kennedy" <skebi69@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

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • R.I.Pienaar at May 2, 2012 at 3:18 pm

    ----- Original Message -----
    From: "Nigel Kersten" <nigel@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 wrote:




    ----- Original Message -----
    From: "John Kennedy" < skebi69@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

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Nigel Kersten at May 2, 2012 at 3:24 pm
    On Wed, May 2, 2012 at 8:18 AM, R.I.Pienaar wrote:
    ----- Original Message -----
    From: "Nigel Kersten" <nigel@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 wrote:




    ----- Original Message -----
    From: "John Kennedy" < skebi69@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?

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • R.I.Pienaar at May 2, 2012 at 3:37 pm

    ----- Original Message -----
    From: "Nigel Kersten" <nigel@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 wrote:




    ----- Original Message -----
    From: "Nigel Kersten" < nigel@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 < rip@devco.net >
    wrote:




    ----- Original Message -----
    From: "John Kennedy" < skebi69@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?
    nope.

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Nigel Kersten at May 2, 2012 at 3:38 pm
    On Wed, May 2, 2012 at 8:37 AM, R.I.Pienaar 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?

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • R.I.Pienaar at May 2, 2012 at 3:46 pm

    ----- Original Message -----
    From: "Nigel Kersten" <nigel@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 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


    .
    ├── development
    │   ├── modules
    │   │   └── test
    │   │   ├── files
    │   │   │   └── envtest
    │   │   └── manifests
    │   │   └── init.pp
    │   └── site.pp
    ├── production
    │   ├── modules
    │   │   └── test
    │   │   ├── files
    │   │   │   └── envtest
    │   │   └── manifests
    │   │   └── init.pp
    │   └── site.pp
    ├── puppet.conf
    └── test.pp


    test.pp has: include test


    production init.pp has:


    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

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • R.I.Pienaar at May 2, 2012 at 3:53 pm

    ----- Original Message -----
    From: "R.I.Pienaar" <rip@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" <nigel@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 < rip@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

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To post to this group, send email to puppet-users@googlegroups.com.
    To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
  • Nigel Kersten at May 2, 2012 at 6:43 pm
    On Wed, May 2, 2012 at 8:53 AM, R.I.Pienaar wrote:
    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

    That's the puzzling bit. It was definitely working for me in production in
    earlier 2.6.x days.

    I just tested with 2.7.x and it's broken too.

    I'll go hunting through the bug tracker today and update the bug or file a
    new one.

    Frustrating.

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedMay 2, '12 at 11:00a
activeMay 2, '12 at 6:43p
posts12
users4
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase