pero 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2cd510f50571a49f36a9d83b33b6ec102c2ec31dce18ee08223b96d9767a867
4
- data.tar.gz: a576229ec962f9359956f787591b3c14b7d6a779fae2224d06181f4508adb573
3
+ metadata.gz: 17794a1ffa026b662d06b36840a883a434823c791db1839ef1efba8306238a63
4
+ data.tar.gz: af2d15aa1377be5af99b1769c6690adeddba106b51e62eaf20e778566df6a96b
5
5
  SHA512:
6
- metadata.gz: de370da8d84760e9c441630e123ecce5af27fb52af670b9edc16ba62b14b4bdc4b156b343c0ba8f764dc3203cfa3eb5b6ffc9a0d6b17efaa5982e31f68e42e22
7
- data.tar.gz: 743fc365959f454d404d11faf1dda6d4c89242e2e4b054d137c5887befc7fb027c5c56345f6bfc164db4c19e8081d27563e8b19bdcd117d6e1a0ea070940da88
6
+ metadata.gz: 372e94f0f02059e076ebbbf7976ecc188b9f22a983c6fe0cd788e899f3536c0c99a1728d33df080458b7e21bd7207f5df9d547a373837d19da25da6544d43388
7
+ data.tar.gz: 7a4baefe02de81bc4551777fcc785ad1332bf2ee7ede50fd5c1d682dfcb1f5479a32221ccec31c9bae6085964da96d93dafac11c5fce716cd509b4115f4641e1
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ run
6
6
  yaml
7
7
  log
8
8
  pkg
9
+ Gemfile.lock
@@ -22,7 +22,7 @@ module Pero
22
22
  option :port, type: :numeric, aliases: ['-p'], desc: "ssh port"
23
23
  option "timeout", default: 10, type: :numeric, desc: "ssh connect timeout"
24
24
  option :ssh_config, type: :string, desc: "ssh config path"
25
- option :environment, type: :string, desc: "puppet environment", default: "production"
25
+ option :environment, type: :string, desc: "puppet environment"
26
26
  option :ask_password, type: :boolean, default: false, desc: "ask ssh or sudo password"
27
27
  option :vagrant, type: :boolean, default: false, desc: "use vagrarant"
28
28
  option :sudo, type: :boolean, default: true, desc: "use sudo"
@@ -61,6 +61,7 @@ module Pero
61
61
  return unless nodes
62
62
  Parallel.each(nodes, in_process: options["concurrent"]) do |n|
63
63
  opt = n["last_options"].merge(options)
64
+ opt["environment"] = "production" if opt["environment"].empty?
64
65
  if options["image-name"]
65
66
  opt.delete("server-version")
66
67
  else
@@ -80,6 +81,7 @@ module Pero
80
81
  option "node-name", aliases: '-N', default: "", type: :string, desc: "json node name(default hostname)"
81
82
  def bootstrap(*hosts)
82
83
  begin
84
+ options["environment"] = "production" if options["environment"].empty?
83
85
  Parallel.each(hosts, in_process: options["concurrent"]) do |host|
84
86
  raise "unknown option #{host}" if host =~ /^-/
85
87
  puppet = Pero::Puppet.new(host, options)
@@ -94,7 +96,7 @@ module Pero
94
96
 
95
97
  no_commands do
96
98
  def prepare
97
- `bundle insatll` if File.exists?("Gemfile")
99
+ `bundle install` if File.exists?("Gemfile")
98
100
  `bundle exec librarian-puppet install` if File.exists?("Puppetfile")
99
101
  end
100
102
  end
@@ -41,7 +41,7 @@ module Pero
41
41
 
42
42
  def alerady_run?
43
43
  c = find
44
- c && c.info["State"] != "exited" && c
44
+ c && c.info["State"] == "running" && c
45
45
  end
46
46
 
47
47
  def run
