pero 0.1.0 → 0.1.5

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: 41f1941626b9f892ebe021edc387601c571976a69ea65c936b7464943fe7024e
4
- data.tar.gz: ec1bbb64db216abda864d2d72d1654efb36ab9f8d19f06b155104d4f50d99937
3
+ metadata.gz: c9fe7de2ca2e843f7c2af48b8b3804438aa9ba062145a456b1807b18c4405274
4
+ data.tar.gz: 6d98fb48aa4038a36b48ec9c26b2747c92ad732dc48b1ce3f34f94c6b8f769e9
5
5
  SHA512:
6
- metadata.gz: '002196fd8e20ceb0ca7d1665e4155dd163c7bd63a7c093fef166d6eda6233e9126c9e33bff1310b80674a109f1478477a2a62d9ac819f64f2bc89c2d3e085026'
7
- data.tar.gz: 8c49fc394ee3419d2b233f0776e90c1fe8cb75a15283628650aeb7a60e81a72312964d2b591d4d2191803b020cd2767023ef2a6041a39903ee0d23040af7c66f
6
+ metadata.gz: 2110591370d40c13810cedd3d770c03ec2229b1b8612b16e7ef96d69772f1739d9c2185cfe5c3ee51ad25ad368a7f104cdbf641d9e84dc306c6e0f5c3558ab10
7
+ data.tar.gz: b0b79c02857c85fee733f69d18ab31acc7c48d1931e2bf29e738c3e8366adf70e9d30ca2cd59b13ed57b9e2fa3bc49306f9088da129e9ecf51d3e5bd6afc4461
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ reports
5
5
  run
6
6
  yaml
7
7
  log
8
+ pkg
@@ -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)
@@ -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,7 +86,7 @@ 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
 
@@ -94,8 +99,10 @@ module Pero
94
99
  Pero.log.error e.inspect
95
100
  raise e
96
101
  ensure
97
- Pero.log.info "stop puppet master container"
98
- container.kill if !@options["one-shot"]
102
+ if @options["one-shot"]
103
+ Pero.log.info "stop puppet master container"
104
+ container.kill
105
+ end
99
106
  end
100
107
  end
101
108
 
@@ -108,20 +115,20 @@ module Pero
108
115
  serve_master do |container|
109
116
  port = container.info["Ports"].first["PublicPort"]
110
117
  begin
111
- tmpdir=(0...8).map{ (65 + rand(26)).chr }.join
118
+ tmpdir=container.info["id"][0..5]
112
119
  Pero.log.info "start forwarding port:#{port}"
113
120
 
114
121
  in_ssh_forwarding(port) do |host, ssh|
115
122
  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` && \
123
+ cmd = "mkdir -p /tmp/puppet/#{tmpdir} && unshare -m -- /bin/bash -c 'export PATH=$PATH:/opt/puppetlabs/bin/ && \
124
+ mkdir -p `puppet config print ssldir` && mount --bind /tmp/puppet/#{tmpdir} `puppet config print ssldir` && \
118
125
  #{puppet_cmd}'"
119
126
  Pero.log.debug "run cmd:#{cmd}"
120
127
  ssh.exec!(specinfra.build_command(cmd)) do |channel, stream, data|
121
128
  Pero.log.info "#{host}:#{data.chomp}" if stream == :stdout && data.chomp != ""
122
129
  Pero.log.warn "#{host}:#{data.chomp}" if stream == :stderr && data.chomp != ""
123
130
  end
124
- ssh.exec!(specinfra.build_command("rm -rf /tmp/puppet/#{tmpdir}"))
131
+ ssh.exec!(specinfra.build_command("rm -rf /tmp/puppet/#{tmpdir}")) if @options["one-shot"]
125
132
  ssh.loop {true} if ENV['PERO_DEBUG']
126
133
  end
127
134
  rescue => e
@@ -1,3 +1,3 @@
1
1
  module Pero
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.5"
3
3
  end
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.0
4
+ version: 0.1.5
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-24 00:00:00.000000000 Z
11
+ date: 2020-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor