syncwrap 2.9.1 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +30 -7
- data/Manifest.txt +1 -0
- data/lib/syncwrap/base.rb +1 -1
- data/lib/syncwrap/component.rb +19 -0
- data/lib/syncwrap/components/arch.rb +2 -4
- data/lib/syncwrap/components/commercial_jdk.rb +1 -1
- data/lib/syncwrap/components/cruby_vm.rb +9 -3
- data/lib/syncwrap/components/debian.rb +20 -14
- data/lib/syncwrap/components/jruby_vm.rb +6 -5
- data/lib/syncwrap/components/lvm_cache.rb +1 -1
- data/lib/syncwrap/components/mdraid.rb +1 -4
- data/lib/syncwrap/components/postgresql.rb +1 -1
- data/lib/syncwrap/components/rake_gem.rb +19 -6
- data/lib/syncwrap/components/rhel.rb +1 -2
- data/lib/syncwrap/components/run_user.rb +1 -1
- data/lib/syncwrap/components/tarpit_gem.rb +2 -2
- data/lib/syncwrap/components/time_checker.rb +107 -0
- data/lib/syncwrap/systemd_service.rb +14 -2
- data/lib/syncwrap.rb +1 -0
- metadata +26 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b332ef7c3b7cd3a26930594f9ff9d0e22054295
|
4
|
+
data.tar.gz: a8ef0a95a638f7449dda4ab994be73bc9e08f8af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 448c97cf5df5774e541c57297bb0c4224dc278068551d06031175e9179b9418dfdb098792643b61af19ef3dd492c263e03946147fb2923932395d4fa8cd069aa
|
7
|
+
data.tar.gz: cb9bd08e0b91b65df2bf86bbd99183126ed8ab83c421a2a88fb257e22c6b4af268fc1eb115f328f31f04f0ae2844a91b7d1339b0bee78f2aefb8c17287e1d462
|
data/History.rdoc
CHANGED
@@ -1,12 +1,35 @@
|
|
1
|
+
=== 2.10.0 (2017-10-26)
|
2
|
+
* SyncWrap::Debian: dist_update condition based on local context
|
3
|
+
hasn't worked properly since 2.7.0, when remote conditional install
|
4
|
+
was implemented. Fix this by using a remote lock file and running
|
5
|
+
prior to any install (inside install conditional) if it hasn't been
|
6
|
+
run in last 1 hour by syncwrap.
|
7
|
+
* Add SyncWrap::Component#sh_if, sudo_if, and rudo_if helper methods
|
8
|
+
for common bash conditionals. Using these where applicable to
|
9
|
+
simplify various internal components.
|
10
|
+
* Add SyncWrap::SystemDService#enable and disable commands
|
11
|
+
* Add SyncWrap::TimeChecker utility component
|
12
|
+
* SyncWrap::CRubyVM
|
13
|
+
* Add hashes for 2.2.8, 2.3.5 and 2.4.2
|
14
|
+
* Update default version to 2.3.5
|
15
|
+
* SyncWrap::JRubyVM; Add hash for 9.1.13.0 and make it the default
|
16
|
+
* SyncWrap::TarpitGem; default version 2.1.2
|
17
|
+
* SyncWrap::RakeGem; default version 12.1.0, support user_install
|
18
|
+
* Expand transitive dependency constraints for new releases:
|
19
|
+
term-ansicolor, tins, json and nokogiri. The latest of tins and
|
20
|
+
nokogiri are incompatible with jruby 1.7.x (in 1.9 mode) which
|
21
|
+
prompts dropping jruby 1.7.x from syncwrap's Travis CI. Compatible
|
22
|
+
earlier versions are still available to users however.
|
23
|
+
|
1
24
|
=== 2.9.1 (2017-8-4)
|
2
25
|
* SyncWrap::JRubyVM
|
3
|
-
* Avoid setting
|
4
|
-
by default. In 2.9.0, this was added as a substitute for
|
5
|
-
jruby.gem.home system property, which when set caused
|
6
|
-
warnings with 9.x. However setting GEM_HOME also
|
7
|
-
effects gem bin wrapper install location. Instead just
|
8
|
-
default in-dist path of jruby 9.x, and system gems will
|
9
|
-
re-installed with a jruby upgrade.
|
26
|
+
* Avoid setting GEM_HOME environment var in the jruby 9.x installed
|
27
|
+
profile by default. In 2.9.0, this was added as a substitute for
|
28
|
+
the jruby.gem.home system property, which when set caused
|
29
|
+
incessant warnings with 9.x. However setting GEM_HOME also
|
30
|
+
undesirably effects gem bin wrapper install location. Instead just
|
31
|
+
use the default in-dist path of jruby 9.x, and system gems will
|
32
|
+
need to be re-installed with a jruby upgrade.
|
10
33
|
* Add support for fast path gem user_install (no-op if same version
|
11
34
|
specification is found)
|
12
35
|
* Fix error message for CLI -S (session) with host not found
|
data/Manifest.txt
CHANGED
@@ -66,6 +66,7 @@ lib/syncwrap/components/rhel.rb
|
|
66
66
|
lib/syncwrap/components/run_user.rb
|
67
67
|
lib/syncwrap/components/source_tree.rb
|
68
68
|
lib/syncwrap/components/tarpit_gem.rb
|
69
|
+
lib/syncwrap/components/time_checker.rb
|
69
70
|
lib/syncwrap/components/ubuntu.rb
|
70
71
|
lib/syncwrap/components/users.rb
|
71
72
|
sync/etc/gemrc
|
data/lib/syncwrap/base.rb
CHANGED
data/lib/syncwrap/component.rb
CHANGED
@@ -123,6 +123,8 @@ module SyncWrap
|
|
123
123
|
# sudo "touch /var/foobar" #=> NestingError
|
124
124
|
# end
|
125
125
|
#
|
126
|
+
# See also #sh_if, #sudo_if for convenience methods.
|
127
|
+
#
|
126
128
|
# While executing the block, #flush is _locked_. The above fails
|
127
129
|
# with a NestingError and accurate stack trace, without running
|
128
130
|
# any potentially dangerous, incomplete bash fragments on the
|
@@ -200,6 +202,23 @@ module SyncWrap
|
|
200
202
|
sh( command, { user: run_user }.merge( opts ), &block )
|
201
203
|
end
|
202
204
|
|
205
|
+
# Wraps cond in a bash "if cond; then" expression and close: "fi",
|
206
|
+
# and then calls #sh with the remaining options and block.
|
207
|
+
def sh_if( cond, opts = {}, &block )
|
208
|
+
cmd = "if #{cond}; then"
|
209
|
+
sh( cmd, opts.merge( close: 'fi' ), &block )
|
210
|
+
end
|
211
|
+
|
212
|
+
# Equivalent to `sh_if( cond, user: :root )`
|
213
|
+
def sudo_if( cond, opts = {}, &block )
|
214
|
+
sh_if( cond, { user: :root }.merge( opts ), &block )
|
215
|
+
end
|
216
|
+
|
217
|
+
# Equivalent to `sh_if( cond, user: run_user )`
|
218
|
+
def rudo_if( cond, opts = {}, &block )
|
219
|
+
sh_if( cond, { user: run_user }.merge( opts ), &block )
|
220
|
+
end
|
221
|
+
|
203
222
|
# Capture and return [exit_code, stdout] from command, where
|
204
223
|
# stdout is the entire stream read into a String. Any commands
|
205
224
|
# already queued via #sh are executed via #flush beforehand, to
|
@@ -66,8 +66,7 @@ module SyncWrap
|
|
66
66
|
# yield to block.
|
67
67
|
def dist_if_not_installed?( pkgs, chk = true, opts = {}, &block )
|
68
68
|
if chk
|
69
|
-
|
70
|
-
sudo( c, opts.merge( close: 'fi' ), &block )
|
69
|
+
sudo_if( "! pacman -Q #{pkgs.join ' '} >/dev/null 2>&1", opts, &block )
|
71
70
|
else
|
72
71
|
block.call
|
73
72
|
end
|
@@ -76,8 +75,7 @@ module SyncWrap
|
|
76
75
|
# Wrap block in a sudo bash conditional testing if the single
|
77
76
|
# specified pkg is installed.
|
78
77
|
def dist_if_installed?( pkg, opts = {}, &block )
|
79
|
-
|
80
|
-
sudo( c, opts.merge( close: 'fi' ), &block )
|
78
|
+
sudo_if( "pacman -Q #{pkg} >/dev/null 2>&1", opts, &block )
|
81
79
|
end
|
82
80
|
|
83
81
|
alias_method :dist_service, :dist_service_via_systemctl
|
@@ -70,7 +70,7 @@ module SyncWrap
|
|
70
70
|
map { |b| "../lib/java/bin/#{b}" }.
|
71
71
|
join( ' ' )
|
72
72
|
|
73
|
-
|
73
|
+
sudo_if( "[ ! -d #{jdk_dir} ]" ) do
|
74
74
|
dist_install( 'curl', minimal: true, check_install: true )
|
75
75
|
sudo <<-SH
|
76
76
|
curl -sSL -o #{distro} #{jdk_url}
|
@@ -47,7 +47,7 @@ module SyncWrap
|
|
47
47
|
include HashSupport
|
48
48
|
|
49
49
|
# Default #ruby_version to install
|
50
|
-
DEFAULT_VERSION = '2.
|
50
|
+
DEFAULT_VERSION = '2.3.5'
|
51
51
|
|
52
52
|
# A set of known (sha256) cryptographic hashes, keyed by version
|
53
53
|
# string, for the source ruby-(version).tar.gz package.
|
@@ -64,17 +64,23 @@ module SyncWrap
|
|
64
64
|
'de8e192791cb157d610c48a9a9ff6e7f19d67ce86052feae62b82e3682cc675f',
|
65
65
|
'2.2.7' =>
|
66
66
|
'374184c6c5bbc88fb7bad422368d4053a236fb6587f0eff76146dcba57f93da5',
|
67
|
+
'2.2.8' =>
|
68
|
+
'8f37b9d8538bf8e50ad098db2a716ea49585ad1601bbd347ef84ca0662d9268a',
|
67
69
|
'2.3.3' =>
|
68
70
|
'241408c8c555b258846368830a06146e4849a1d58dcaf6b14a3b6a73058115b7',
|
69
71
|
'2.3.4' =>
|
70
|
-
'98e18f17c933318d0e32fed3aea67e304f174d03170a38fd920c4fbe49fec0c3'
|
72
|
+
'98e18f17c933318d0e32fed3aea67e304f174d03170a38fd920c4fbe49fec0c3',
|
73
|
+
'2.3.5' =>
|
74
|
+
'5462f7bbb28beff5da7441968471ed922f964db1abdce82b8860608acc23ddcc',
|
75
|
+
'2.4.2' =>
|
76
|
+
'93b9e75e00b262bc4def6b26b7ae8717efc252c47154abb7392e54357e6c8c9c' }
|
71
77
|
|
72
78
|
# The ruby version to install, as it appears in source packages
|
73
79
|
# from ruby-lang.org. Note that starting with 2.1.0, the patch
|
74
80
|
# release (p#) no longer appears in package names.
|
75
81
|
# (Default: DEFAULT_VERSION)
|
76
82
|
#
|
77
|
-
# Example values: '2.0.0-p481', '2.2.
|
83
|
+
# Example values: '2.0.0-p481', '2.2.8', '2.3.5', '2.4.2'
|
78
84
|
attr_accessor :ruby_version
|
79
85
|
|
80
86
|
# If true, attempt to uninstall any pre-existing distro packaged
|
@@ -33,6 +33,8 @@ module SyncWrap
|
|
33
33
|
|
34
34
|
alias :distro_version :debian_version
|
35
35
|
|
36
|
+
UPDATE_LOCK = "/var/lock/subsys/syncwrap-apt-get-update".freeze
|
37
|
+
|
36
38
|
protected
|
37
39
|
|
38
40
|
# Set true/false to override the default, distro version based
|
@@ -89,14 +91,20 @@ module SyncWrap
|
|
89
91
|
# ==== Options
|
90
92
|
#
|
91
93
|
# :update_required:: If true, always perform update. If specified
|
92
|
-
# as false, do nothing. If unspecified,
|
93
|
-
#
|
94
|
+
# as false, do nothing. If unspecified, update
|
95
|
+
# if it hasn't already been run in the last
|
96
|
+
# hour via syncwrap (using a lock file).
|
94
97
|
#
|
95
98
|
# Options are also passed to the sudo calls.
|
96
99
|
def dist_update( opts = {} )
|
97
100
|
req = opts[ :update_required ]
|
98
|
-
if ( req != false )
|
99
|
-
|
101
|
+
if ( req != false )
|
102
|
+
dist_if_update_old?( req != true, opts ) do
|
103
|
+
sudo( <<-SH, opts )
|
104
|
+
apt-get -yqq update
|
105
|
+
touch #{UPDATE_LOCK}
|
106
|
+
SH
|
107
|
+
end
|
100
108
|
end
|
101
109
|
end
|
102
110
|
|
@@ -119,8 +127,7 @@ module SyncWrap
|
|
119
127
|
if chk
|
120
128
|
qry = "dpkg-query -W -f '${db:Status-Status}\\n' #{pkgs.join ' '}"
|
121
129
|
cnt = qry + " | grep -c -E '^installed$'"
|
122
|
-
|
123
|
-
sudo( cond, opts.merge( close: 'fi' ), &block )
|
130
|
+
sudo_if( %Q{[ "$(#{cnt})" != "#{pkgs.count}" ]}, opts, &block )
|
124
131
|
else
|
125
132
|
block.call
|
126
133
|
end
|
@@ -131,8 +138,7 @@ module SyncWrap
|
|
131
138
|
def dist_if_installed?( pkg, opts = {}, &block )
|
132
139
|
qry = "dpkg-query -W -f '${db:Status-Status}\\n' #{pkg}"
|
133
140
|
tst = qry + " | grep -q -E '^installed$'"
|
134
|
-
|
135
|
-
sudo( cond, opts.merge( close: 'fi' ), &block )
|
141
|
+
sudo_if( tst, opts, &block )
|
136
142
|
end
|
137
143
|
|
138
144
|
# Install a System V style init.d service script
|
@@ -163,13 +169,13 @@ module SyncWrap
|
|
163
169
|
|
164
170
|
protected
|
165
171
|
|
166
|
-
def
|
167
|
-
|
168
|
-
|
169
|
-
|
172
|
+
def dist_if_update_old?( chk = true, opts = {}, &block )
|
173
|
+
if chk
|
174
|
+
l = UPDATE_LOCK
|
175
|
+
sudo_if( %Q{[[ ! -e #{l} || -n "$(find #{l} -mmin +60)" ]]},
|
176
|
+
opts, &block )
|
170
177
|
else
|
171
|
-
|
172
|
-
true
|
178
|
+
block.call
|
173
179
|
end
|
174
180
|
end
|
175
181
|
|
@@ -32,7 +32,7 @@ module SyncWrap
|
|
32
32
|
include HashSupport
|
33
33
|
|
34
34
|
# Default #jruby_version to install
|
35
|
-
DEFAULT_VERSION = '1.
|
35
|
+
DEFAULT_VERSION = '9.1.13.0'
|
36
36
|
|
37
37
|
# A set of known cryptographic hashes, keyed by version
|
38
38
|
# string. We prefer sha256 but sha1 is what is published for
|
@@ -46,11 +46,13 @@ module SyncWrap
|
|
46
46
|
'1.7.27' => '4a24fe103d3735b23cc58668dec711857125a6f3',
|
47
47
|
'9.1.12.0' =>
|
48
48
|
'ddb23c95f4b3cc3fc1cc57b81cb4ceee776496ede402b9a6eb0622cf15e1a597',
|
49
|
+
'9.1.13.0' =>
|
50
|
+
'9d156646623ac2f27174721035b52572a4b05690db7c1293295aa2c04aad3908',
|
49
51
|
}
|
50
52
|
|
51
53
|
# JRuby version to install (default: DEFAULT_VERSION)
|
52
54
|
#
|
53
|
-
# Example values: '1.7.
|
55
|
+
# Example values: '1.7.27', '9.1.13.0'
|
54
56
|
attr_accessor :jruby_version
|
55
57
|
|
56
58
|
# A cryptographic hash value (hexadecimal, some standard length)
|
@@ -181,8 +183,7 @@ module SyncWrap
|
|
181
183
|
specs = [ "#{prefix}/specifications/#{gem}-#{ver}-java.gemspec",
|
182
184
|
"#{prefix}/specifications/#{gem}-#{ver}.gemspec" ]
|
183
185
|
|
184
|
-
|
185
|
-
shopts = { close: 'fi' }
|
186
|
+
shopts = {}
|
186
187
|
case opts[ :user_install ]
|
187
188
|
when String
|
188
189
|
shopts[ :user ] = opts[ :user_install ]
|
@@ -190,7 +191,7 @@ module SyncWrap
|
|
190
191
|
shopts[ :user ] = :root
|
191
192
|
end
|
192
193
|
|
193
|
-
|
194
|
+
sh_if( "[ ! -e #{specs[0]} -a ! -e #{specs[1]} ]", shopts ) do
|
194
195
|
super
|
195
196
|
end
|
196
197
|
else
|
@@ -93,7 +93,7 @@ module SyncWrap
|
|
93
93
|
else
|
94
94
|
dist_install( "lvm2", minimal: true )
|
95
95
|
end
|
96
|
-
|
96
|
+
sudo_if( "! lvs /dev/#{vg}/#{lv_cache}" ) do
|
97
97
|
unmount_device( raw_device )
|
98
98
|
sudo <<-SH
|
99
99
|
vgextend #{vgextend_flags.join ' '} #{vg} #{raw_device}
|
@@ -120,9 +120,7 @@ module SyncWrap
|
|
120
120
|
|
121
121
|
paths = lvm_volumes.map { |r| r[1] }
|
122
122
|
test = paths.map { |p| "! -e #{p}" }.join( " -a " )
|
123
|
-
|
124
|
-
sudo( "if [ #{test} ]; then", close: "fi" ) do
|
125
|
-
|
123
|
+
sudo_if( "[ #{test} ]" ) do
|
126
124
|
dist_install( "mdadm", "lvm2", minimal: true )
|
127
125
|
|
128
126
|
raw_devices.each do |d|
|
@@ -138,7 +136,6 @@ module SyncWrap
|
|
138
136
|
end
|
139
137
|
|
140
138
|
create_volumes( dev )
|
141
|
-
|
142
139
|
end
|
143
140
|
end
|
144
141
|
|
@@ -319,7 +319,7 @@ module SyncWrap
|
|
319
319
|
changes = rput( 'etc/sysconfig/pgsql/postgresql', user: :root )
|
320
320
|
end
|
321
321
|
|
322
|
-
|
322
|
+
sudo_if( "[ ! -d '#{pg_data_dir}/base' ]" ) do
|
323
323
|
sudo <<-SH
|
324
324
|
mkdir -p #{pg_data_dir}
|
325
325
|
chown postgres:postgres #{pg_data_dir}
|
@@ -20,27 +20,40 @@ module SyncWrap
|
|
20
20
|
|
21
21
|
# Provision for the rake rubygem and its (j)rake command
|
22
22
|
#
|
23
|
-
# Host component dependencies: <
|
23
|
+
# Host component dependencies: RunUser?, <ruby>
|
24
24
|
#
|
25
25
|
class RakeGem < Component
|
26
26
|
|
27
|
-
# Rake version to install (Default:
|
27
|
+
# Rake version to install (Default: 12.1.0)
|
28
28
|
attr_accessor :rake_version
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
protected
|
31
|
+
|
32
|
+
# Perform a user_install as the run_user? (Default: false)
|
33
|
+
attr_writer :user_install
|
34
|
+
|
35
|
+
def user_install?
|
36
|
+
@user_install
|
33
37
|
end
|
34
38
|
|
39
|
+
public
|
40
|
+
|
35
41
|
def rake_command
|
36
42
|
( ruby_command == 'jruby' ) ? 'jrake' : 'rake'
|
37
43
|
end
|
38
44
|
|
45
|
+
def initialize( opts = {} )
|
46
|
+
@rake_version = '12.1.0'
|
47
|
+
@user_install = false
|
48
|
+
super
|
49
|
+
end
|
50
|
+
|
39
51
|
def install
|
40
|
-
opts = { version: rake_version }
|
52
|
+
opts = { version: rake_version, user_install: user_install? && run_user }
|
41
53
|
opts[ :format_executable ] = true unless rake_command == 'rake'
|
42
54
|
gem_install( 'rake', opts )
|
43
55
|
end
|
44
56
|
|
45
57
|
end
|
58
|
+
|
46
59
|
end
|
@@ -125,8 +125,7 @@ module SyncWrap
|
|
125
125
|
if chk
|
126
126
|
pkgs = Array( pkgs )
|
127
127
|
cnt = "rpm -q #{pkgs.join ' '} | grep -cv 'not installed'"
|
128
|
-
|
129
|
-
sudo( cond, opts.merge( close: 'fi' ), &block )
|
128
|
+
sudo_if( %Q{[ "$(#{cnt})" != "#{pkgs.count}" ]}, opts, &block )
|
130
129
|
else
|
131
130
|
block.call
|
132
131
|
end
|
@@ -63,7 +63,7 @@ module SyncWrap
|
|
63
63
|
|
64
64
|
# Create run_user if not already present
|
65
65
|
def create_run_user
|
66
|
-
|
66
|
+
sudo_if( "! id #{run_user} >/dev/null 2>&1" ) do
|
67
67
|
user_opts = "-r -c 'Run User' -s /bin/bash"
|
68
68
|
user_opts += " -d #{run_user_home}" if run_user_home
|
69
69
|
if run_group && run_group != run_user
|
@@ -24,7 +24,7 @@ module SyncWrap
|
|
24
24
|
#
|
25
25
|
class TarpitGem < Component
|
26
26
|
|
27
|
-
# Tarpit version to install (Default: 2.1.
|
27
|
+
# Tarpit version to install (Default: 2.1.2)
|
28
28
|
attr_accessor :tarpit_version
|
29
29
|
|
30
30
|
protected
|
@@ -39,7 +39,7 @@ module SyncWrap
|
|
39
39
|
public
|
40
40
|
|
41
41
|
def initialize( opts = {} )
|
42
|
-
@tarpit_version = '2.1.
|
42
|
+
@tarpit_version = '2.1.2'
|
43
43
|
@user_install = false
|
44
44
|
super
|
45
45
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2011-2017 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You may
|
6
|
+
# obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require 'time'
|
18
|
+
require 'term/ansicolor'
|
19
|
+
|
20
|
+
require 'syncwrap/component'
|
21
|
+
|
22
|
+
module SyncWrap
|
23
|
+
|
24
|
+
# Component for checking and comparing remote host times. This can
|
25
|
+
# be used to validate proper time keeping (e.g. via ntpd or similar)
|
26
|
+
# on multiple remote hosts by comparing with local time. Its also
|
27
|
+
# illustrative of syncwrap threading and synchronized output
|
28
|
+
# formatting.
|
29
|
+
#
|
30
|
+
# === Usage
|
31
|
+
#
|
32
|
+
# First you should add this component to some or all hosts:
|
33
|
+
#
|
34
|
+
# role( :all, TimeChecker.new )
|
35
|
+
#
|
36
|
+
# Then you run it via the command line:
|
37
|
+
#
|
38
|
+
# syncwrap TimeChecker.check
|
39
|
+
#
|
40
|
+
# You can also experiment with -v and -t flags if desired.
|
41
|
+
#
|
42
|
+
# Output is in the following form per host:
|
43
|
+
#
|
44
|
+
# host-name : start-delta <- HH:MM:SS.NNNNNNZ -> return-delta
|
45
|
+
#
|
46
|
+
# Where:
|
47
|
+
#
|
48
|
+
# * the captured and parsed remote time is shown in 'Z'ulu (UTC)
|
49
|
+
#
|
50
|
+
# * start-delta is the time difference between the local time, just
|
51
|
+
# before the remote command is started, and the remote time.
|
52
|
+
#
|
53
|
+
# * return-delta is the difference between the remote time and local
|
54
|
+
# time, just after the remote command has returned.
|
55
|
+
#
|
56
|
+
# If both local and remote hosts have well synchronized clocks, then
|
57
|
+
# both these differences should be positive, but small negative
|
58
|
+
# values for return-delta are common, in the range of the clock
|
59
|
+
# skew. Negative values are formatted in red when output is
|
60
|
+
# colorized.
|
61
|
+
#
|
62
|
+
# Host component dependencies: none
|
63
|
+
class TimeChecker < Component
|
64
|
+
include Term::ANSIColor
|
65
|
+
|
66
|
+
FORMAT = "%-24s: %s%9.6fs%s <- %s -> %s%9.6fs%s\n".freeze
|
67
|
+
|
68
|
+
def check
|
69
|
+
lnow1 = Time.now.utc
|
70
|
+
rc, out = capture( 'date --rfc-3339=ns' )
|
71
|
+
if rc == 0
|
72
|
+
lnow2 = Time.now.utc
|
73
|
+
rnow = Time.parse( out ).utc
|
74
|
+
d1 = rnow - lnow1
|
75
|
+
d2 = lnow2 - rnow
|
76
|
+
formatter.sync do
|
77
|
+
c = formatter.io
|
78
|
+
c << FORMAT % [ host.name,
|
79
|
+
d1 < 0.0 ? red? : green?, d1, clear?,
|
80
|
+
rnow.strftime( '%H:%M:%S.%6NZ' ),
|
81
|
+
d2 < 0.0 ? red? : green?, d2, clear? ]
|
82
|
+
c.flush
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def formatter
|
90
|
+
@formatter ||= host.space.formatter
|
91
|
+
end
|
92
|
+
|
93
|
+
def green?
|
94
|
+
formatter.colorize ? green : ""
|
95
|
+
end
|
96
|
+
|
97
|
+
def red?
|
98
|
+
formatter.colorize ? red : ""
|
99
|
+
end
|
100
|
+
|
101
|
+
def clear?
|
102
|
+
formatter.colorize ? clear : ""
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -18,8 +18,8 @@ module SyncWrap
|
|
18
18
|
|
19
19
|
# Support module for components which install SystemD
|
20
20
|
# services. Provide unit file installation with `systemctl` calls,
|
21
|
-
# and also provides standard #
|
22
|
-
# commands for use in the CLI.
|
21
|
+
# and also provides standard #enable, #start, #status, #restart,
|
22
|
+
# #stop, and #disable commands for use in the CLI.
|
23
23
|
#
|
24
24
|
# Host component dependencies: <Distro>
|
25
25
|
module SystemDService
|
@@ -105,6 +105,18 @@ module SyncWrap
|
|
105
105
|
systemctl( 'stop', *systemd_units )
|
106
106
|
end
|
107
107
|
|
108
|
+
# Disable all #systemd_units.
|
109
|
+
def disable
|
110
|
+
require_systemd_service!
|
111
|
+
systemctl( 'disable', *systemd_units )
|
112
|
+
end
|
113
|
+
|
114
|
+
# Enable all #systemd_units.
|
115
|
+
def enable
|
116
|
+
require_systemd_service!
|
117
|
+
systemctl( 'enable', *systemd_units )
|
118
|
+
end
|
119
|
+
|
108
120
|
# Output status of #systemd_units (useful via CLI with --verbose).
|
109
121
|
# Exit codes 0-3 are accepted from `systemctl`, since these will
|
110
122
|
# be returned in normal operational contexts, for example, when
|
data/lib/syncwrap.rb
CHANGED
@@ -417,6 +417,7 @@ module SyncWrap
|
|
417
417
|
autoload :RunUser, 'syncwrap/components/run_user'
|
418
418
|
autoload :SourceTree, 'syncwrap/components/source_tree'
|
419
419
|
autoload :TarpitGem, 'syncwrap/components/tarpit_gem'
|
420
|
+
autoload :TimeChecker, 'syncwrap/components/time_checker'
|
420
421
|
autoload :Ubuntu, 'syncwrap/components/ubuntu'
|
421
422
|
autoload :Users, 'syncwrap/components/users'
|
422
423
|
|
metadata
CHANGED
@@ -1,43 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syncwrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Kellum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.2.2
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.5'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 1.2.2
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.5'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: tins
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
39
|
+
version: 1.6.0
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '1.14'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
|
-
- - "
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.6.0
|
50
|
+
- - "<"
|
39
51
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
52
|
+
version: '1.14'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: aws-sdk
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,7 +73,7 @@ dependencies:
|
|
61
73
|
version: 1.7.1
|
62
74
|
- - "<"
|
63
75
|
- !ruby/object:Gem::Version
|
64
|
-
version: '
|
76
|
+
version: '2.2'
|
65
77
|
type: :runtime
|
66
78
|
prerelease: false
|
67
79
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,7 +83,7 @@ dependencies:
|
|
71
83
|
version: 1.7.1
|
72
84
|
- - "<"
|
73
85
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
86
|
+
version: '2.2'
|
75
87
|
- !ruby/object:Gem::Dependency
|
76
88
|
name: nokogiri
|
77
89
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +93,7 @@ dependencies:
|
|
81
93
|
version: 1.5.9
|
82
94
|
- - "<"
|
83
95
|
- !ruby/object:Gem::Version
|
84
|
-
version: '1.
|
96
|
+
version: '1.9'
|
85
97
|
type: :runtime
|
86
98
|
prerelease: false
|
87
99
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -91,7 +103,7 @@ dependencies:
|
|
91
103
|
version: 1.5.9
|
92
104
|
- - "<"
|
93
105
|
- !ruby/object:Gem::Version
|
94
|
-
version: '1.
|
106
|
+
version: '1.9'
|
95
107
|
- !ruby/object:Gem::Dependency
|
96
108
|
name: minitest
|
97
109
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,6 +212,7 @@ files:
|
|
200
212
|
- lib/syncwrap/components/run_user.rb
|
201
213
|
- lib/syncwrap/components/source_tree.rb
|
202
214
|
- lib/syncwrap/components/tarpit_gem.rb
|
215
|
+
- lib/syncwrap/components/time_checker.rb
|
203
216
|
- lib/syncwrap/components/ubuntu.rb
|
204
217
|
- lib/syncwrap/components/users.rb
|
205
218
|
- lib/syncwrap/context.rb
|
@@ -285,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
285
298
|
version: '0'
|
286
299
|
requirements: []
|
287
300
|
rubyforge_project:
|
288
|
-
rubygems_version: 2.
|
301
|
+
rubygems_version: 2.5.2.1
|
289
302
|
signing_key:
|
290
303
|
specification_version: 4
|
291
304
|
summary: A rather direct provisioning and deployment system in ruby, bash over ssh,
|