@@ -49,23 +49,26 @@ module Pero
49
49
  c.delete(:force => true) if c.info["Names"].first == "/#{container_name}"
50
50
  end
51
51
 
52
+ vols = volumes || []
53
+ vols << "#{Dir.pwd}:/etc/puppetlabs/code/environments/#{@environment}"
54
+ vols << "#{Dir.pwd}/keys:/etc/puppetlabs/puppet/eyaml/"
55
+
52
56
  container = ::Docker::Container.create({
53
57
  'name' => container_name,
54
58
  'Hostname' => 'puppet',
55
59
  'Image' => build.id,
56
60
  'ExposedPorts' => { '8140/tcp' => {} },
61
+ 'HostConfig' => {
62
+ 'Binds' => vols,
63
+ 'PortBindings' => {
64
+ '8140/tcp' => [{ 'HostPort' => "0" }],
65
+ },
66
+ },
67
+ 'Cmd' => ["bash", "-c", "rm -rf #{conf_dir}/ssl/* && #{create_ca} && #{run_cmd}"]
57
68
  })
58
69
 
59
70
  Pero.log.info "start puppet master container"
60
- vols = volumes || []
61
- vols << "#{Dir.pwd}:/etc/puppetlabs/code/environments/#{@environment}"
62
- vols << "#{Dir.pwd}/keys:/etc/puppetlabs/puppet/eyaml/"
63
- container.start(
64
- 'Binds' => vols,
65
- 'PortBindings' => {
66
- '8140/tcp' => [{ 'HostPort' => "0" }],
67
- },
68
- )
71
+ container.start
69
72
 
70
73
  container = find
71
74
  raise "can't start container" unless container
@@ -111,15 +114,28 @@ EOS
111
114
 
112
115
 
113
116
  end
117
+
118
+ def conf_dir
119
+ if Gem::Version.new("4.0.0") > Gem::Version.new(server_version)
120
+ "/etc/puppet"
121
+ elsif Gem::Version.new("5.0.0") > Gem::Version.new(server_version) && Gem::Version.new("4.0.0") <= Gem::Version.new(server_version)
122
+ "/etc/puppetlabs/puppet/"
123
+ elsif Gem::Version.new("6.0.0") > Gem::Version.new(server_version)&& Gem::Version.new("5.0.0") <= Gem::Version.new(server_version)
124
+ "/etc/puppetlabs/puppet/"
125
+ else
126
+ "/etc/puppetlabs/puppet/"
127
+ end
128
+ end
129
+
114
130
  def docker_file
115
- release_package,package_name, conf_dir = if Gem::Version.new("4.0.0") > Gem::Version.new(server_version)
116
- ["puppetlabs-release-el-#{el}.noarch.rpm", "puppet-server", "/etc/puppet"]
131
+ release_package,package_name = if Gem::Version.new("4.0.0") > Gem::Version.new(server_version)
132
+ ["puppetlabs-release-el-#{el}.noarch.rpm", "puppet-server"]
117
133
  elsif Gem::Version.new("5.0.0") > Gem::Version.new(server_version) && Gem::Version.new("4.0.0") <= Gem::Version.new(server_version)
118
- ["puppetlabs-release-pc1-el-#{el}.noarch.rpm", "puppetserver", "/etc/puppetlabs/puppet/"]
134
+ ["puppetlabs-release-pc1-el-#{el}.noarch.rpm", "puppetserver"]
119
135
  elsif Gem::Version.new("6.0.0") > Gem::Version.new(server_version)&& Gem::Version.new("5.0.0") <= Gem::Version.new(server_version)
120
- ["puppet5-release-el-#{el}.noarch.rpm", "puppetserver", "/etc/puppetlabs/puppet/"]
136
+ ["puppet5-release-el-#{el}.noarch.rpm", "puppetserver"]
121
137
  else
