Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

Commit

Permalink
Introduced new 'manifestpath' option to satisfy #28
Browse files Browse the repository at this point in the history
  • Loading branch information
simpsonjulian committed Jun 24, 2012
1 parent cf51e0b commit b59b8df
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 7 deletions.
5 changes: 4 additions & 1 deletion bin/skewer
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ desc 'mock every fog call'
default_value false
flag [:m,:mock]

desc 'Location of manifest'
flag [:mp,:manifestpath]

desc 'Update the puppet code on a machine that you have already provisioned'
command :update do |c|
c.desc 'Host to update'
Expand Down Expand Up @@ -138,4 +141,4 @@ on_error do |exception|
true
end

exit GLI.run(ARGV)
exit GLI.run(ARGV)
26 changes: 26 additions & 0 deletions features/puppet_options.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Feature: Puppet Options
In order to run Puppet in a way that suits me
As a systems administrator
I want to pass options to puppet

@announce-stdout
@announce-stderr
Scenario: Set Manifest Path
Given I have puppet code in "/tmp/more_skewer_test_code"
And a file named ".skewer.json" with:
"""
{"puppet_repo":"/tmp/skewer_test_code"}
"""
When I run `./bin/skewer --manifestpath=foo/bar.pp provision --cloud=stub --role=foobar --image=ami-deadbeef`
Then the stdout should contain "Using manifest foo/bar.pp"

@announce-stdout
@announce-stderr
Scenario: Set Manifest Path
Given I have puppet code in "/tmp/more_skewer_test_code"
And a file named ".skewer.json" with:
"""
{"puppet_repo":"/tmp/skewer_test_code"}
"""
When I run `./bin/skewer provision --cloud=stub --role=foobar --image=ami-deadbeef`
Then the stdout should contain "Using manifest manifests/site.pp"
10 changes: 5 additions & 5 deletions lib/skewer/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ def initialize
@configs = {}
reset
read_config_files

end

def reset
@configs[:puppet_repo] = '../infrastructure'
@configs[:region] = 'us-east-1'
@configs[:flavor_id] = 'm1.large'
@configs[:aws_username] = 'ubuntu'
@configs[:puppet_repo] = '../infrastructure'
@configs[:region] = 'us-east-1'
@configs[:flavor_id] = 'm1.large'
@configs[:aws_username] = 'ubuntu'
@configs[:manifestpath] = 'manifests/site.pp'
end

def read_config_file(config_file)
Expand Down
4 changes: 3 additions & 1 deletion lib/skewer/puppet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def arguments
end

def command_string(username, options)
manifest = config.manifestpath
logger.debug "Using manifest #{manifest}"
@command_line = "cd infrastructure"
if username == 'root'
@command_line << " &&"
Expand All @@ -26,7 +28,7 @@ def command_string(username, options)
end
@command_line << " #{@installer.executable}"
@command_line << " puppet apply"
@command_line << " manifests/site.pp"
@command_line << " #{manifest}"
@command_line << " --color false"
@command_line << " #{arguments}"
if options[:noop]
Expand Down
16 changes: 16 additions & 0 deletions spec/puppet_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
require 'skewer/puppet'

class ConfigProxy
# TODO: work out why rspec tests can't load the skewer module'
include Skewer
def set(var, val)
config.set(var, val)
end
end

describe Skewer::Puppet do

before(:each) do
Expand Down Expand Up @@ -27,6 +35,14 @@
@puppet.command_string('root', {:noop => true}).should == "#{@prefix} --modulepath modules --vardir /var/lib/puppet --noop"
end

it "should have a variable puppet manifest path" do
require 'skewer/skewer'
ConfigProxy.new.set :manifestpath, 'my_great_manifests/main.pp'
prefix = "cd infrastructure && /usr/local/bin/bundle exec puppet apply my_great_manifests/main.pp --color false"
@puppet.command_string('root', {}).should == "#{prefix} --modulepath modules --vardir /var/lib/puppet"

end

it "should blow up if something fails" do
node = mock('node')
result = stub('result')
Expand Down

0 comments on commit b59b8df

Please sign in to comment.