Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: specialunderwear/puppet-kicker
base: b64942f22d
...
head fork: specialunderwear/puppet-kicker
compare: d14629ab81
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
2  README.rst
@@ -92,6 +92,8 @@ facts.
servers_with_facts('hostname=/^new$|^old$/') // returns servers with hostname either new or old
servers_with_facts('uptime>10', 'hostname=/lala/') // returns servers with uptime over 10 and hostname matches lala
+- server_with_role: Return one server object with a certain role:
+ server_with_role('haproxy', { hostname => 'localhost', ipaddress => '127.0.0.1'}) // returns one haproxy server, or localhost server if nothing found.
.. _cloudstack:
View
26 lib/puppet/parser/functions/server_with_role.rb
@@ -0,0 +1,26 @@
+begin
+ require 'puppet/util/log'
+
+ module Puppet::Parser::Functions
+ newfunction(:server_with_role,
+ :type => :rvalue,
+ :doc => "Return one server object with a certain role:
+
+ server_with_role('frontend', { fallback => 'somevalue' })
+ " ) do |args|
+ Puppet::Parser::Functions.autoloader.loadall
+
+ fallback = nil
+
+ if args.kind_of?(Array) and args.count > 1
+ fallback = args.pop
+ end
+
+ servers = servers_with_role(args)
+ servers.count ? servers : fallback
+ end
+ end
+
+rescue NameError, LoadError
+ # the puppet clients don't have any activerecord. see http://projects.puppetlabs.com/issues/12594
+end
View
2  lib/puppet/parser/functions/servers_with_role.rb
@@ -6,7 +6,7 @@ module Puppet::Parser::Functions
:type => :rvalue,
:doc => "Return all server objects with a certain role:
- servers_with_role('frontend', 'production)
+ servers_with_role('frontend', 'production')
" ) do |roles|
Puppet::Parser::Functions.autoloader.loadall

No commit comments for this range

Something went wrong with that request. Please try again.