supply_drop 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # supply_drop
2
+
3
+ supply_drop is a capistrano plugin to facitiate provisioning servers with puppet, without using the puppet server. It works by simply rsyncing your puppet configuration files to your servers and running puppet apply. It strives to allow you to write idiomatic puppet scripts while being as lightweight as possible.
4
+
5
+ ### Installation
6
+
7
+ gem install supply_drop
8
+
9
+ or with Bundler
10
+
11
+ gem 'supply_drop'
12
+
13
+ then at the top of your deploy.rb
14
+
15
+ require 'rubygems'
16
+ require 'supply_drop'
17
+
18
+ ### Tasks
19
+
20
+ cap puppet:bootstrap
21
+
22
+ This does a simple apt-get install of puppet on the target servers.
23
+
24
+ cap puppet:noop
25
+
26
+ This will show you a list of the pending changes to be applied server-by-server.
27
+
28
+ cap puppet:apply
29
+
30
+ Applies the pending changes to all the servers.
31
+
32
+ You can specify that one of your servers should be puppet by setting the :nopuppet flag to true, like so. It will then be skipped by all the above commands.
33
+
34
+ role :wierd_thing, '33.33.33.33', :nopuppet => true
35
+
36
+ ### Variables
37
+
38
+ There are several variables that can be overriden to change how supply_drop works:
39
+
40
+ set :puppet_source, '.'
41
+
42
+ defines the base directory containing your puppet configs that will be rsynced to teh servers.
43
+
44
+ set :puppet_destination, '/tmp/supply_drop'
45
+
46
+ defines where on the server the puppet configuration files are synced to.
47
+
48
+ set :puppet_command, 'puppet'
49
+
50
+ allows you to override the puppet command that is run if puppet is not on the path.
51
+
52
+ set :puppet_lib, "#{puppet_target}/modules"
53
+
54
+ the value of the PUPPETLIB environment variable, the location of your puppet modules
55
+
56
+ set :puppet_parameters, 'puppet.pp'
57
+
58
+ the parameters that are passed to the puppet call.
59
+
60
+ ### How to contribute
61
+
62
+ If you write anything complicated, write a test for it. Test that your changes work using vagrant. Send a pull request. Easy peezy.
63
+
64
+ ### Contributors
65
+
66
+ Paul Gross [pgr0ss](https://github.com/pgr0ss "github")
data/Rakefile CHANGED
@@ -1,3 +1,11 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.test_files = FileList['test/*_test.rb']
5
+ end
6
+
7
+ task :default => :test
8
+
1
9
  desc "clean"
2
10
  task :clean do
3
11
  rm_f Dir.glob("*.gem")
@@ -0,0 +1,15 @@
1
+ # this is all to get vagrant working with capistrano
2
+ vagrant_gem = `gem which vagrant`.chomp
3
+ ssh_options[:keys] = File.expand_path('../../keys/vagrant', vagrant_gem)
4
+ ssh_options[:paranoid] = false
5
+ ssh_options[:keys_only] = true
6
+ ssh_options[:user_known_hosts_file] = []
7
+ ssh_options[:config] = false
8
+ set :user, 'vagrant'
9
+
10
+
11
+ $:.unshift File.expand_path('../../../lib', __FILE__) # in your Capfile, this would likely be "require 'rubygems'"
12
+ require 'supply_drop'
13
+
14
+ server '33.33.33.10', :web, :app
15
+ role :db, '33.33.33.11', :nopuppet => true
@@ -0,0 +1,6 @@
1
+ Vagrant::Config.run do |config|
2
+ config.vm.box = "lucid32"
3
+ config.vm.define(:web) { |c| c.vm.network("33.33.33.10") }
4
+ config.vm.define(:db) { |c| c.vm.network("33.33.33.11") }
5
+ end
6
+
@@ -0,0 +1 @@
1
+ exec { "/bin/echo hello:": }
@@ -0,0 +1,26 @@
1
+ class Rsync
2
+ class << self
3
+ def command(from, to, options={})
4
+ flags = ['-az']
5
+ flags << '--delete' if options[:delete]
6
+ flags << excludes(options[:excludes]) if options.has_key?(:excludes)
7
+ flags << ssh_options(options[:ssh]) if options.has_key?(:ssh)
8
+
9
+ "rsync #{flags.compact.join(' ')} #{from} #{to}"
10
+ end
11
+
12
+ def excludes(patterns)
13
+ [patterns].flatten.map { |p| "--exclude=#{p}" }
14
+ end
15
+
16
+ def ssh_options(options)
17
+ mapped_options = options.map do |key, value|
18
+ if key == :keys && value != nil
19
+ [value].flatten.select { |k| File.exist?(k) }.map { |k| "-i #{k}" }
20
+ end
21
+ end
22
+
23
+ %[-e "ssh #{mapped_options.join(' ')}"]
24
+ end
25
+ end
26
+ end
data/lib/supply_drop.rb CHANGED
@@ -1,8 +1,11 @@
1
+ require 'supply_drop/rsync'
2
+
1
3
  Capistrano::Configuration.instance.load do
2
4
  namespace :puppet do
3
- set :puppet_target, '/home/vagrant/supply_drop'
5
+ set :puppet_source, '.'
6
+ set :puppet_destination, '/tmp/supply_drop'
4
7
  set :puppet_command, 'puppet'
5
- set(:puppet_lib) { "#{puppet_target}/modules" }
8
+ set :puppet_lib, "#{puppet_destination}/modules"
6
9
  set :puppet_parameters, 'puppet.pp'
7
10
 
8
11
  desc "installs puppet"
@@ -14,7 +17,13 @@ Capistrano::Configuration.instance.load do
14
17
  desc "pushes the current puppet configuration to the server"
15
18
  task :update_code, :except => { :nopuppet => true } do
16
19
  find_servers_for_task(current_task).each do |server|
17
- rsync_cmd = "rsync -az --delete --exclude=.git -e 'ssh -i #{ssh_options[:keys]}' . #{server.user || user}@#{server.host}:#{puppet_target}/"
20
+ rsync_cmd = Rsync.command(
21
+ puppet_source,
22
+ "#{server.user || user}@#{server.host}:#{puppet_destination}/",
23
+ :delete => true,
24
+ :excludes => ['.git'],
25
+ :ssh => { :keys => ssh_options[:keys] }
26
+ )
18
27
  logger.debug rsync_cmd
19
28
  system rsync_cmd
20
29
  end
@@ -34,7 +43,7 @@ Capistrano::Configuration.instance.load do
34
43
  end
35
44
 
36
45
  def puppet(command = :noop)
37
- puppet_cmd = "cd #{puppet_target} && #{sudo} PUPPETLIB=#{puppet_lib} puppet #{puppet_parameters}"
46
+ puppet_cmd = "cd #{puppet_destination} && #{sudo} PUPPETLIB=#{puppet_lib} #{puppet_command} #{puppet_parameters}"
38
47
  flag = command == :noop ? '--noop' : ''
39
48
 
40
49
  outputs = {}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supply_drop
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Pitluga
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-20 00:00:00 -05:00
18
+ date: 2011-05-22 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -28,9 +28,13 @@ extensions: []
28
28
  extra_rdoc_files: []
29
29
 
30
30
  files:
31
- - README
31
+ - README.md
32
32
  - Rakefile
33
+ - lib/supply_drop/rsync.rb
33
34
  - lib/supply_drop.rb
35
+ - examples/capistrano/Capfile
36
+ - examples/capistrano/puppet.pp
37
+ - examples/capistrano/Vagrantfile
34
38
  has_rdoc: true
35
39
  homepage: http://github.com/pitluga/supply_drop
36
40
  licenses: []
@@ -61,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
65
  requirements: []
62
66
 
63
67
  rubyforge_project:
64
- rubygems_version: 1.4.1
68
+ rubygems_version: 1.6.0
65
69
  signing_key:
66
70
  specification_version: 3
67
71
  summary: Serverless puppet with capistrano
data/README DELETED
File without changes