pero 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/pero/cli.rb +31 -11
- data/lib/pero/docker.rb +11 -10
- data/lib/pero/puppet.rb +2 -0
- 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: 05cbbff3dcd2e37bc56f0b6b84c67c7f920aa7f648fdf523ec6b6ebc062c5f06
|
4
|
+
data.tar.gz: 9254adde17ef21f614ab32e84edd3e4a71d40ae534372224bffd4c6587ae8b49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e264fefbe67c4d6240125f327f8013bc2a6450770e2eef42e9d2eb62386aadca5782b0bd3f23b79f88cc8ba4348ad131e6b995ad9b6bb2779b7d64e42d74f78
|
7
|
+
data.tar.gz: b496423a88e94f2625ad18dc1abdaabbd60b9e54ef3a4949043301dabaf531589a3df85511e2cbdeb95a14a96c150708cc5feb48482dccdc9f5c4d34cb7321e7
|
data/Gemfile.lock
CHANGED
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}"
|
@@ -57,12 +62,8 @@ module Pero
|
|
57
62
|
"AutoRemove" => true,
|
58
63
|
)
|
59
64
|
|
60
|
-
container =
|
61
|
-
c.info["Names"].first == "/#{container_name}"
|
62
|
-
end
|
63
|
-
|
65
|
+
container = find
|
64
66
|
raise "can't start container" unless container
|
65
|
-
|
66
67
|
begin
|
67
68
|
Retryable.retryable(tries: 20, sleep: 5) do
|
68
69
|
https = Net::HTTP.new('localhost', container.info["Ports"].first["PublicPort"])
|
@@ -78,10 +79,11 @@ module Pero
|
|
78
79
|
raise e
|
79
80
|
end
|
80
81
|
rescue
|
81
|
-
container.
|
82
|
+
Pero.log.error "can't start container.please check [ docker logs #{container.info["id"]} ]"
|
83
|
+
container = find
|
84
|
+
container.kill if container && container.info["State"] != "exited"
|
82
85
|
raise "can't start puppet server"
|
83
86
|
end
|
84
|
-
|
85
87
|
container
|
86
88
|
end
|
87
89
|
|
@@ -126,7 +128,6 @@ CMD bash -c "rm -rf #{conf_dir}/ssl/* && #{create_ca} && #{run_cmd}"
|
|
126
128
|
|
127
129
|
def create_ca
|
128
130
|
release_package,package_name, conf_dir = if Gem::Version.new("5.0.0") > Gem::Version.new(server_version)
|
129
|
-
#'(puppet cert generate `hostname` --dns_alt_names localhost,127.0.0.1 || puppet cert --allow-dns-alt-names sign `hostname`)'
|
130
131
|
'puppet cert generate `hostname` --dns_alt_names localhost,127.0.0.1'
|
131
132
|
elsif Gem::Version.new("6.0.0") > Gem::Version.new(server_version)
|
132
133
|
'puppet cert generate `hostname` --dns_alt_names localhost,127.0.0.1'
|
data/lib/pero/puppet.rb
CHANGED
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.7
|
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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|