diff options
-rw-r--r-- | Modulefile | 9 | ||||
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | lib/puppet/parser/functions/trocla.rb | 7 | ||||
-rw-r--r-- | lib/puppet/parser/functions/trocla_get.rb | 9 | ||||
-rw-r--r-- | lib/puppet/util/trocla_helper.rb | 31 | ||||
-rw-r--r-- | manifests/config.pp | 8 | ||||
-rw-r--r-- | manifests/master.pp | 17 | ||||
-rw-r--r-- | manifests/master/ree.pp | 14 | ||||
-rw-r--r-- | metadata.json | 21 |
9 files changed, 120 insertions, 0 deletions
diff --git a/Modulefile b/Modulefile new file mode 100644 index 0000000..379f8d8 --- /dev/null +++ b/Modulefile @@ -0,0 +1,9 @@ +name 'duritong-trocla' +version '0.0.1' + +author 'duritong' +license '' +project_page 'https://github.com/duritong/trocla' +source 'https://github.com/duritong/puppet-trocla' +summary '' +description 'Query/Use trocla (https://github.com/duritong/trocla) from puppet' @@ -0,0 +1,4 @@ +trocla + +This is the trocla module. It provides the necessary function to query +trocla from puppet, as well as a puppet class to setup things on the puppetmaster. diff --git a/lib/puppet/parser/functions/trocla.rb b/lib/puppet/parser/functions/trocla.rb new file mode 100644 index 0000000..9fa06bb --- /dev/null +++ b/lib/puppet/parser/functions/trocla.rb @@ -0,0 +1,7 @@ +module Puppet::Parser::Functions + newfunction(:trocla, :type => :rvalue) do |*args| + require File.dirname(__FILE__) + '/../../util/trocla_helper' + + Puppet::Util::TroclaHelper.trocla(:password,true,*args) + end +end
\ No newline at end of file diff --git a/lib/puppet/parser/functions/trocla_get.rb b/lib/puppet/parser/functions/trocla_get.rb new file mode 100644 index 0000000..ed8eeab --- /dev/null +++ b/lib/puppet/parser/functions/trocla_get.rb @@ -0,0 +1,9 @@ +module Puppet::Parser::Functions + newfunction(:trocla_get, :type => :rvalue) do |*args| + require File.dirname(__FILE__) + '/../../util/trocla_helper' + if (answer=Puppet::Util::TroclaHelper.trocla(:get_password,false,*args)).nil? + raise(Puppet::ParseError, "No password for key,format #{args.flatten.inspect} found!") + end + answer + end +end
\ No newline at end of file diff --git a/lib/puppet/util/trocla_helper.rb b/lib/puppet/util/trocla_helper.rb new file mode 100644 index 0000000..8187d08 --- /dev/null +++ b/lib/puppet/util/trocla_helper.rb @@ -0,0 +1,31 @@ +module Puppet::Util::TroclaHelper + def trocla(trocla_func,has_options,*args) + # Functions called from puppet manifests that look like this: + # lookup("foo", "bar") + # internally in puppet are invoked: func(["foo", "bar"]) + # + # where as calling from templates should work like this: + # scope.function_lookup("foo", "bar") + # + # Therefore, declare this function with args '*args' to accept any number + # of arguments and deal with puppet's special calling mechanism now: + if args[0].is_a?(Array) + args = args[0] + end + + key = args[0] || raise(Puppet::ParseError, "You need to pass at least a key as an argument!") + format = args[1] || 'plain' + options = args[2] || {} + + configfile = File.join(File.dirname(Puppet.settings[:config]), "trocla.yaml") + + raise(Puppet::ParseError, "Trocla config file #{configfile} not readable") unless File.exist?(configfile) + raise(Puppet::ParseError, "You need rubygems to use Trocla") unless Puppet.features.rubygems? + + require 'rubygems' + require 'trocla' + + has_options ? Trocla.new(configfile).send(trocla_func, key, format, options) : Trocla.new(configfile).send(trocla_func, key, format) + end + module_function :trocla +end
\ No newline at end of file diff --git a/manifests/config.pp b/manifests/config.pp new file mode 100644 index 0000000..3a4a356 --- /dev/null +++ b/manifests/config.pp @@ -0,0 +1,8 @@ +class trocla::config { + file{"${settings::confdir}/trocla.yaml": + source => [ "puppet:///modules/site-trocla/${fqdn}/trocla.yaml", + 'puppet:///modules/site-trocla/trocla.yaml' ], + require => Package['trocla'], + owner => root, group => puppet, mode => 0640; + } +} diff --git a/manifests/master.pp b/manifests/master.pp new file mode 100644 index 0000000..62c975e --- /dev/null +++ b/manifests/master.pp @@ -0,0 +1,17 @@ +# Class: trocla::master +# +# This module manages the necessary things for trocla on a master. +# +# [Remember: No empty lines between comments and class definition] +class trocla::master { + + require rubygems::moneta + require rubygems::highline + + package{'trocla': + ensure => present, + provider => gem, + } + + include trocla::config +} diff --git a/manifests/master/ree.pp b/manifests/master/ree.pp new file mode 100644 index 0000000..92cc07b --- /dev/null +++ b/manifests/master/ree.pp @@ -0,0 +1,14 @@ +# Class: trocla::master::ree +# +# This module manages the necessary things for trocla on a master. +# +# [Remember: No empty lines between comments and class definition] +class trocla::master::ree { + + require ruby-enterprise::gems::moneta + require ruby-enterprise::gems::highline + + ruby-enterprise::gem{'trocla': } + + include trocla::config +} diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..427a2e4 --- /dev/null +++ b/metadata.json @@ -0,0 +1,21 @@ +{ + "name": "duritong-trocla", + "author": "duritong", + "description": "Query/Use trocla (https://github.com/duritong/trocla) from puppet", + "license": "", + "project_page": "https://github.com/duritong/trocla", + "source": "https://github.com/duritong/puppet-trocla", + "summary": "", + "version": "0.0.1", + "checksums": { + "Modulefile": "431cf06775a63c7cffa657b0d0911efd", + "README": "d4025a6e12d37adb7b8317bc89a2f807", + "lib/puppet/parser/functions/trocla.rb": "9d9e2472b99079dcec1bcbb5e4e74db2", + "lib/puppet/parser/functions/trocla_get.rb": "2a140366c2506d93c9705ae3705942d2", + "lib/puppet/util/trocla_helper.rb": "7da306ce8fa229bdc6d0e37a50087a6a", + "manifests/config.pp": "2160ee7d4089d6c3d15379d2f9789242", + "manifests/master.pp": "938d8681cdc1f8fadc5c2dc63447ee64", + "manifests/master/ree.pp": "f48611c532170c9fb7f73017a8df1f6f" + }, + "dependencies": [] +}
\ No newline at end of file |