pero 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pero/cli.rb +52 -59
- data/lib/pero/puppet.rb +2 -2
- data/lib/pero/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a48e2786db38760a4c084182d6e8fa0d75ed4a8dc7a302bd019d66a58977e31
|
4
|
+
data.tar.gz: 85022aad2062db63dd56289a8b0a93998db0dc36a94cef79d46701e19f9e381e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4b82257f375edd65d5f336c5ea08289125c8fed6d0acad596a2e9ceedef6901c59c7c7d274dd41c8477f5a8bc44cb5f47d9a1df89d4ea44ff9ae2dea1f742f0
|
7
|
+
data.tar.gz: 4b541bd95a5c460f841ca63304e7141bc9390a3e20a93e6f7b1e463c522c40bf945c8512a0c6b755bdfbffe0099253d9dc28b406823695fb8a320a197b57efce
|
data/lib/pero/cli.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'pero'
|
2
|
+
require 'thor'
|
3
|
+
require 'parallel'
|
4
4
|
|
5
5
|
module Pero
|
6
6
|
class CLI < Thor
|
@@ -17,41 +17,38 @@ module Pero
|
|
17
17
|
|
18
18
|
def self.shared_options
|
19
19
|
option :log_level, type: :string, aliases: ['-l'], default: 'info'
|
20
|
-
option :user, type: :string, aliases: ['-x'], desc:
|
21
|
-
option :key, type: :string, aliases: ['-i'], desc:
|
22
|
-
option :port, type: :numeric, aliases: ['-p'], desc:
|
23
|
-
option
|
24
|
-
option :ssh_config, type: :string, desc:
|
25
|
-
option :environment, type: :string, desc:
|
26
|
-
option :ask_password, type: :boolean, default: false, desc:
|
27
|
-
option :vagrant, type: :boolean, default: false, desc:
|
28
|
-
option :sudo, type: :boolean, default: true, desc:
|
29
|
-
option
|
20
|
+
option :user, type: :string, aliases: ['-x'], desc: 'ssh user'
|
21
|
+
option :key, type: :string, aliases: ['-i'], desc: 'ssh private key'
|
22
|
+
option :port, type: :numeric, aliases: ['-p'], desc: 'ssh port'
|
23
|
+
option 'timeout', default: 10, type: :numeric, desc: 'ssh connect timeout'
|
24
|
+
option :ssh_config, type: :string, desc: 'ssh config path'
|
25
|
+
option :environment, type: :string, desc: 'puppet environment'
|
26
|
+
option :ask_password, type: :boolean, default: false, desc: 'ask ssh or sudo password'
|
27
|
+
option :vagrant, type: :boolean, default: false, desc: 'use vagrarant'
|
28
|
+
option :sudo, type: :boolean, default: true, desc: 'use sudo'
|
29
|
+
option 'concurrent', aliases: '-C', default: 3, type: :numeric, desc: 'running concurrent'
|
30
30
|
end
|
31
31
|
|
32
|
-
desc
|
32
|
+
desc 'versions', 'show support version'
|
33
33
|
def versions
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Pero.log.error e.inspect
|
38
|
-
end
|
34
|
+
Pero::Puppet::Redhat.show_versions
|
35
|
+
rescue StandardError => e
|
36
|
+
Pero.log.error e.inspect
|
39
37
|
end
|
40
38
|
|
41
|
-
desc
|
39
|
+
desc 'apply', 'puppet apply'
|
42
40
|
shared_options
|
43
|
-
option
|
44
|
-
option
|
41
|
+
option 'server-version', type: :string
|
42
|
+
option 'image-name', type: :string
|
45
43
|
option :noop, aliases: '-n', default: false, type: :boolean
|
46
44
|
option :test, aliases: '-t', default: false, type: :boolean
|
47
45
|
option :verbose, aliases: '-v', default: true, type: :boolean
|
48
46
|
option :tags, default: nil, type: :array
|
49
47
|
option :volumes, default: nil, type: :array
|
50
|
-
option
|
48
|
+
option 'one-shot', default: false, type: :boolean, desc: 'stop puppet server after run'
|
51
49
|
def apply(name_regexp)
|
52
|
-
|
53
|
-
|
54
|
-
Pero.log.error "image-name or server-version are required"
|
50
|
+
if !options['image-name'] && !options['server-version']
|
51
|
+
Pero.log.error 'image-name or server-version are required'
|
55
52
|
return
|
56
53
|
end
|
57
54
|
|
@@ -64,64 +61,60 @@ module Pero
|
|
64
61
|
m = Mutex.new
|
65
62
|
|
66
63
|
begin
|
67
|
-
Parallel.each(nodes, in_threads: options[
|
64
|
+
Parallel.each(nodes, in_threads: options['concurrent']) do |n|
|
68
65
|
opt = merge_options(n, options)
|
69
|
-
puppet = Pero::Puppet.new(opt[
|
66
|
+
puppet = Pero::Puppet.new(opt['host'], opt, m)
|
70
67
|
puppet.apply
|
71
68
|
end
|
72
|
-
rescue => e
|
69
|
+
rescue StandardError => e
|
73
70
|
Pero.log.error e.backtrace.join("\n")
|
74
71
|
Pero.log.error e.inspect
|
75
|
-
|
76
72
|
ensure
|
77
|
-
if options[
|
78
|
-
Pero.log.info
|
79
|
-
|
80
|
-
|
81
|
-
Pero::Puppet.new(opt["host"], opt, m).stop_master
|
82
|
-
end
|
73
|
+
if options['one-shot']
|
74
|
+
Pero.log.info 'stop puppet master container'
|
75
|
+
opt = merge_options(nodes.first, options)
|
76
|
+
Pero::Puppet.new(opt['host'], opt, m).stop_master
|
83
77
|
else
|
84
|
-
Pero.log.info
|
78
|
+
Pero.log.info 'puppet master container keep running'
|
85
79
|
end
|
86
80
|
end
|
87
81
|
end
|
88
82
|
|
89
|
-
desc
|
83
|
+
desc 'bootstrap', 'bootstrap pero'
|
90
84
|
shared_options
|
91
|
-
option
|
92
|
-
option
|
85
|
+
option 'agent-version', type: :string
|
86
|
+
option 'node-name', aliases: '-N', default: '', type: :string, desc: 'json node name(default hostname)'
|
93
87
|
def bootstrap(*hosts)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
raise "unknown option #{host}" if host =~ /^-/
|
99
|
-
puppet = Pero::Puppet.new(host, options, m)
|
88
|
+
options['environment'] = 'production' if options['environment'].nil? || options['environment'].empty?
|
89
|
+
m = Mutex.new
|
90
|
+
Parallel.each(hosts, in_threads: options['concurrent']) do |host|
|
91
|
+
raise "unknown option #{host}" if host =~ /^-/
|
100
92
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
Pero.log.error e.backtrace.join("\n")
|
106
|
-
Pero.log.error e.inspect
|
93
|
+
puppet = Pero::Puppet.new(host, options, m)
|
94
|
+
|
95
|
+
Pero.log.info "bootstrap pero #{host}"
|
96
|
+
puppet.install
|
107
97
|
end
|
98
|
+
rescue StandardError => e
|
99
|
+
Pero.log.error e.backtrace.join("\n")
|
100
|
+
Pero.log.error e.inspect
|
108
101
|
end
|
109
102
|
|
110
103
|
no_commands do
|
111
104
|
def merge_options(node, options)
|
112
|
-
opt = node[
|
113
|
-
opt[
|
114
|
-
if options[
|
115
|
-
opt.delete(
|
105
|
+
opt = node['last_options'].merge(options)
|
106
|
+
opt['environment'] = 'production' if opt['environment'].nil? || opt['environment'].empty?
|
107
|
+
if options['image-name']
|
108
|
+
opt.delete('server-version')
|
116
109
|
else
|
117
|
-
opt.delete(
|
110
|
+
opt.delete('image-name')
|
118
111
|
end
|
119
112
|
opt
|
120
113
|
end
|
121
114
|
|
122
115
|
def prepare
|
123
|
-
`bundle install` if File.exist?(
|
124
|
-
`bundle exec librarian-puppet install` if File.exist?(
|
116
|
+
`bundle install` if File.exist?('Gemfile')
|
117
|
+
`bundle exec librarian-puppet install` if File.exist?('Puppetfile')
|
125
118
|
end
|
126
119
|
end
|
127
120
|
end
|
data/lib/pero/puppet.rb
CHANGED
@@ -94,7 +94,7 @@ module Pero
|
|
94
94
|
@mutex.lock
|
95
95
|
run_container.kill if docker.alerady_run?
|
96
96
|
ensure
|
97
|
-
@mutex.unlock
|
97
|
+
@mutex.unlock
|
98
98
|
end
|
99
99
|
|
100
100
|
def serve_master
|
@@ -115,7 +115,7 @@ module Pero
|
|
115
115
|
@mutex.lock
|
116
116
|
docker.alerady_run? || docker.run
|
117
117
|
ensure
|
118
|
-
@mutex.unlock
|
118
|
+
@mutex.unlock
|
119
119
|
end
|
120
120
|
|
121
121
|
def apply
|
data/lib/pero/version.rb
CHANGED