diff --git a/README.md b/README.md new file mode 100644 index 0000000..f2f2735 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +Reapply your Puppet configs automatically using Guard! Awesome! + +``` ruby +guard 'puppet', :verbose => true, :manifest => 'manifests/site.pp' do + watch(%r{^(manifests|modules)}) +end +``` + +It's assumed your configs are all in the current folder, which is the +equivalent of `--confdir=$PWD` at the command line. Otherwise, +there's not much use of using Guard with Puppet. :) + +Two options so far: + +* `:verbose`: Show more output from Puppet (default: `true`) +* `:manifest`: The main manifest file to run (default: `manifests/site.pp`) + +Bugs and fixes? You know the drill. + diff --git a/lib/guard/puppet/runner.rb b/lib/guard/puppet/runner.rb index bef3e44..1c7bf98 100644 --- a/lib/guard/puppet/runner.rb +++ b/lib/guard/puppet/runner.rb @@ -8,7 +8,10 @@ module Guard attr_reader :options def initialize(options) - @options = options + @options = { + :verbose => true, + :manifest => 'manifests/site.pp' + }.merge(options) end def run @@ -18,12 +21,8 @@ module Guard end def command_line_params - command = [ "apply" ] + command = [ "apply", %{--confdir="#{Dir.pwd}"} ] command << "-v" if @options[:verbose] - if @options[:config_dir] - @options[:config_dir] = Dir.pwd if @options[:config_dir] == true - command << %{--confdir="#{@options[:config_dir]}"} if @options[:config_dir] - end command << @options[:manifest] if @options[:manifest] command end diff --git a/lib/guard/puppet/templates/Guardfile b/lib/guard/puppet/templates/Guardfile new file mode 100644 index 0000000..cb36e72 --- /dev/null +++ b/lib/guard/puppet/templates/Guardfile @@ -0,0 +1,4 @@ +guard 'puppet' do + watch(%r{^(manifests|modules)}) +end + diff --git a/spec/lib/guard/puppet/runner_spec.rb b/spec/lib/guard/puppet/runner_spec.rb index d5ca8d6..e710d8f 100644 --- a/spec/lib/guard/puppet/runner_spec.rb +++ b/spec/lib/guard/puppet/runner_spec.rb @@ -9,31 +9,19 @@ describe Guard::Puppet::Runner do subject { runner.command_line_params } context 'default' do - it { should == [ 'apply' ] } + it { should == [ 'apply', %{--confdir="#{Dir.pwd}"}, '-v', 'manifests/site.pp' ] } end - context 'verbose' do - let(:options) { { :verbose => true } } + context 'not verbose' do + let(:options) { { :verbose => false } } - it { should == [ 'apply', '-v' ] } - end - - context 'config dir with path' do - let(:options) { { :config_dir => '/123' } } - - it { should == [ 'apply', '--confdir="/123"' ] } - end - - context 'config dir with true' do - let(:options) { { :config_dir => true } } - - it { should == [ 'apply', %{--confdir="#{Dir.pwd}"} ] } + it { should == [ 'apply', %{--confdir="#{Dir.pwd}"}, 'manifests/site.pp' ] } end context 'manifest' do let(:options) { { :manifest => '123' } } - it { should == [ 'apply', '123' ] } + it { should == [ 'apply', %{--confdir="#{Dir.pwd}"}, '-v', '123' ] } end end