shadow_puppet 0.1.12 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
data/lib/shadow_puppet.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require File.join(File.dirname(__FILE__) + '/shadow_puppet', 'core_ext.rb')
1
2
  require File.join(File.dirname(__FILE__) + '/shadow_puppet', 'manifest.rb')
2
3
 
3
4
  class ShadowPuppet::Manifest::Setup < ShadowPuppet::Manifest
@@ -5,17 +6,20 @@ class ShadowPuppet::Manifest::Setup < ShadowPuppet::Manifest
5
6
 
6
7
  def setup_directories()
7
8
  if Process.uid == 0
8
- file "/var/puppet",
9
+ file "/var/shadow_puppet",
10
+ :ensure => "directory",
11
+ :backup => false
12
+ file "/etc/shadow_puppet",
9
13
  :ensure => "directory",
10
14
  :backup => false
11
15
  else
12
- file ENV["HOME"] + "/.puppet",
16
+ file ENV["HOME"] + "/.shadow_puppet",
13
17
  :ensure => "directory",
14
18
  :backup => false
15
- file ENV["HOME"] + "/.puppet/var",
19
+ file ENV["HOME"] + "/.shadow_puppet/var",
16
20
  :ensure => "directory",
17
21
  :backup => false,
18
- :require => file(ENV["HOME"] + "/.puppet")
22
+ :require => file(ENV["HOME"] + "/.shadow_puppet")
19
23
  end
20
24
  end
21
25
  end
@@ -1,15 +1,5 @@
1
1
  require 'puppet'
2
2
  require 'erb'
3
- gem "activesupport"
4
- require 'active_support/core_ext/class/attribute_accessors'
5
- require 'active_support/core_ext/array'
6
- require 'active_support/inflector'
7
- require 'active_support/core_ext/hash/indifferent_access'
8
- require 'active_support/core_ext/class/inheritable_attributes'
9
- require 'active_support/core_ext/duplicable'
10
- class Hash #:nodoc:
11
- include ActiveSupport::CoreExtensions::Hash::IndifferentAccess
12
- end
13
3
 
14
4
  module ShadowPuppet
15
5
  # A Manifest is an executable collection of Puppet Resources[http://reductivelabs.com/trac/puppet/wiki/TypeReference].
@@ -94,9 +84,12 @@ module ShadowPuppet
94
84
  # config hash, which is immediately passed on to the configure
95
85
  # method
96
86
  def initialize(config = {})
97
- unless Process.uid == 0
98
- Puppet[:confdir] = File.expand_path("~/.puppet")
99
- Puppet[:vardir] = File.expand_path("~/.puppet/var")
87
+ if Process.uid == 0
88
+ Puppet[:confdir] = File.expand_path("/etc/shadow_puppet")
89
+ Puppet[:vardir] = File.expand_path("/var/shadow_puppet")
90
+ else
91
+ Puppet[:confdir] = File.expand_path("~/.shadow_puppet")
92
+ Puppet[:vardir] = File.expand_path("~/.shadow_puppet/var")
100
93
  end
101
94
  Puppet[:user] = Process.uid
102
95
  Puppet[:group] = Process.gid
@@ -112,12 +105,17 @@ module ShadowPuppet
112
105
  # Declares that the named method or methods will be called whenever
113
106
  # execute is called on an instance of this class. If the last argument is
114
107
  # a Hash, this hash is passed as an argument to all provided methods.
108
+ # If no options hash is provided, each method is passed the contents of
109
+ # <tt>configuration[method]</tt>.
110
+ #
115
111
  # Subclasses of the Manifest class properly inherit the parent classes'
116
112
  # calls to recipe.
117
113
  def self.recipe(*methods)
118
114
  return nil if methods.nil? || methods == []
119
115
  options = methods.extract_options!
120
116
  methods.each do |meth|
117
+ options = self.configuration[meth.to_sym] if options == {}
118
+ options ||= {}
121
119
  recipes << [meth.to_sym, options]
122
120
  end
123
121
  end
@@ -155,10 +153,11 @@ module ShadowPuppet
155
153
  # >> SampleManifest.configuration
156
154
  # => {"name" => 'test'}
157
155
  #
158
- # Subsequent calls to configure perform a merge of the
156
+ # Subsequent calls to configure perform a deep_merge of the
159
157
  # provided <tt>hash</tt> into the pre-existing configuration
160
158
  def self.configure(hash)
161
- write_inheritable_attribute(:configuration, configuration.merge(hash))
159
+ hash ||= HashWithIndifferentAccess.new
160
+ write_inheritable_attribute(:configuration, hash.deep_merge(configuration))
162
161
  end
163
162
  class << self
164
163
  alias_method :configuration=, :configure
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shadow_puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Newland
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-27 00:00:00 -05:00
12
+ date: 2009-03-04 00:00:00 -05:00
13
13
  default_executable: shadow_puppet
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency