Created
June 28, 2013 14:39
-
-
Save maxlinc/5885186 to your computer and use it in GitHub Desktop.
roles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding : utf-8 -*- | |
module Puppet::Parser::Functions | |
newfunction(:has_role, :type => :rvalue) do |role| | |
has_role?(role) | |
end | |
end | |
def has_role?(role) | |
pool = lookupvar "#{role.first}_pool" | |
if pool | |
pool_items = pool.split(',') | |
pool_items.include?(lookupvar 'fqdn') || pool_items.include?(lookupvar 'ipaddress') | |
else | |
false | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define truth::roles_check() { | |
if has_role($name) { | |
class {"apps::my_${name}": | |
ensure => present, | |
} | |
} else { | |
class {"apps::my_${name}": | |
ensure => absent, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment