pero 0.1.4 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/pero/cli.rb +31 -11
- data/lib/pero/docker.rb +25 -22
- data/lib/pero/puppet.rb +8 -3
- data/lib/pero/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cc26e00bd55e4f440b1093cb50d648c692431e242aaad76ee5a75b4861a569e
|
4
|
+
data.tar.gz: 993f4b79e420e78cfdebc1f124fa066b70f2b562b4948affa768819eb212ee5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b84c3ad2efb6a369fd8d3edf4a80076d107dd9270a41840e5ff41ca15549aeb360ba2318d2568237f279bfb941b6b97963bbace51e15771584c38dc67dc20d7d
|
7
|
+
data.tar.gz: ac0092e216b422dd99afdede3175063d267c92e09a10cdcfa207d7a3e514a5d4412ba57900c6bf1efbcb049c139ddbc345ab640cd113f93866820dfa95603466
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pero (0.1.
|
4
|
+
pero (0.1.8)
|
5
5
|
docker-api
|
6
6
|
logger
|
7
7
|
net-ssh
|
@@ -41,7 +41,7 @@ GEM
|
|
41
41
|
rspec-support (~> 3.9.0)
|
42
42
|
rspec-support (3.9.3)
|
43
43
|
sfl (2.3)
|
44
|
-
specinfra (2.82.
|
44
|
+
specinfra (2.82.19)
|
45
45
|
net-scp
|
46
46
|
net-ssh (>= 2.7)
|
47
47
|
net-telnet (= 0.1.1)
|
data/lib/pero/cli.rb
CHANGED
@@ -30,7 +30,11 @@ module Pero
|
|
30
30
|
|
31
31
|
desc "versions", "show support version"
|
32
32
|
def versions
|
33
|
-
|
33
|
+
begin
|
34
|
+
Pero::Puppet::Redhat.show_versions
|
35
|
+
rescue => e
|
36
|
+
Pero.log.error e.inspect
|
37
|
+
end
|
34
38
|
end
|
35
39
|
|
36
40
|
desc "apply", "puppet apply"
|
@@ -41,12 +45,17 @@ module Pero
|
|
41
45
|
option :tags, default: nil, type: :array
|
42
46
|
option "one-shot", default: false, type: :boolean, desc: "stop puppet server after run"
|
43
47
|
def apply(name_regexp)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
begin
|
49
|
+
prepare
|
50
|
+
nodes = Pero::History.search(name_regexp)
|
51
|
+
return unless nodes
|
52
|
+
Parallel.each(nodes, in_process: options["concurrent"]) do |n|
|
53
|
+
opt = n["last_options"].merge(options)
|
54
|
+
puppet = Pero::Puppet.new(opt["host"], opt)
|
55
|
+
puppet.apply
|
56
|
+
end
|
57
|
+
rescue => e
|
58
|
+
Pero.log.error e.inspect
|
50
59
|
end
|
51
60
|
end
|
52
61
|
|
@@ -55,10 +64,21 @@ module Pero
|
|
55
64
|
option "agent-version", type: :string
|
56
65
|
option "node-name", aliases: '-N', default: "", type: :string, desc: "json node name(default hostname)"
|
57
66
|
def bootstrap(*hosts)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
67
|
+
begin
|
68
|
+
Parallel.each(hosts, in_process: options["concurrent"]) do |host|
|
69
|
+
next if host =~ /^-/
|
70
|
+
puppet = Pero::Puppet.new(host, options)
|
71
|
+
puppet.install
|
72
|
+
end
|
73
|
+
rescue => e
|
74
|
+
Pero.log.error e.inspect
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
no_commands do
|
79
|
+
def prepare
|
80
|
+
`bundle insatll` if File.exists?("Gemfile")
|
81
|
+
`bundle exec librarian-puppet install` if File.exists?("Puppetfile")
|
62
82
|
end
|
63
83
|
end
|
64
84
|
end
|
data/lib/pero/docker.rb
CHANGED
@@ -27,12 +27,17 @@ module Pero
|
|
27
27
|
"pero-#{server_version}-#{Digest::MD5.hexdigest(Dir.pwd)[0..5]}-#{@environment}"
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def find
|
31
31
|
::Docker::Container.all(:all => true).find do |c|
|
32
|
-
c.info["Names"].first == "/#{container_name}"
|
32
|
+
c.info["Names"].first == "/#{container_name}"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
def alerady_run?
|
37
|
+
c = find
|
38
|
+
c && c.info["State"] != "exited" && c
|
39
|
+
end
|
40
|
+
|
36
41
|
def run
|
37
42
|
::Docker::Container.all(:all => true).each do |c|
|
38
43
|
c.delete(:force => true) if c.info["Names"].first == "/#{container_name}"
|
@@ -45,6 +50,7 @@ module Pero
|
|
45
50
|
'ExposedPorts' => { '8140/tcp' => {} },
|
46
51
|
})
|
47
52
|
|
53
|
+
Pero.log.info "start puppet master container"
|
48
54
|
container.start(
|
49
55
|
'Binds' => [
|
50
56
|
"#{Dir.pwd}:/etc/puppetlabs/code/environments/#{@environment}",
|
@@ -53,34 +59,32 @@ module Pero
|
|
53
59
|
'PortBindings' => {
|
54
60
|
'8140/tcp' => [{ 'HostPort' => "0" }],
|
55
61
|
},
|
56
|
-
"AutoRemove" => true,
|
57
62
|
)
|
58
63
|
|
59
|
-
container =
|
60
|
-
c.info["Names"].first == "/#{container_name}"
|
61
|
-
end
|
62
|
-
|
64
|
+
container = find
|
63
65
|
raise "can't start container" unless container
|
64
|
-
|
65
66
|
begin
|
66
67
|
Retryable.retryable(tries: 20, sleep: 5) do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
68
|
+
begin
|
69
|
+
https = Net::HTTP.new('localhost', container.info["Ports"].first["PublicPort"])
|
70
|
+
https.use_ssl = true
|
71
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
72
|
+
Pero.log.debug "start server health check"
|
73
|
+
https.start {
|
74
|
+
response = https.get('/')
|
75
|
+
Pero.log.debug "puppet http response #{response}"
|
76
|
+
}
|
77
|
+
rescue => e
|
78
|
+
Pero.log.debug e.inspect
|
79
|
+
raise e
|
80
|
+
end
|
78
81
|
end
|
79
82
|
rescue
|
80
|
-
container.
|
83
|
+
Pero.log.error "can't start container.please check [ docker logs #{container.info["id"]} ]"
|
84
|
+
container = find
|
85
|
+
container.kill if container && container.info["State"] != "exited"
|
81
86
|
raise "can't start puppet server"
|
82
87
|
end
|
83
|
-
|
84
88
|
container
|
85
89
|
end
|
86
90
|
|
@@ -125,7 +129,6 @@ CMD bash -c "rm -rf #{conf_dir}/ssl/* && #{create_ca} && #{run_cmd}"
|
|
125
129
|
|
126
130
|
def create_ca
|
127
131
|
release_package,package_name, conf_dir = if Gem::Version.new("5.0.0") > Gem::Version.new(server_version)
|
128
|
-
#'(puppet cert generate `hostname` --dns_alt_names localhost,127.0.0.1 || puppet cert --allow-dns-alt-names sign `hostname`)'
|
129
132
|
'puppet cert generate `hostname` --dns_alt_names localhost,127.0.0.1'
|
130
133
|
elsif Gem::Version.new("6.0.0") > Gem::Version.new(server_version)
|
131
134
|
'puppet cert generate `hostname` --dns_alt_names localhost,127.0.0.1'
|
data/lib/pero/puppet.rb
CHANGED
@@ -28,6 +28,11 @@ module Pero
|
|
28
28
|
|
29
29
|
@options[:host] = host
|
30
30
|
so = ssh_options
|
31
|
+
|
32
|
+
if !Net::SSH::VALID_OPTIONS.include?(:strict_host_key_checking)
|
33
|
+
so.delete(:strict_host_key_checking)
|
34
|
+
end
|
35
|
+
|
31
36
|
@specinfra = Specinfra::Backend::Ssh.new(
|
32
37
|
request_pty: true,
|
33
38
|
host: so[:host_name],
|
@@ -86,7 +91,6 @@ module Pero
|
|
86
91
|
end
|
87
92
|
|
88
93
|
def serve_master
|
89
|
-
Pero.log.info "start puppet master container"
|
90
94
|
container = run_container
|
91
95
|
begin
|
92
96
|
yield container
|
@@ -97,6 +101,8 @@ module Pero
|
|
97
101
|
if @options["one-shot"]
|
98
102
|
Pero.log.info "stop puppet master container"
|
99
103
|
container.kill
|
104
|
+
else
|
105
|
+
Pero.log.info "puppet master container keep running"
|
100
106
|
end
|
101
107
|
end
|
102
108
|
end
|
@@ -111,8 +117,6 @@ module Pero
|
|
111
117
|
port = container.info["Ports"].first["PublicPort"]
|
112
118
|
begin
|
113
119
|
tmpdir=container.info["id"][0..5]
|
114
|
-
Pero.log.info "start forwarding port:#{port}"
|
115
|
-
|
116
120
|
in_ssh_forwarding(port) do |host, ssh|
|
117
121
|
Pero.log.info "#{host}:puppet cmd[#{puppet_cmd}]"
|
118
122
|
cmd = "mkdir -p /tmp/puppet/#{tmpdir} && unshare -m -- /bin/bash -c 'export PATH=$PATH:/opt/puppetlabs/bin/ && \
|
@@ -158,6 +162,7 @@ module Pero
|
|
158
162
|
options.delete(:strict_host_key_checking)
|
159
163
|
end
|
160
164
|
|
165
|
+
Pero.log.info "start forwarding #{specinfra.get_config(:host)}:8140 => localhost:#{port}"
|
161
166
|
Net::SSH.start(
|
162
167
|
specinfra.get_config(:host),
|
163
168
|
options[:user],
|
data/lib/pero/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyama86
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|