rearrange and simplify things for the most common use case
This commit is contained in:
parent
3ce23fab9f
commit
128a393a61
19
README.md
Normal file
19
README.md
Normal file
@ -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.
|
||||
|
@ -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
|
||||
|
4
lib/guard/puppet/templates/Guardfile
Normal file
4
lib/guard/puppet/templates/Guardfile
Normal file
@ -0,0 +1,4 @@
|
||||
guard 'puppet' do
|
||||
watch(%r{^(manifests|modules)})
|
||||
end
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user