pero 0.5.4 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pero/docker.rb +106 -102
- data/lib/pero/puppet.rb +62 -57
- data/lib/pero/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 987ee0dddd45d8f05e4a1ca60cfe2df83a31542e2793931ddfda01446f3bbe1b
|
4
|
+
data.tar.gz: 791d656dc30d9530316a10fa5b7dc08c69e7089d24a5b040f884435a44f4f038
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1745f07c1634fc170bd6b34c5f2332627a86d2352645045919cdd26e5cf57a3b6bb32e69606b2be4f7dbc6272153905f36095699062a89d047c2e1e54dacd330
|
7
|
+
data.tar.gz: e866274608d76736a53f74f0d9e2b0503c55e200548b1df204059743daca66c7cb208ff387cd9ffcd9bbe170fbd6cc7beb433822ffd55b4c4809104982b537a4
|
data/lib/pero/docker.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'docker'
|
2
2
|
require 'digest/md5'
|
3
|
-
require
|
3
|
+
require 'retryable'
|
4
4
|
require 'net/https'
|
5
5
|
module Pero
|
6
6
|
class Docker
|
7
7
|
attr_reader :server_version, :image_name, :volumes
|
8
|
+
|
8
9
|
def initialize(version, image_name, environment, volumes)
|
9
10
|
@server_version = version
|
10
11
|
@image_name = image_name
|
@@ -13,20 +14,25 @@ module Pero
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def build
|
16
|
-
Pero.log.info
|
17
|
+
Pero.log.info 'start build container'
|
17
18
|
::Docker.options[:read_timeout] = 300
|
18
19
|
begin
|
19
20
|
image = if image_name
|
20
21
|
::Docker::Image.create('fromImage' => image_name)
|
21
22
|
else
|
22
|
-
::Docker::Image.build(
|
23
|
+
::Docker::Image.build(
|
24
|
+
docker_file,
|
25
|
+
{
|
26
|
+
'platform' => ENV['DOCKER_DEFAULT_PLATFORM'] || 'linux/amd64'
|
27
|
+
}
|
28
|
+
)
|
23
29
|
end
|
24
|
-
rescue => e
|
30
|
+
rescue StandardError => e
|
25
31
|
Pero.log.debug docker_file
|
26
32
|
Pero.log.error "failed build container #{e.inspect}"
|
27
33
|
raise e
|
28
34
|
end
|
29
|
-
Pero.log.info
|
35
|
+
Pero.log.info 'success build container'
|
30
36
|
image
|
31
37
|
end
|
32
38
|
|
@@ -35,19 +41,19 @@ module Pero
|
|
35
41
|
end
|
36
42
|
|
37
43
|
def find
|
38
|
-
::Docker::Container.all(:
|
39
|
-
c.info[
|
44
|
+
::Docker::Container.all(all: true).find do |c|
|
45
|
+
c.info['Names'].first == "/#{container_name}"
|
40
46
|
end
|
41
47
|
end
|
42
48
|
|
43
49
|
def alerady_run?
|
44
50
|
c = find
|
45
|
-
c && c.info[
|
51
|
+
c && c.info['State'] == 'running' && c
|
46
52
|
end
|
47
53
|
|
48
54
|
def run
|
49
|
-
::Docker::Container.all(:
|
50
|
-
c.delete(:
|
55
|
+
::Docker::Container.all(all: true).each do |c|
|
56
|
+
c.delete(force: true) if c.info['Names'].first == "/#{container_name}"
|
51
57
|
end
|
52
58
|
|
53
59
|
vols = volumes || []
|
@@ -55,124 +61,122 @@ module Pero
|
|
55
61
|
vols << "#{Dir.pwd}/keys:/etc/puppetlabs/puppet/eyaml/"
|
56
62
|
|
57
63
|
container = ::Docker::Container.create({
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
64
|
+
'name' => container_name,
|
65
|
+
'Hostname' => 'puppet',
|
66
|
+
'Image' => build.id,
|
67
|
+
'ExposedPorts' => { '8140/tcp' => {} },
|
68
|
+
'HostConfig' => {
|
69
|
+
'Binds' => vols,
|
70
|
+
'PortBindings' => {
|
71
|
+
'8140/tcp' => [{ 'HostPort' => '0' }]
|
72
|
+
}
|
73
|
+
},
|
74
|
+
'platform' => ENV['DOCKER_DEFAULT_PLATFORM'] || 'linux/amd64',
|
75
|
+
'Cmd' => ['bash', '-c', "rm -rf #{conf_dir}/ssl/* && #{create_ca} && #{run_cmd}"]
|
76
|
+
})
|
77
|
+
|
78
|
+
Pero.log.info 'start puppet master container'
|
72
79
|
container.start
|
73
80
|
|
74
81
|
container = find
|
75
82
|
raise "can't start container" unless container
|
83
|
+
|
76
84
|
begin
|
77
85
|
Retryable.retryable(tries: 20, sleep: 5) do
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
https.
|
84
|
-
|
85
|
-
Pero.log.debug "puppet http response #{response}"
|
86
|
-
}
|
87
|
-
rescue => e
|
88
|
-
Pero.log.debug e.inspect
|
89
|
-
raise e
|
86
|
+
https = Net::HTTP.new('localhost', container.info['Ports'].first['PublicPort'])
|
87
|
+
https.use_ssl = true
|
88
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
89
|
+
Pero.log.debug 'start server health check'
|
90
|
+
https.start do
|
91
|
+
response = https.get('/')
|
92
|
+
Pero.log.debug "puppet http response #{response}"
|
90
93
|
end
|
94
|
+
rescue StandardError => e
|
95
|
+
Pero.log.debug e.inspect
|
96
|
+
raise e
|
91
97
|
end
|
92
|
-
rescue
|
93
|
-
Pero.log.error "can't start container.please check [ docker logs #{container.info[
|
98
|
+
rescue StandardError
|
99
|
+
Pero.log.error "can't start container.please check [ docker logs #{container.info['id']} ]"
|
94
100
|
container = find
|
95
|
-
container.kill if container && container.info[
|
101
|
+
container.kill if container && container.info['State'] != 'exited'
|
96
102
|
raise "can't start puppet server"
|
97
103
|
end
|
98
104
|
container
|
99
105
|
end
|
100
106
|
|
101
107
|
def puppet_config
|
102
|
-
|
103
|
-
[master]
|
104
|
-
vardir = /var/puppet
|
105
|
-
certname = puppet
|
106
|
-
dns_alt_names = puppet,localhost
|
107
|
-
autosign = true
|
108
|
-
environment_timeout = unlimited
|
109
|
-
codedir = /etc/puppetlabs/code
|
110
|
-
|
111
|
-
[main]
|
112
|
-
server = puppet
|
113
|
-
#{@environment && @environment !=
|
114
|
-
EOS
|
115
|
-
|
116
|
-
|
108
|
+
<<~EOS
|
109
|
+
[master]
|
110
|
+
vardir = /var/puppet
|
111
|
+
certname = puppet
|
112
|
+
dns_alt_names = puppet,localhost
|
113
|
+
autosign = true
|
114
|
+
environment_timeout = unlimited
|
115
|
+
codedir = /etc/puppetlabs/code
|
116
|
+
|
117
|
+
[main]
|
118
|
+
server = puppet
|
119
|
+
#{@environment && @environment != '' ? "environment = #{@environment}" : nil}
|
120
|
+
EOS
|
117
121
|
end
|
118
122
|
|
119
123
|
def conf_dir
|
120
|
-
if Gem::Version.new(
|
121
|
-
|
122
|
-
elsif Gem::Version.new(
|
123
|
-
|
124
|
-
elsif Gem::Version.new(
|
125
|
-
|
124
|
+
if Gem::Version.new('4.0.0') > Gem::Version.new(server_version)
|
125
|
+
'/etc/puppet'
|
126
|
+
elsif Gem::Version.new('5.0.0') > Gem::Version.new(server_version) && Gem::Version.new('4.0.0') <= Gem::Version.new(server_version)
|
127
|
+
'/etc/puppetlabs/puppet/'
|
128
|
+
elsif Gem::Version.new('6.0.0') > Gem::Version.new(server_version) && Gem::Version.new('5.0.0') <= Gem::Version.new(server_version)
|
129
|
+
'/etc/puppetlabs/puppet/'
|
126
130
|
else
|
127
|
-
|
131
|
+
'/etc/puppetlabs/puppet/'
|
128
132
|
end
|
129
133
|
end
|
130
134
|
|
131
135
|
def docker_file
|
132
|
-
release_package,package_name = if Gem::Version.new(
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
136
|
+
release_package, package_name = if Gem::Version.new('4.0.0') > Gem::Version.new(server_version)
|
137
|
+
["puppetlabs-release-el-#{el}.noarch.rpm", 'puppet-server']
|
138
|
+
elsif Gem::Version.new('5.0.0') > Gem::Version.new(server_version) && Gem::Version.new('4.0.0') <= Gem::Version.new(server_version)
|
139
|
+
["puppetlabs-release-pc1-el-#{el}.noarch.rpm", 'puppetserver']
|
140
|
+
elsif Gem::Version.new('6.0.0') > Gem::Version.new(server_version) && Gem::Version.new('5.0.0') <= Gem::Version.new(server_version)
|
141
|
+
["puppet5-release-el-#{el}.noarch.rpm", 'puppetserver']
|
142
|
+
elsif Gem::Version.new('7.0.0') > Gem::Version.new(server_version) && Gem::Version.new('6.0.0') <= Gem::Version.new(server_version)
|
143
|
+
["puppet6-release-el-#{el}.noarch.rpm", 'puppetserver']
|
144
|
+
else
|
145
|
+
["puppet7-release-el-#{el}.noarch.rpm", 'puppetserver']
|
146
|
+
end
|
143
147
|
|
144
148
|
vault_repo = if el == 6
|
145
|
-
|
146
|
-
RUN sed -i "s|#baseurl=|baseurl=|g" /etc/yum.repos.d/CentOS-Base.repo \
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
legacy_signing = if Gem::Version.new(
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
FROM #{from_image}
|
162
|
-
#{vault_repo}
|
163
|
-
#{legacy_signing}
|
164
|
-
RUN curl -L -k -O https://yum.puppetlabs.com/#{release_package} && \
|
165
|
-
rpm -ivh #{release_package}
|
166
|
-
RUN yum install -y #{package_name}-#{server_version}
|
167
|
-
ENV PATH $PATH:/opt/puppetlabs/bin
|
168
|
-
RUN echo -e "#{puppet_config.split(/\n/).join(
|
149
|
+
<<~EOS
|
150
|
+
RUN sed -i "s|#baseurl=|baseurl=|g" /etc/yum.repos.d/CentOS-Base.repo \
|
151
|
+
&& sed -i "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-Base.repo \
|
152
|
+
&& sed -i "s|http://mirror\.centos\.org/|http://vault\.centos\.org/|g" /etc/yum.repos.d/CentOS-Base.repo
|
153
|
+
EOS
|
154
|
+
else
|
155
|
+
''
|
156
|
+
end
|
157
|
+
|
158
|
+
legacy_signing = if Gem::Version.new('3.0.0') > Gem::Version.new(server_version)
|
159
|
+
"RUN echo 'LegacySigningMDs md5' >> /etc/pki/tls/legacy-settings"
|
160
|
+
else
|
161
|
+
''
|
162
|
+
end
|
163
|
+
|
164
|
+
<<~EOS
|
165
|
+
FROM #{from_image}
|
166
|
+
#{vault_repo}
|
167
|
+
#{legacy_signing}
|
168
|
+
RUN curl -L -k -O https://yum.puppetlabs.com/#{release_package} && \
|
169
|
+
rpm -ivh #{release_package}
|
170
|
+
RUN yum install -y #{package_name}-#{server_version}
|
171
|
+
ENV PATH $PATH:/opt/puppetlabs/bin
|
172
|
+
RUN echo -e "#{puppet_config.split(/\n/).join('\\n')}" > #{conf_dir}/puppet.conf
|
169
173
|
EOS
|
170
174
|
end
|
171
175
|
|
172
176
|
def create_ca
|
173
|
-
if Gem::Version.new(
|
177
|
+
if Gem::Version.new('5.0.0') > Gem::Version.new(server_version)
|
174
178
|
'puppet cert generate `hostname` --dns_alt_names localhost,127.0.0.1'
|
175
|
-
elsif Gem::Version.new(
|
179
|
+
elsif Gem::Version.new('6.0.0') > Gem::Version.new(server_version)
|
176
180
|
'puppet cert generate `hostname` --dns_alt_names localhost,127.0.0.1'
|
177
181
|
else
|
178
182
|
'puppetserver ca setup --ca-name `hostname` --subject-alt-names DNS:localhost'
|
@@ -180,14 +184,14 @@ RUN echo -e "#{puppet_config.split(/\n/).join("\\n")}" > #{conf_dir}/puppet.conf
|
|
180
184
|
end
|
181
185
|
|
182
186
|
def run_cmd
|
183
|
-
if Gem::Version.new(
|
187
|
+
if Gem::Version.new('3.0.0') > Gem::Version.new(server_version)
|
184
188
|
# /var/puppet/run is created for the first time by running `puppet master`,
|
185
189
|
# but `puppet master` will fail because the permissions are wrong.
|
186
190
|
# So, let the `puppet master` fail once, fix the permission of /var/puppet/run, and execute `puppet master` again.
|
187
191
|
'puppet master --no-daemonize --verbose || (chown puppet: /var/puppet/run && puppet master --no-daemonize --verbose)'
|
188
|
-
elsif Gem::Version.new(
|
192
|
+
elsif Gem::Version.new('5.0.0') > Gem::Version.new(server_version)
|
189
193
|
'puppet master --no-daemonize --verbose'
|
190
|
-
elsif Gem::Version.new(
|
194
|
+
elsif Gem::Version.new('6.0.0') > Gem::Version.new(server_version)
|
191
195
|
'puppetserver foreground'
|
192
196
|
else
|
193
197
|
'puppetserver foreground'
|
@@ -195,7 +199,7 @@ RUN echo -e "#{puppet_config.split(/\n/).join("\\n")}" > #{conf_dir}/puppet.conf
|
|
195
199
|
end
|
196
200
|
|
197
201
|
def el
|
198
|
-
if Gem::Version.new(
|
202
|
+
if Gem::Version.new('3.5.1') > Gem::Version.new(server_version)
|
199
203
|
6
|
200
204
|
else
|
201
205
|
7
|
data/lib/pero/puppet.rb
CHANGED
@@ -9,9 +9,9 @@ module Specinfra
|
|
9
9
|
return @sudo_password if defined?(@sudo_password)
|
10
10
|
|
11
11
|
# TODO: Fix this dirty hack
|
12
|
-
return nil unless caller.any? {|call| call.include?('channel_data') }
|
12
|
+
return nil unless caller.any? { |call| call.include?('channel_data') }
|
13
13
|
|
14
|
-
print
|
14
|
+
print 'sudo password: '
|
15
15
|
@sudo_password = STDIN.noecho(&:gets).strip
|
16
16
|
print "\n"
|
17
17
|
@sudo_password
|
@@ -23,6 +23,7 @@ module Pero
|
|
23
23
|
class Puppet
|
24
24
|
extend Pero::SshExecutable
|
25
25
|
attr_reader :specinfra
|
26
|
+
|
26
27
|
def initialize(host, options, mutex)
|
27
28
|
@options = options.dup
|
28
29
|
@mutex = mutex
|
@@ -30,15 +31,13 @@ module Pero
|
|
30
31
|
@options[:host] = host
|
31
32
|
so = ssh_options
|
32
33
|
|
33
|
-
|
34
|
-
so.delete(:strict_host_key_checking)
|
35
|
-
end
|
34
|
+
so.delete(:strict_host_key_checking) unless Net::SSH::VALID_OPTIONS.include?(:strict_host_key_checking)
|
36
35
|
|
37
36
|
@specinfra = Specinfra::Backend::Ssh.new(
|
38
37
|
request_pty: true,
|
39
38
|
host: so[:host_name],
|
40
39
|
ssh_options: so,
|
41
|
-
disable_sudo: false
|
40
|
+
disable_sudo: false
|
42
41
|
)
|
43
42
|
end
|
44
43
|
|
@@ -48,15 +47,15 @@ module Pero
|
|
48
47
|
opts[:host_name] = @options[:host]
|
49
48
|
|
50
49
|
# from ssh-config
|
51
|
-
ssh_config_files = @options[
|
52
|
-
opts.merge!(Net::SSH::Config.for(@options[
|
53
|
-
opts[:user] = @options[
|
54
|
-
opts[:password] = @options[
|
55
|
-
opts[:keys] = [@options[
|
56
|
-
opts[:port] = @options[
|
57
|
-
opts[:timeout] = @options[
|
58
|
-
|
59
|
-
if @options[
|
50
|
+
ssh_config_files = @options['ssh_config'] ? [@options['ssh_config']] : Net::SSH::Config.default_files
|
51
|
+
opts.merge!(Net::SSH::Config.for(@options['host'], ssh_config_files))
|
52
|
+
opts[:user] = @options['user'] || opts[:user] || Etc.getlogin
|
53
|
+
opts[:password] = @options['password'] if @options['password']
|
54
|
+
opts[:keys] = [@options['key']] if @options['key']
|
55
|
+
opts[:port] = @options['port'] if @options['port']
|
56
|
+
opts[:timeout] = @options['timeout'] if @options['timeout']
|
57
|
+
|
58
|
+
if @options['vagrant']
|
60
59
|
config = Tempfile.new('', Dir.tmpdir)
|
61
60
|
hostname = opts[:host_name] || 'default'
|
62
61
|
vagrant_cmd = "vagrant ssh-config #{hostname} > #{config.path}"
|
@@ -70,8 +69,8 @@ module Pero
|
|
70
69
|
opts.merge!(Net::SSH::Config.for(hostname, [config.path]))
|
71
70
|
end
|
72
71
|
|
73
|
-
if @options[
|
74
|
-
print
|
72
|
+
if @options['ask_password']
|
73
|
+
print 'password: '
|
75
74
|
password = STDIN.noecho(&:gets).strip
|
76
75
|
print "\n"
|
77
76
|
opts.merge!(password: password)
|
@@ -82,47 +81,55 @@ module Pero
|
|
82
81
|
def install
|
83
82
|
osi = specinfra.os_info
|
84
83
|
os = case osi[:family]
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
os.install(@options[
|
84
|
+
when 'redhat'
|
85
|
+
Redhat.new(specinfra, osi)
|
86
|
+
else
|
87
|
+
raise 'sorry unsupport os, please pull request!!!'
|
88
|
+
end
|
89
|
+
os.install(@options['agent-version']) if @options['agent-version']
|
91
90
|
Pero::History::Attribute.new(specinfra, @options).save
|
92
91
|
end
|
93
92
|
|
94
93
|
def stop_master
|
94
|
+
@mutex.lock
|
95
95
|
run_container.kill if docker.alerady_run?
|
96
|
+
ensure
|
97
|
+
@mutex.unlock
|
96
98
|
end
|
97
99
|
|
98
100
|
def serve_master
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
101
|
+
container = run_container
|
102
|
+
begin
|
103
|
+
yield container
|
104
|
+
rescue StandardError => e
|
105
|
+
Pero.log.error e.inspect
|
106
|
+
raise e
|
107
|
+
end
|
106
108
|
end
|
107
109
|
|
108
110
|
def docker
|
109
|
-
Pero::Docker.new(@options[
|
111
|
+
Pero::Docker.new(@options['server-version'], @options['image-name'], @options['environment'], @options['volumes'])
|
110
112
|
end
|
111
113
|
|
112
114
|
def run_container
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
@mutex.unlock
|
118
|
-
end
|
115
|
+
@mutex.lock
|
116
|
+
docker.alerady_run? || docker.run
|
117
|
+
ensure
|
118
|
+
@mutex.unlock
|
119
119
|
end
|
120
120
|
|
121
121
|
def apply
|
122
122
|
serve_master do |container|
|
123
|
-
port = container.info[
|
123
|
+
port = container.info['Ports'].first['PublicPort']
|
124
|
+
https = Net::HTTP.new('localhost', port)
|
125
|
+
https.use_ssl = true
|
126
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
127
|
+
https.start do
|
128
|
+
https.delete('/puppet-admin-api/v1/environment-cache')
|
129
|
+
end
|
130
|
+
|
124
131
|
begin
|
125
|
-
tmpdir=container.info[
|
132
|
+
tmpdir = container.info['id'][0..5]
|
126
133
|
in_ssh_forwarding(port) do |host, ssh|
|
127
134
|
Pero.log.info "#{host}:puppet cmd[#{puppet_cmd}]"
|
128
135
|
cmd = "mkdir -p /tmp/puppet/#{tmpdir} && unshare -m -- /bin/bash -c 'export PATH=$PATH:/opt/puppetlabs/bin/ && \
|
@@ -131,14 +138,14 @@ module Pero
|
|
131
138
|
Pero.log.debug "run cmd:#{cmd}"
|
132
139
|
ssh_exec(ssh, host, cmd)
|
133
140
|
|
134
|
-
if @options[
|
141
|
+
if @options['one-shot']
|
135
142
|
cmd = "/bin/rm -rf /tmp/puppet/#{tmpdir}"
|
136
143
|
ssh_exec(ssh, host, cmd)
|
137
144
|
end
|
138
145
|
|
139
|
-
ssh.loop {true} if ENV['PERO_DEBUG']
|
146
|
+
ssh.loop { true } if ENV['PERO_DEBUG']
|
140
147
|
end
|
141
|
-
rescue => e
|
148
|
+
rescue StandardError => e
|
142
149
|
Pero.log.error "puppet apply error:#{e.inspect}"
|
143
150
|
end
|
144
151
|
end
|
@@ -149,15 +156,15 @@ module Pero
|
|
149
156
|
def ssh_exec(ssh, host, cmd)
|
150
157
|
ssh.open_channel do |ch|
|
151
158
|
ch.request_pty
|
152
|
-
ch.on_data do |
|
159
|
+
ch.on_data do |_ch, data|
|
153
160
|
Pero.log.info "#{host}:#{data.chomp}"
|
154
161
|
end
|
155
162
|
|
156
|
-
ch.on_extended_data do |
|
163
|
+
ch.on_extended_data do |_c, _type, data|
|
157
164
|
Pero.log.error "#{host}:#{data.chomp}"
|
158
165
|
end
|
159
166
|
|
160
|
-
ch.exec specinfra.build_command(cmd) do |
|
167
|
+
ch.exec specinfra.build_command(cmd) do |_ch, success|
|
161
168
|
raise "could not execute #{cmd}" unless success
|
162
169
|
end
|
163
170
|
end
|
@@ -165,29 +172,27 @@ module Pero
|
|
165
172
|
end
|
166
173
|
|
167
174
|
def puppet_cmd
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
175
|
+
if Gem::Version.new('5.0.0') > Gem::Version.new(@options['agent-version'])
|
176
|
+
"puppet agent --no-daemonize --onetime #{parse_puppet_option(@options)} --ca_port 8140 --ca_server localhost --masterport 8140 --server localhost"
|
177
|
+
else
|
178
|
+
"/opt/puppetlabs/bin/puppet agent --no-daemonize --onetime #{parse_puppet_option(@options)} --ca_server localhost --masterport 8140 --server localhost"
|
179
|
+
end
|
173
180
|
end
|
174
181
|
|
175
182
|
def parse_puppet_option(options)
|
176
|
-
ret =
|
177
|
-
%w
|
183
|
+
ret = ''
|
184
|
+
%w[noop verbose test].each do |n|
|
178
185
|
ret << " --#{n}" if options[n]
|
179
186
|
end
|
180
|
-
ret << " --tags #{options[
|
181
|
-
ret << " --environment #{options[
|
187
|
+
ret << " --tags #{options['tags'].join(',')}" if options['tags']
|
188
|
+
ret << " --environment #{options['environment']}" if options['environment']
|
182
189
|
ret
|
183
190
|
end
|
184
191
|
|
185
192
|
def in_ssh_forwarding(port)
|
186
193
|
options = specinfra.get_config(:ssh_options)
|
187
194
|
|
188
|
-
|
189
|
-
options.delete(:strict_host_key_checking)
|
190
|
-
end
|
195
|
+
options.delete(:strict_host_key_checking) unless Net::SSH::VALID_OPTIONS.include?(:strict_host_key_checking)
|
191
196
|
|
192
197
|
Pero.log.info "start forwarding #{specinfra.get_config(:host)}:8140 => localhost:#{port}"
|
193
198
|
Net::SSH.start(
|
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.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyama86
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: '0'
|
201
201
|
requirements: []
|
202
|
-
rubygems_version: 3.
|
202
|
+
rubygems_version: 3.4.19
|
203
203
|
signing_key:
|
204
204
|
specification_version: 4
|
205
205
|
summary: tool for puppet apply from our desktop.
|