]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/puppetmaster/lib/puppet/parser/functions/has_role.rb
Log error rather than exploding unhelpfully
[dsa-puppet.git] / modules / puppetmaster / lib / puppet / parser / functions / has_role.rb
1 module Puppet::Parser::Functions
2   newfunction(:has_role, :type => :rvalue) do |args|
3     begin
4       role = args.shift
5       roles = lookupvar('site::roles')
6       fqdn = lookupvar('fqdn')
7       if not roles.include?(role)
8         error "Failed to look up missing role #{role}"
9         return False
10       end
11       return roles[role].include?(fqdn)
12     end
13   end
14 end