Permalink
Browse files

Merge pull request #63 from agx/issue/62

Allow to set up pre conditions from an array
  • Loading branch information...
2 parents 695b9a4 + 98bb99e commit ea2a2a3d914b737974eecf066964c57e28b8ee8e Tim Sharpe committed Nov 17, 2012
@@ -31,7 +31,11 @@ def catalogue
end
if self.respond_to? :pre_condition
- pre_cond = pre_condition
+ if pre_condition.kind_of?(Array)
+ pre_cond = pre_condition.join("\n")
+ else
+ pre_cond = pre_condition
+ end
else
pre_cond = ''
end
@@ -39,7 +39,11 @@ def catalogue
end
if self.respond_to? :pre_condition
- pre_cond = pre_condition
+ if pre_condition.kind_of?(Array)
+ pre_cond = pre_condition.join("\n")
+ else
+ pre_cond = pre_condition
+ end
else
pre_cond = ""
end
@@ -14,7 +14,11 @@ def subject
# if we specify a pre_condition, we should ensure that we compile that code
# into a catalog that is accessible from the scope where the function is called
if self.respond_to? :pre_condition
- Puppet[:code] = pre_condition
+ if pre_condition.kind_of?(Array)
+ Puppet[:code] = pre_condition.join("\n")
+ else
+ Puppet[:code] = pre_condition
+ end
nodename = self.respond_to?(:node) ? node : Puppet[:certname]
facts_val = {
'hostname' => nodename.split('.').first,
@@ -13,7 +13,9 @@
describe 'sysctl::before' do
let(:title) { 'test define' }
- let(:pre_condition) { 'class {"sysctl::common":}' }
+ let(:pre_condition) {
+ [ '# we need sysctl common',
+ 'class {"sysctl::common":}' ] }
let(:params) { { :value => "title" } }
it { should create_resource("sysctl::before", 'test define')\

0 comments on commit ea2a2a3

Please sign in to comment.