syncwrap 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.rdoc +7 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +1 -0
- data/Rakefile +18 -0
- data/examples/LAYOUT.rdoc +26 -14
- data/examples/db_setup.rb +16 -0
- data/lib/syncwrap/amazon_ec2.rb +1 -1
- data/lib/syncwrap/amazon_ws.rb +1 -1
- data/lib/syncwrap/base.rb +1 -1
- data/lib/syncwrap/cli.rb +3 -3
- data/lib/syncwrap/components/iyyov_daemon.rb +17 -15
- data/lib/syncwrap/components/jruby_vm.rb +1 -1
- data/lib/syncwrap/components/mdraid.rb +5 -5
- data/lib/syncwrap/components/run_user.rb +15 -8
- data/lib/syncwrap/components/users.rb +1 -1
- data/lib/syncwrap/context.rb +5 -1
- data/lib/syncwrap/rsync.rb +2 -2
- data/lib/syncwrap.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8747b0974cbb0b64ec21384e0e9f76edce077a6
|
4
|
+
data.tar.gz: df3d730eaa4ba91b3fc70ea80a9a74efd0f509e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26144f170e5a161982eec15e0f7b8b901c4b5a3eb2c73a36991aae6eab7a16476a9d0304d6ebf8b72ddd8fab214729563046f259f05b7a00c355a128f00dc1dd
|
7
|
+
data.tar.gz: 11f3c42c8f174332aaed9391228c8d97efe19734c67b2023c2a4164e32734a311c42a9b8cac9a5d80c10f0362c435ed7e582f1686624cf1223b42720339065d9
|
data/History.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 2.1.1 (2014-4-15)
|
2
|
+
* Use 'syncwrap-' as tmpdir prefix.
|
3
|
+
* Fix Users, RunUser use of useradd, adding -s and -m options, for
|
4
|
+
Ubuntu (where bash shell is not default)
|
5
|
+
* Add RunUser.run_user_home option; no change in default
|
6
|
+
* IyyovDaemon: handle case of non-version related job changes
|
7
|
+
|
1
8
|
=== 2.1.0 (2014-3-5)
|
2
9
|
* Simplify existing state handling (i.e. Ubuntu.first_apt?, Users
|
3
10
|
:just_created) by introducing SyncWrap::Component#state
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -6,3 +6,21 @@ require 'bundler/setup'
|
|
6
6
|
require 'rjack-tarpit'
|
7
7
|
|
8
8
|
RJack::TarPit.new( 'syncwrap' ).define_tasks
|
9
|
+
|
10
|
+
desc "Upload RDOC to Amazon S3 (rdoc.gravitext.com/syncwrap, Oregon)"
|
11
|
+
task :publish_rdoc => [ :clean, :rerdoc ] do
|
12
|
+
mime_types = {
|
13
|
+
'*.html' => 'text/html; charset=utf-8',
|
14
|
+
'*.css' => 'text/css',
|
15
|
+
'*.js' => 'text/javascript',
|
16
|
+
'*.png' => 'image/png',
|
17
|
+
'*.gif' => 'image/gif',
|
18
|
+
}
|
19
|
+
mime_types.each do |pat, mime_type|
|
20
|
+
sh <<-SH
|
21
|
+
s3cmd sync -P --exclude '*.*' --include '#{pat}' \
|
22
|
+
-m '#{mime_type}' \
|
23
|
+
doc/ s3://rdoc.gravitext.com/syncwrap/
|
24
|
+
SH
|
25
|
+
end
|
26
|
+
end
|
data/examples/LAYOUT.rdoc
CHANGED
@@ -16,6 +16,7 @@ by multiple examples.
|
|
16
16
|
Here is what a complete end-user project setup might look like:
|
17
17
|
|
18
18
|
deploy/
|
19
|
+
├── Gemfile
|
19
20
|
├── lib/
|
20
21
|
│ └── my_component.rb
|
21
22
|
├── .gitignore
|
@@ -24,23 +25,33 @@ Here is what a complete end-user project setup might look like:
|
|
24
25
|
│ └── sec.pem
|
25
26
|
├── sync.rb
|
26
27
|
└── sync/
|
27
|
-
├── home
|
28
|
-
│ └── bob
|
29
|
-
│ └── .ssh
|
28
|
+
├── home/
|
29
|
+
│ └── bob/
|
30
|
+
│ └── .ssh/
|
30
31
|
│ └── authorized_keys
|
31
|
-
└──
|
32
|
-
└──
|
32
|
+
└── var/
|
33
|
+
└── my_server/
|
34
|
+
└── config.rb.erb
|
33
35
|
|
34
36
|
sync.rb:: The aforementioned default named sync-file, containing
|
35
37
|
roles, components, hosts, and possibly profiles.
|
36
38
|
|
37
39
|
sync/:: The default named sync root containing a tree of static files
|
38
|
-
and templates for pushing to hosts
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
and templates for pushing to hosts via
|
41
|
+
SyncWrap::Component#rput. The sub-directory structure
|
42
|
+
generally mimics the rput remote locations. See the rput.rb
|
43
|
+
example for usage. The local sync root can contain overrides
|
44
|
+
to the syncwrap gem provided files/directories as well as new
|
45
|
+
files.
|
46
|
+
|
47
|
+
sync/home/:: Default location for SyncWrap::Users provisioned
|
48
|
+
developer home directories (for ssh authorized_keys at
|
49
|
+
minimum).
|
50
|
+
|
51
|
+
sync/var/:: Conventional location for daemon-component configuration
|
52
|
+
or other deployed files and templates (*.erb). Note that
|
53
|
+
with SyncWrap::RunUser at least, this maps by default to
|
54
|
+
the remote /var/local/runr directory.
|
44
55
|
|
45
56
|
lib/:: Place project-specific components here. Once these are
|
46
57
|
non-trivial its nicer to `require_relative` them into the
|
@@ -63,8 +74,9 @@ private/:: This directory is for sensitive files like credentials that
|
|
63
74
|
...which ignores and avoids check-in by mistake of any so
|
64
75
|
named sub-directory and its contents.
|
65
76
|
|
77
|
+
Gemfile:: Include a bundler Gemfile for precise version control of all
|
78
|
+
gems involved, including syncwrap.
|
79
|
+
|
66
80
|
Without the private/ directories and sync.rb file, and adjusting lib/
|
67
81
|
accordingly, you could also package this as a gem. This makes it easy
|
68
|
-
to reuse components and files/templates across projects.
|
69
|
-
bundler Gemfile in each deploy directory for precise version control
|
70
|
-
of all gems involved, including syncwrap.
|
82
|
+
to reuse components and files/templates across projects.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class MyDatabase < SyncWrap::Component
|
2
|
+
def install
|
3
|
+
%w[ bob joanne ].each { |u| pg_create_user( u ) }
|
4
|
+
end
|
5
|
+
|
6
|
+
def pg_create_user( user, flags=[] )
|
7
|
+
sql_test = "SELECT count(*) FROM pg_user WHERE usename = '#{user}'"
|
8
|
+
sh( <<-SH, user: 'postgres' )
|
9
|
+
if [[ $(psql -tA -c "#{sql_test}") == "0" ]]; then
|
10
|
+
createuser #{flags.join ' '} #{user}
|
11
|
+
fi
|
12
|
+
SH
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
host 'localhost', MyDatabase.new
|
data/lib/syncwrap/amazon_ec2.rb
CHANGED
@@ -286,7 +286,7 @@ module SyncWrap
|
|
286
286
|
echo 'Defaults:#{user} !requiretty' >> /etc/sudoers.d/#{user}
|
287
287
|
chmod 440 /etc/sudoers.d/#{user}
|
288
288
|
SH
|
289
|
-
script.split( "\n" ).map
|
289
|
+
script.split( "\n" ).map( &:strip ).join( "\n" )
|
290
290
|
end
|
291
291
|
|
292
292
|
end
|
data/lib/syncwrap/amazon_ws.rb
CHANGED
data/lib/syncwrap/base.rb
CHANGED
data/lib/syncwrap/cli.rb
CHANGED
@@ -282,10 +282,10 @@ TEXT
|
|
282
282
|
|
283
283
|
def list_roles( hosts, multi )
|
284
284
|
puts "Included Roles:" if multi
|
285
|
-
roles = hosts.map
|
285
|
+
roles = hosts.map( &:roles ).inject([],:|)
|
286
286
|
table = roles.map do |role|
|
287
287
|
row = [ ':' + role.to_s ]
|
288
|
-
classes = space.role( role ).map
|
288
|
+
classes = space.role( role ).map( &:class )
|
289
289
|
row << short_class_names( classes ).join(' ')
|
290
290
|
end
|
291
291
|
print_table( table )
|
@@ -309,7 +309,7 @@ TEXT
|
|
309
309
|
end
|
310
310
|
|
311
311
|
def print_table( table )
|
312
|
-
max_columns = table.map
|
312
|
+
max_columns = table.map( &:count ).max || 0
|
313
313
|
col_widths = max_columns.times.map do |i|
|
314
314
|
table.map { |row| row[i] && row[i].length }.compact.max
|
315
315
|
end
|
@@ -70,24 +70,26 @@ module SyncWrap
|
|
70
70
|
def standard_install
|
71
71
|
|
72
72
|
create_service_dir( name, instance )
|
73
|
-
|
73
|
+
conf_changes = rput_service_config
|
74
74
|
|
75
|
-
# Shorten if the desired versioned process is already running.
|
76
75
|
pid, ver = capture_running_version( name, instance )
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
76
|
+
|
77
|
+
gem_install( gem_name, version: version ) if ver != version
|
78
|
+
|
79
|
+
# The job_source may contain more than just this daemon
|
80
|
+
# (i.e. additional tasks, etc.) Even if this is the
|
81
|
+
# default/daemon.rb.erb, it might have just been changed to
|
82
|
+
# that. So go ahead an rput in any case.
|
83
|
+
job_changes = rput( job_source,
|
84
|
+
"#{iyyov_run_dir}/jobs.d/#{name_instance}.rb",
|
85
|
+
user: run_user )
|
86
|
+
job_changes += iyyov_install_jobs
|
84
87
|
|
85
88
|
# If we found a daemon pid then kill if either:
|
86
89
|
#
|
87
|
-
# (1) the version is the same
|
88
|
-
#
|
89
|
-
#
|
90
|
-
# should be up to restart the daemon.
|
90
|
+
# (1) the version is the same but there was a config change or
|
91
|
+
# hashdot was updated (i.e. new jruby version). In this case
|
92
|
+
# Iyyov should be up to restart the daemon.
|
91
93
|
#
|
92
94
|
# (2) We are :imaging, in which case we want a graceful
|
93
95
|
# shutdown. In this case Iyyov should have already been kill
|
@@ -97,13 +99,13 @@ module SyncWrap
|
|
97
99
|
# already stopped (i.e. crashed, etc) between above pid capture
|
98
100
|
# and the kill. Ignore kill failures.
|
99
101
|
if pid &&
|
100
|
-
( ( ver == version && ( !
|
102
|
+
( ( ver == version && ( !conf_changes.empty? ||
|
101
103
|
state[ :hashdot_updated ] ) ) ||
|
102
104
|
state[ :imaging ] )
|
103
105
|
rudo( "kill #{pid} || true" )
|
104
106
|
end
|
105
107
|
|
106
|
-
|
108
|
+
conf_changes + job_changes
|
107
109
|
end
|
108
110
|
|
109
111
|
def rput_service_config
|
@@ -58,10 +58,11 @@ module SyncWrap
|
|
58
58
|
attr_accessor :raid_chunk
|
59
59
|
|
60
60
|
# A table of [ slice, path (,name) ] rows where; slice is a
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
61
|
+
# Numeric in range (0.0..1.0), path is the mount point, and name
|
62
|
+
# is the lvm name, defaulting if omitted to the last path
|
63
|
+
# element. The sum of all slice values in the table should be 1.0,
|
64
|
+
# unless unallocated space is desired.
|
65
|
+
# Default: [ [ 1.0, '/data' ] ]
|
65
66
|
attr_accessor :lvm_volumes
|
66
67
|
|
67
68
|
# File System Type. Default: 'ext4'
|
@@ -154,7 +155,6 @@ module SyncWrap
|
|
154
155
|
|
155
156
|
def create_raid( md )
|
156
157
|
rlevel = raid_level || default_raid_level
|
157
|
-
|
158
158
|
sudo <<-SH
|
159
159
|
mdadm --create #{md} --level=#{rlevel} --chunk=#{raid_chunk} \
|
160
160
|
--raid-devices=#{raw_devices.count} #{raw_devices.join ' '}
|
@@ -25,7 +25,7 @@ module SyncWrap
|
|
25
25
|
# A user for running deployed daemons, jobs (default: 'runr')
|
26
26
|
attr_accessor :run_user
|
27
27
|
|
28
|
-
# A group for running (default: nil -> same as run_user)
|
28
|
+
# A group for running (default: nil -> same as #run_user)
|
29
29
|
attr_accessor :run_group
|
30
30
|
|
31
31
|
# Root directory for persistent data and logs
|
@@ -36,11 +36,19 @@ module SyncWrap
|
|
36
36
|
@run_dir || "/var/local/#{run_user}"
|
37
37
|
end
|
38
38
|
|
39
|
+
# Home directory for the #run_user
|
40
|
+
# (default: nil -> unspecified)
|
41
|
+
attr_writer :run_user_home
|
42
|
+
|
43
|
+
def run_user_home
|
44
|
+
@run_user_home
|
45
|
+
end
|
46
|
+
|
39
47
|
def initialize( opts = {} )
|
40
48
|
@run_user = 'runr'
|
41
49
|
@run_group = nil
|
42
50
|
@run_dir = nil
|
43
|
-
|
51
|
+
@run_user_home = nil
|
44
52
|
super
|
45
53
|
end
|
46
54
|
|
@@ -52,14 +60,13 @@ module SyncWrap
|
|
52
60
|
# Create run_user if not already present
|
53
61
|
def create_run_user
|
54
62
|
sudo( "if ! id #{run_user} >/dev/null 2>&1; then", close: "fi" ) do
|
63
|
+
user_opts = "-c 'Run User' -s /bin/bash"
|
64
|
+
user_opts += " -d #{run_user_home}" if run_user_home
|
55
65
|
if run_group && run_group != run_user
|
56
|
-
sudo
|
57
|
-
|
58
|
-
useradd -g #{run_group} #{run_user}
|
59
|
-
SH
|
60
|
-
else
|
61
|
-
sudo "useradd #{run_user}"
|
66
|
+
sudo "groupadd -f #{run_group}"
|
67
|
+
user_opts += " -g #{run_group}"
|
62
68
|
end
|
69
|
+
sudo "useradd #{user_opts} #{run_user}"
|
63
70
|
end
|
64
71
|
end
|
65
72
|
|
data/lib/syncwrap/context.rb
CHANGED
data/lib/syncwrap/rsync.rb
CHANGED
@@ -159,7 +159,7 @@ module SyncWrap
|
|
159
159
|
def process_templates( srcs, opts ) # :doc:
|
160
160
|
bnd = opts[ :erb_binding ] or raise "required :erb_binding param missing"
|
161
161
|
erb_mode = opts[ :erb_mode ] || '<>' #Trim new line on "<% ... %>\n"
|
162
|
-
mktmpdir( 'syncwrap' ) do |tmp_dir|
|
162
|
+
mktmpdir( 'syncwrap-' ) do |tmp_dir|
|
163
163
|
processed_sources = []
|
164
164
|
out_dir = File.join( tmp_dir, 'd' ) #for default perms
|
165
165
|
srcs.each do |src|
|
@@ -197,7 +197,7 @@ module SyncWrap
|
|
197
197
|
FileUtils.mkdir_p( newdir, mode: 0700 )
|
198
198
|
ENV['TMPDIR'] = newdir
|
199
199
|
end
|
200
|
-
Dir.mktmpdir(
|
200
|
+
Dir.mktmpdir( prefix ) do |tmp_dir|
|
201
201
|
yield tmp_dir
|
202
202
|
end
|
203
203
|
ensure
|
data/lib/syncwrap.rb
CHANGED
@@ -188,9 +188,9 @@ module SyncWrap
|
|
188
188
|
# roles, currently contained by the specified hosts or all hosts.
|
189
189
|
def component_classes( hs = hosts )
|
190
190
|
hs.
|
191
|
-
map
|
191
|
+
map( &:components ).
|
192
192
|
flatten.
|
193
|
-
map
|
193
|
+
map( &:class ).
|
194
194
|
uniq
|
195
195
|
end
|
196
196
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syncwrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Kellum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- bin/syncwrap
|
171
171
|
- examples/LAYOUT.rdoc
|
172
172
|
- examples/Rakefile
|
173
|
+
- examples/db_setup.rb
|
173
174
|
- examples/ec2.rb
|
174
175
|
- examples/hello.rb
|
175
176
|
- examples/hello_binding.rb
|