Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Specifically, if I'm in staging, I want directory A, and in QA, directory B:

file{'/etc/appenv':
  ensure => file,
  owner  => 'root',
  group  => 'root',
  mode   => 0644,
  source => "file:///puppet/modules/myapp/appenv-${env}",
}

I have only 1 machine that needs this specific env for now. I have read Puppet: variable overriding best practices, but I thought stages were supposed to be used for this purpose.

share|improve this question

1 Answer 1

Instead of ${env}, try using ${environment} as per http://docs.puppetlabs.com/guides/environment.html

If you want to change another variable based on the environment, you can do it in a conditional/case statement/selector:

$dir = ${environment} ? {
   'staging' =>'A',
    'QA' => 'B',
    default => 'unknown',
}

file{'/etc/appenv':
  ensure => file,
  owner  => 'root',
  group  => 'root',
  mode   => 0644,
  source => "file:///puppet/modules/myapp/${dir}/appenv",
}
share|improve this answer
    
I actually run puppet through cron jobs on my machines. Can I specify the environment without a puppet master or agent? I see puppet agent --environment dev, but what about puppet apply --environment ... PATH/TO/MANIFEST.pp? Can't see it on the manual page. –  François Beausoleil Jul 20 '12 at 16:07
    
puppet apply --environment=production works fine. You can use any --option that you can put in the config file. –  vaughan Aug 13 '12 at 11:23
    
I also needed to remove the surround braces ${environment} -> $environment –  vaughan Aug 13 '12 at 11:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.