122
- ["puppet6-release-el-#{el}.noarch.rpm", "puppetserver", "/etc/puppetlabs/puppet/"]
138
+ ["puppet6-release-el-#{el}.noarch.rpm", "puppetserver"]
123
139
  end
124
140
 
125
141
  <<-EOS
@@ -129,7 +145,6 @@ rpm -ivh #{release_package}
129
145
  RUN yum install -y #{package_name}-#{server_version}
130
146
  ENV PATH $PATH:/opt/puppetlabs/bin
131
147
  RUN echo -e "#{puppet_config.split(/\n/).join("\\n")}" > #{conf_dir}/puppet.conf
132
- CMD bash -c "rm -rf #{conf_dir}/ssl/* && #{create_ca} && #{run_cmd}"
133
148
  EOS
134
149
  end
135
150
 
@@ -1,3 +1,3 @@
1
1
  module Pero
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency 'retryable'
31
31
  spec.add_dependency 'specinfra'
32
32
  spec.add_dependency 'parallel'
33
- spec.add_development_dependency "bundler", "~> 1.17"
34
- spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "bundler"
34
+ spec.add_development_dependency "rake"
35
35
  spec.add_development_dependency "rspec", "~> 3.0"
36
36
  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.2.0
4
+ version: 0.3.0
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-27 00:00:00.000000000 Z
11
+ date: 2020-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -112,30 +112,30 @@ dependencies:
112
112
  name: bundler
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '1.17'
117
+ version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '1.17'
124
+ version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rake
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: '10.0'
131
+ version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: '10.0'
138
+ version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rspec
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -160,7 +160,6 @@ extra_rdoc_files: []
160
160
  files:
161
161
  - ".gitignore"
162
162
  - Gemfile
163
- - Gemfile.lock
164
163
  - LICENSE.txt
165
164
  - README.md
166
165
  - Rakefile
@@ -200,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
199
  - !ruby/object:Gem::Version
201
200
  version: '0'
202
201
  requirements: []
203
- rubygems_version: 3.0.6
202
+ rubygems_version: 3.1.2
204
203
  signing_key:
205
204
  specification_version: 4
206
205
  summary: tool for puppet apply from our desktop.
@@ -1,61 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pero (0.1.9)
5
- docker-api
6
- logger
7
- net-ssh
8
- parallel
9
- retryable
10
- specinfra
11
- thor
12
-
13
- GEM
14
- remote: https://rubygems.org/
15
- specs:
16
- diff-lcs (1.4.4)
17
- docker-api (1.34.2)
18
- excon (>= 0.47.0)
19
- multi_json
20
- excon (0.76.0)
21
- logger (1.4.2)
22
- multi_json (1.15.0)
23
- net-scp (3.0.0)
24
- net-ssh (>= 2.6.5, < 7.0.0)
25
- net-ssh (6.1.0)
26
- net-telnet (0.1.1)
27
- parallel (1.19.2)
28
- rake (10.5.0)
29
- retryable (3.0.5)
30
- rspec (3.9.0)
31
- rspec-core (~> 3.9.0)
32
- rspec-expectations (~> 3.9.0)
33
- rspec-mocks (~> 3.9.0)
34
- rspec-core (3.9.2)
35
- rspec-support (~> 3.9.3)
36
- rspec-expectations (3.9.2)
37
- diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.9.0)
39
- rspec-mocks (3.9.1)
40
- diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.9.0)
42
- rspec-support (3.9.3)
43
- sfl (2.3)
44
- specinfra (2.82.19)
45
- net-scp
46
- net-ssh (>= 2.7)
47
- net-telnet (= 0.1.1)
48
- sfl
49
- thor (1.0.1)
50
-
51
- PLATFORMS
52
- ruby
53
-
54
- DEPENDENCIES
55
- bundler (~> 1.17)
56
- pero!
57
- rake (~> 10.0)
58
- rspec (~> 3.0)
59
-
60
- BUNDLED WITH
61
- 1.17.3