Skip to content

Instantly share code, notes, and snippets.

@rodjek
Forked from cloudartisan/nodes.pp
Created July 5, 2012 05:28
Show Gist options
  • Save rodjek/3051548 to your computer and use it in GitHub Desktop.
Save rodjek/3051548 to your computer and use it in GitHub Desktop.
Want to define a different security group for each server range
# First option, make elasticsearch a parameterised class
node /^tcsearch(0[1-9]|10)\.deskstaging\.com$/ inherits staging {
class { 'elasticsearch':
security_group => 'foo',
}
}
node /^tcsearch2[0-9]\.deskstaging\.com$/ inherits staging {
class { 'elasticsearch':
security_group => 'bar',
}
}
class elasticsearch($security_group) {
# ...
}
# Second option, handle it in the class itself
class elasticsearch {
case $::hostname {
/^tcsearch(0[1-9]|10)/ { $security_group = 'foo' }
/^tcsearch2[1-9]/ { $security_group = 'bar' }
default: {
fail("Unable to determine security group for host '${::hostname}'")
}
}
# ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment