supply_drop 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -0
- data/lib/supply_drop.rb +60 -4
- data/lib/supply_drop/rsync.rb +1 -0
- metadata +6 -8
data/README.md
CHANGED
@@ -35,6 +35,10 @@ Applies the pending changes to all the servers.
|
|
35
35
|
|
36
36
|
Locally syntax checks all the puppet files and erb templates. Requires you to have puppet installed locally.
|
37
37
|
|
38
|
+
cap puppet:remove_lock
|
39
|
+
|
40
|
+
Remove any stale lock files created by supply_drop when locking is used and something went wrong.
|
41
|
+
|
38
42
|
|
39
43
|
You can specify that one of your servers should not be puppeted by setting the :nopuppet flag to true, like so. It will then be skipped by all the above commands.
|
40
44
|
|
@@ -77,6 +81,10 @@ determines whether the rsync commands for multiple servers are run in parallel t
|
|
77
81
|
when true, will syntax check your puppet files and erb templates before rsyncing them to your servers. This is an
|
78
82
|
experimental feature and is quite slow at the moment.
|
79
83
|
|
84
|
+
set :puppet_stream_output, false
|
85
|
+
|
86
|
+
will write the incremental output from the hosts to the screen instead of waiting until complete and printing by host.
|
87
|
+
|
80
88
|
set :puppet_write_to_file, nil
|
81
89
|
|
82
90
|
a file to additionally write puppet output to, useful for large noops with small scrollbacks.
|
@@ -85,6 +93,10 @@ a file to additionally write puppet output to, useful for large noops with small
|
|
85
93
|
|
86
94
|
allows you to specify the user to execute the puppet command as. Like running sudo -u puppet args from the command line.
|
87
95
|
|
96
|
+
set :puppet_lock_file, '/tmp/puppet.lock'
|
97
|
+
|
98
|
+
sets a lockfile on each remote host to prevent multiple users from puppeting the same node simultaneously. Set to nil to disable locking. You can alternately temporarily disable locking by setting the NO_PUPPET_LOCKING environment variable to any value.
|
99
|
+
|
88
100
|
### Handling Legacy Puppet
|
89
101
|
|
90
102
|
Puppet deprecated the implicit invocation of apply [in the 2.6.x series](https://github.com/puppetlabs/puppet/commit/a23cfd869f90ae4456dded6e5a1c82719b128f01).
|
@@ -105,4 +117,5 @@ If you write anything complicated, write a test for it. Test that your changes w
|
|
105
117
|
* Paul Gross [pgr0ss](https://github.com/pgr0ss "github")
|
106
118
|
* Drew Olson [drewolson](https://github.com/drewolson "github")
|
107
119
|
* Dave Pirotte [dpirotte](https://github.com/dpirotte "github")
|
120
|
+
* Mike Pilat [mikepilat](https://github.com/mikepilat "github")
|
108
121
|
* Dan Manges [dan-manges](https://github.com/dan-manges "github") (one soda's worth)
|
data/lib/supply_drop.rb
CHANGED
@@ -20,6 +20,7 @@ Capistrano::Configuration.instance.load do
|
|
20
20
|
set :puppet_syntax_check, false
|
21
21
|
set :puppet_write_to_file, nil
|
22
22
|
set :puppet_runner, nil
|
23
|
+
set :puppet_lock_file, '/tmp/puppet.lock'
|
23
24
|
|
24
25
|
namespace :bootstrap do
|
25
26
|
desc "installs puppet via rubygems on an osx host"
|
@@ -72,6 +73,7 @@ Capistrano::Configuration.instance.load do
|
|
72
73
|
SupplyDrop::Rsync.remote_address(server.user || fetch(:user, ENV['USER']), server.host, puppet_destination),
|
73
74
|
:delete => true,
|
74
75
|
:excludes => puppet_excludes,
|
76
|
+
:world_writable => true,
|
75
77
|
:ssh => { :keys => ssh_options[:keys], :config => ssh_options[:config], :port => fetch(:port, nil) }
|
76
78
|
)
|
77
79
|
logger.debug rsync_cmd
|
@@ -85,17 +87,71 @@ Capistrano::Configuration.instance.load do
|
|
85
87
|
syntax_check if puppet_syntax_check
|
86
88
|
end
|
87
89
|
|
90
|
+
before 'puppet:noop' do
|
91
|
+
_lock if _should_lock?
|
92
|
+
end
|
93
|
+
|
94
|
+
before 'puppet:apply' do
|
95
|
+
_lock if _should_lock?
|
96
|
+
end
|
97
|
+
|
88
98
|
desc "runs puppet with --noop flag to show changes"
|
89
99
|
task :noop, :except => { :nopuppet => true } do
|
90
|
-
|
91
|
-
|
100
|
+
transaction do
|
101
|
+
on_rollback { _unlock }
|
102
|
+
update_code
|
103
|
+
_puppet :noop
|
104
|
+
end
|
92
105
|
end
|
93
106
|
|
94
107
|
desc "applies the current puppet config to the server"
|
95
108
|
task :apply, :except => { :nopuppet => true } do
|
96
|
-
|
97
|
-
|
109
|
+
transaction do
|
110
|
+
on_rollback { _unlock }
|
111
|
+
update_code
|
112
|
+
_puppet :apply
|
113
|
+
end
|
98
114
|
end
|
115
|
+
|
116
|
+
desc "clears the puppet lockfile on the server."
|
117
|
+
task :remove_lock, :except => { :nopuppet => true} do
|
118
|
+
_unlock
|
119
|
+
end
|
120
|
+
|
121
|
+
after 'puppet:noop' do
|
122
|
+
_unlock
|
123
|
+
end
|
124
|
+
|
125
|
+
after 'puppet:apply' do
|
126
|
+
_unlock
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def _red_text(text)
|
131
|
+
"\033[0;31m#{text}\033[0m"
|
132
|
+
end
|
133
|
+
|
134
|
+
def _lock
|
135
|
+
if puppet_lock_file
|
136
|
+
run <<-GETLOCK
|
137
|
+
if [ ! -f #{puppet_lock_file} ]; then
|
138
|
+
touch #{puppet_lock_file}
|
139
|
+
mkdir -p #{remote_puppet_destination}
|
140
|
+
chmod o+w #{remote_puppet_destination}
|
141
|
+
else
|
142
|
+
stat -c "#{_red_text("Puppet in progress, #{puppet_lock_file} owned by %U since %x")}" #{puppet_lock_file} >&2
|
143
|
+
exit 1
|
144
|
+
fi"
|
145
|
+
GETLOCK
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def _unlock
|
150
|
+
run "rm -f #{puppet_lock_file}; true" if _should_lock?
|
151
|
+
end
|
152
|
+
|
153
|
+
def _should_lock?
|
154
|
+
puppet_lock_file && !ENV['NO_PUPPET_LOCK']
|
99
155
|
end
|
100
156
|
|
101
157
|
def _puppet(command = :noop)
|
data/lib/supply_drop/rsync.rb
CHANGED
@@ -3,6 +3,7 @@ module SupplyDrop
|
|
3
3
|
class << self
|
4
4
|
def command(from, to, options={})
|
5
5
|
flags = ['-az']
|
6
|
+
flags << '--chmod=o+w' if options[:world_writable]
|
6
7
|
flags << '--delete' if options[:delete]
|
7
8
|
flags << excludes(options[:excludes]) if options.has_key?(:excludes)
|
8
9
|
flags << ssh_options(options[:ssh]) if options.has_key?(:ssh)
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 55
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 10
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.10.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tony Pitluga
|
@@ -16,8 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
20
|
-
default_executable:
|
19
|
+
date: 2012-06-26 00:00:00 Z
|
21
20
|
dependencies: []
|
22
21
|
|
23
22
|
description: See http://github.com/pitluga/supply_drop
|
@@ -1873,7 +1872,6 @@ files:
|
|
1873
1872
|
- examples/vendored-puppet/vendor/puppet-2.7.8/test/util/storage.rb
|
1874
1873
|
- examples/vendored-puppet/vendor/puppet-2.7.8/test/util/subclass_loader.rb
|
1875
1874
|
- examples/vendored-puppet/vendor/puppet-2.7.8/test/util/utiltest.rb
|
1876
|
-
has_rdoc: true
|
1877
1875
|
homepage: http://github.com/pitluga/supply_drop
|
1878
1876
|
licenses: []
|
1879
1877
|
|
@@ -1903,7 +1901,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1903
1901
|
requirements: []
|
1904
1902
|
|
1905
1903
|
rubyforge_project:
|
1906
|
-
rubygems_version: 1.
|
1904
|
+
rubygems_version: 1.8.17
|
1907
1905
|
signing_key:
|
1908
1906
|
specification_version: 3
|
1909
1907
|
summary: Masterless puppet with capistrano
|