[Puppet Users] Selecting modlues based on subnet in nodes.pp

2012-01-26 Thread Derek
I have four major zones in my nework:  Development, Quality Assurance,
User Acceptanc Testing, and Production.  I am able to deply different
modules to these zones based on the simple regular expressions posted
in the example at the bottom of this message.

I have two data centers in my network:  Salt Lake City and Santa
Clara.  I would like to be able to deploy different modules to servers
based on the data center that they reside it.  I have tried simple if
statements and case statements but don't seem to be able to deploy my
site based modules.

Can you give me some imput on the best approach to my problem?  I know
I can manually define ever server in the enterprise in my nodes.pp,
but I would prefer a more dynamic approach based IP subnet.

$sal_nets =
['10.131.21.0','10.131.31.0','10.131.40.0','10.134.40.0','10.135.1.0','10.135.2.0','10.135.20.0','10.135.3.0','10.135.6.0','10.142.20.0','10.142.23.0']

$scl_nets =
['10.146.1.0','10.146.16.0','10.146.19.0','10.146.20.0','10.146.24.0','10.146.24.0','10.146.28.0','10.146.31.0','10.151.21.0','192.168.119.0','192.168.43.0','192.168.99.0']

node /^.+\.dev\.svbank\.com/  {

#  if ($network_eth0 in $sal_nets) or ($network_bond0 in $sal_nets) {
#notice('salt lake city net')
#  }

#  if (($network_eth0 and ($network_eth0 in $sal_nets))) or
($network_bond0 and (($network_bond0 in $scl_nets))) {
#notice('santa clara net')
#  }

  case $network_eth0 {
$sal_nets: { include svb-sal-sendmail-cf } # use SAL
repository
$scl_nets: { include svb-scl-sendmail-cf } # else use SCL
repository
}

  include svb-core-config
  include svb-core-encase
  include svb-core-packages
  include svb-puppet
  include svb-sshd
  include svb-sudo
  include svb-repos
  include svb-snmpd
#  include svb-sendmail-cf
}
node /^.+\.qa\.svbank\.com/  {
  include svb-core-config
  include svb-core-encase
  include svb-core-packages
  include svb-puppet
  include svb-sshd
  include svb-sudo
  include svb-repos
  include svb-snmpd
#  include svb-sendmail-cf
}
node /^.+\.uat\.svbank\.com/  {
  include svb-core-config
  include svb-core-encase
  include svb-core-packages
  include svb-puppet
  include svb-sshd
  include svb-sudo
  include svb-repos
#  include svb-sendmail-cf
  include svb-users
}
node /^.+\.corp\.svbank\.com/  {
  include svb-core-config
  include svb-repos
  include svb-puppet
}

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Selecting modlues based on subnet in nodes.pp

2012-01-26 Thread Gabriel Filion
Hello,

On 12-01-23 02:14 PM, Derek wrote:
 I have four major zones in my nework:  Development, Quality Assurance,
 User Acceptanc Testing, and Production.  I am able to deply different
 modules to these zones based on the simple regular expressions posted
 in the example at the bottom of this message.
 
 I have two data centers in my network:  Salt Lake City and Santa
 Clara.  I would like to be able to deploy different modules to servers
 based on the data center that they reside it.  I have tried simple if
 statements and case statements but don't seem to be able to deploy my
 site based modules.
 
 Can you give me some imput on the best approach to my problem?

You could use environments to differentiate the nodes..:

http://docs.puppetlabs.com/guides/environment.html
http://hunnur.com/blog/2010/10/dynamic-git-branch-puppet-environments/

Or (maybe better) you could define a custom fact that tells in which DC
your node is present and then branch on the value of this fact:

http://www.devco.net/archives/2011/06/29/facter_facts_from_txt_json_yaml_and_non_ruby_scripts.php

(see the end of the post for a link to github where you can find the
code for custom facts from arbitrary files)

-- 
Gabriel Filion

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.