pero 0.1.1 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80cef5729ae09df0448c266e6e5367f846bf2d9c1b335e0f35bf02b7437924fd
4
- data.tar.gz: 51f5b3b7dd9630bede9fa570832d2a4825a9e959b69128cc5369480cd796447a
3
+ metadata.gz: f970d0b7869fb40c3e86c2946655bd523971901322cf0e290647c2dbe0115a1b
4
+ data.tar.gz: f2a7c166a9feff206398f8e7dad567c24860cd7613f06a1f2a81f3ff6c9f55ac
5
5
  SHA512:
6
- metadata.gz: 22104b9d4f8d1a8b3a594c93d8aaf352cc147bae97f988f44e6e4cd6fc7af899097c7ff6827c474afa520d2fc0af268b86131eecbacf2bf362885d5380b3ca52
7
- data.tar.gz: 158cd30a1ce205662ca59a3d2676bc587d5da64b0ffc26ffc25bd860e60aeba2d24e6561469a6fbdd21cbe5e8469949df9b6790e3e5f269868839597730cc3a5
6
+ metadata.gz: 28ca76f64521f7529d63cb1c7bfd0ab2747ade30d3f0cbe247f6793a45e6c147e677086e896d925bd1fc2401d74bb1265bdd63c88dcd5c801d2c03496834fba0
7
+ data.tar.gz: fc59ba398210e11a801cafa509eb81c8db0dcb6e3837b78562a021f0face8741935ecff2b2d5cac021bd5940612524a3ff5a6d18197022bfb2e181a27aba098f
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ reports
5
5
  run
6
6
  yaml
7
7
  log
8
+ pkg
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pero (0.1.0)
4
+ pero (0.1.5)
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.18)
44
+ specinfra (2.82.19)
45
45
  net-scp
46
46
  net-ssh (>= 2.7)
47
47
  net-telnet (= 0.1.1)
@@ -25,7 +25,7 @@ module Pero
25
25
  option :ask_password, type: :boolean, default: false, desc: "ask ssh or sudo password"
26
26
  option :vagrant, type: :boolean, default: false, desc: "use vagrarant"
27
27
  option :sudo, type: :boolean, default: true, desc: "use sudo"
28
- option "concurrent", aliases: '-N',default: 3, type: :numeric, desc: "running concurrent"
28
+ option "concurrent", aliases: '-C',default: 3, type: :numeric, desc: "running concurrent"
29
29
  end
30
30
 
31
31
  desc "versions", "show support version"
@@ -50,11 +50,11 @@ module Pero
50
50
  end
51
51
  end
52
52
 
53
- desc "install", "install puppet"
53
+ desc "bootstrap", "bootstrap pero"
54
54
  shared_options
55
- option "agent-version", default: "6.17.0", type: :string
55
+ option "agent-version", type: :string
56
56
  option "node-name", aliases: '-N', default: "", type: :string, desc: "json node name(default hostname)"
57
- def install(*hosts)
57
+ def bootstrap(*hosts)
58
58
  Parallel.each(hosts, in_process: options["concurrent"]) do |host|
59
59
  next if host =~ /^-/
60
60
  puppet = Pero::Puppet.new(host, options)
@@ -45,6 +45,7 @@ module Pero
45
45
  'ExposedPorts' => { '8140/tcp' => {} },
46
46
  })
47
47
 
48
+ Pero.log.info "start puppet master container"
48
49
  container.start(
49
50
  'Binds' => [
50
51
  "#{Dir.pwd}:/etc/puppetlabs/code/environments/#{@environment}",
@@ -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],
@@ -73,7 +78,7 @@ module Pero
73
78
  end
74
79
 
75
80
  def install
76
- Pero.log.info "bootstrap puppet"
81
+ Pero.log.info "bootstrap pero"
77
82
  osi = specinfra.os_info
78
83
  os = case osi[:family]
79
84
  when "redhat"
@@ -81,12 +86,11 @@ module Pero
81
86
  else
82
87
  raise "sorry unsupport os, please pull request!!!"
83
88
  end
84
- os.install(@options["agent-version"])
89
+ os.install(@options["agent-version"]) if @options["agent-version"]
85
90
  Pero::History::Attribute.new(specinfra, @options).save
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
@@ -94,8 +98,10 @@ module Pero
94
98
  Pero.log.error e.inspect
95
99
  raise e
96
100
  ensure
97
- Pero.log.info "stop puppet master container"
98
- container.kill if @options["one-shot"]
101
+ if @options["one-shot"]
102
+ Pero.log.info "stop puppet master container"
103
+ container.kill
104
+ end
99
105
  end
100
106
  end
101
107
 
@@ -108,20 +114,18 @@ module Pero
108
114
  serve_master do |container|
109
115
  port = container.info["Ports"].first["PublicPort"]
110
116
  begin
111
- tmpdir=(0...8).map{ (65 + rand(26)).chr }.join
112
- Pero.log.info "start forwarding port:#{port}"
113
-
117
+ tmpdir=container.info["id"][0..5]
114
118
  in_ssh_forwarding(port) do |host, ssh|
115
119
  Pero.log.info "#{host}:puppet cmd[#{puppet_cmd}]"
116
- cmd = "unshare -m -- /bin/bash -c 'export PATH=$PATH:/opt/puppetlabs/bin/ && mkdir -p /tmp/puppet/#{tmpdir} && \
117
- mkdir -p `puppet config print ssldir` && mount --bind /tmp/puppet/#{tmpdir} `puppet config print ssldir` && \
120
+ cmd = "mkdir -p /tmp/puppet/#{tmpdir} && unshare -m -- /bin/bash -c 'export PATH=$PATH:/opt/puppetlabs/bin/ && \
121
+ mkdir -p `puppet config print ssldir` && mount --bind /tmp/puppet/#{tmpdir} `puppet config print ssldir` && \
118
122
  #{puppet_cmd}'"
119
123
  Pero.log.debug "run cmd:#{cmd}"
120
124
  ssh.exec!(specinfra.build_command(cmd)) do |channel, stream, data|
121
125
  Pero.log.info "#{host}:#{data.chomp}" if stream == :stdout && data.chomp != ""
122
126
  Pero.log.warn "#{host}:#{data.chomp}" if stream == :stderr && data.chomp != ""
123
127
  end
124
- ssh.exec!(specinfra.build_command("rm -rf /tmp/puppet/#{tmpdir}"))
128
+ ssh.exec!(specinfra.build_command("rm -rf /tmp/puppet/#{tmpdir}")) if @options["one-shot"]
125
129
  ssh.loop {true} if ENV['PERO_DEBUG']
126
130
  end
127
131
  rescue => e
@@ -156,6 +160,7 @@ module Pero
156
160
  options.delete(:strict_host_key_checking)
157
161
  end
158
162
 
163
+ Pero.log.info "start forwarding #{specinfra.get_config(:host)}:8140 => localhost:#{port}"
159
164
  Net::SSH.start(
160
165
  specinfra.get_config(:host),
161
166
  options[:user],
@@ -1,3 +1,3 @@
1
1
  module Pero
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - pyama86