opskeleton 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
data/lib/opskeleton.rb CHANGED
@@ -6,12 +6,10 @@ require 'yaml'
6
6
  require 'ostruct'
7
7
  require 'git'
8
8
  require 'opskeleton/thorable'
9
- require 'opskeleton/dockerize'
10
9
  require 'opskeleton/package'
11
10
  require 'opskeleton/clean'
12
11
  require 'opskeleton/bump'
13
12
  require 'opskeleton/generate_puppet'
14
- require 'opskeleton/generate_chef'
15
13
  require 'opskeleton/deploy_bintray'
16
14
  require 'opskeleton/deploy_s3'
17
15
  require 'opskeleton/deploy_scp'
@@ -20,4 +18,6 @@ require 'opskeleton/commit'
20
18
  require 'opskeleton/uncommited'
21
19
  require 'opskeleton/push'
22
20
  require 'opskeleton/git'
21
+ require 'opskeleton/update'
22
+ require 'opskeleton/analyze'
23
23
 
@@ -0,0 +1,18 @@
1
+
2
+ module Opsk
3
+ class Analyze < Thor::Group
4
+ include Thorable, Thor::Actions
5
+
6
+ argument :file, :type => :string, :desc => 'the puppet log input file'
7
+ class_option :threshold, :type=> :string, :desc => 'minimum run time filter'
8
+
9
+ def report
10
+ threshold = options['threshold'] || '0.01'
11
+ rs = File.readlines(file).find_all{|line| line.include?('Evaluated')}
12
+ top = rs.collect {|r| r.split(' ').values_at(3 , 7)}.find_all{|r| r[1].to_f > threshold.to_f}
13
+ top.sort_by{|r| r[1].to_f}.reverse.each {|r|
14
+ say("#{r[0]} #{r[1]}")
15
+ }
16
+ end
17
+ end
18
+ end
@@ -17,14 +17,6 @@ module Opsk
17
17
 
18
18
  def cleanup
19
19
  remove_dir('pkg')
20
- if(File.exists?('dockerfiles'))
21
- images = Dir['dockerfiles/*'].select{|file| File.ftype(file) == 'directory'}
22
- images.each do |path|
23
- if(File.ftype(path) == 'directory')
24
- remove_dir("#{path}/pkg")
25
- end
26
- end
27
- end
28
20
  end
29
21
 
30
22
  end
@@ -14,7 +14,7 @@ module Opsk
14
14
  meta.includes.each {|f|
15
15
  if(File.directory?("#{path}/#{f}"))
16
16
  directory "#{path}/#{f}", "#{artifact_path}/#{f}", :verbose => false
17
- elsif(File.exists?("#{path}/#{f}"))
17
+ elsif(File.exist?("#{path}/#{f}"))
18
18
  copy_file "#{path}/#{f}", "#{artifact_path}/#{f}"
19
19
  else
20
20
  raise Exception.new("#{f} not found please validate opks.yaml includes section")
@@ -23,16 +23,16 @@ module Opsk
23
23
 
24
24
  meta.excludes.each {|f| remove_file("#{artifact_path}/#{f}") } if(meta.excludes)
25
25
 
26
- unless(File.exists?("#{artifact_path}/manifests/site.pp"))
26
+ unless(File.exist?("#{artifact_path}/manifests/site.pp"))
27
27
  template('templates/puppet/site.erb', "#{artifact_path}/manifests/site.pp")
28
28
  end
29
29
  end
30
30
 
31
31
  def scripts
32
32
  empty_directory("#{artifact_path}/scripts")
33
- files = {:puppet => %w(lookup.rb run.sh) , :chef => [] }
33
+ files = {:puppet => %w(lookup.rb run.sh) }
34
34
  files[type_of].each do |s|
35
- unless(File.exists?("#{artifact_path}/scripts/#{s}"))
35
+ unless(File.exist?("#{artifact_path}/scripts/#{s}"))
36
36
  template("templates/#{type_of}/scripts/#{s}", "#{artifact_path}/scripts/#{s}")
37
37
  chmod("#{artifact_path}/scripts/#{s}", 0755)
38
38
  end
@@ -42,7 +42,6 @@ module Opsk
42
42
  def package
43
43
  ignored = IO.readlines('.gitignore').map(&:chomp)
44
44
  ignored.delete('modules')
45
- ignored.delete('cookbooks')
46
45
  ignored = ignored.select {|ig| !meta.includes.include?(ig)}
47
46
  excludes = ignored.map{|f| "'#{f}'"}.join(" --exclude=") << ' --exclude-backups --exclude-vcs --exclude=pkg'
48
47
  tar = "#{artifact}.tar.gz"
@@ -53,19 +52,6 @@ module Opsk
53
52
 
54
53
  end
55
54
 
56
- def dockercopy
57
- tar = "#{artifact}.tar.gz"
58
- if(File.exists?('dockerfiles'))
59
- images = Dir['dockerfiles/*'].select{|file| File.ftype(file) == 'directory'}
60
- images.each do |path|
61
- if(File.ftype(path) == 'directory')
62
- empty_directory "#{path}/pkg"
63
- FileUtils.copy "pkg/#{tar}", "#{path}/pkg/#{tar}"
64
- end
65
- end
66
- end
67
- end
68
-
69
55
  end
70
56
 
71
57
  end
@@ -17,8 +17,7 @@ module Opsk
17
17
 
18
18
  def type_of
19
19
  return :puppet if meta.includes.include?('Puppetfile')
20
- return :chef if meta.includes.include?('Cheffile')
21
- raise Exception.new('no matching provisoner type found, make sure to include Cheffile or Pupppetfile in opsk.yaml')
20
+ raise Exception.new('no matching provisoner type found, make sure to include Pupppetfile in opsk.yaml')
22
21
  end
23
22
 
24
23
  def name
@@ -0,0 +1,27 @@
1
+ module Opsk
2
+ class Update < Thor::Group
3
+ include Thorable, Thor::Actions
4
+ class_option :module, :type=> :string, :desc => 'module to update'
5
+
6
+ def update
7
+ Dir["./*"].reject{|o| not File.directory?(o)}.each do |d|
8
+ resp = yes?("Update #{d}? (y/n)") unless options['all']
9
+ if File.exists?("#{d}/Puppetfile") and resp
10
+ inside(d) do
11
+ run("librarian-puppet update #{options['module']}")
12
+ end
13
+ resp = yes?("Commit Puppetfile.lock#{d}? (y/n)") unless options['all']
14
+ if resp
15
+ git = Opsk::Git.new(d,self)
16
+ git.add("#{d}/Puppetfile.lock")
17
+ git.commit("Opsk: updating #{options['module']}")
18
+ git.push
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+
@@ -1,3 +1,3 @@
1
1
  module Opskeleton
2
- VERSION = '0.9.8'
2
+ VERSION = '0.9.9'
3
3
  end
data/opskeleton.gemspec CHANGED
@@ -8,27 +8,25 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Opskeleton::VERSION
9
9
  gem.authors = ["narkisr"]
10
10
  gem.email = ["narkisr@gmail.com"]
11
- gem.description = %q{A generator for ops projects that include vagrant puppet and fpm}
12
- gem.summary = %q{A generator for ops projects that include vagrant puppet and fpm}
11
+ gem.description = %q{Managing services lifecycle from Development to production using Vagrant and Puppet}
12
+ gem.summary = %q{Managing services lifecycle from Development to production using Vagrant and Puppet}
13
13
  gem.homepage = "https://github.com/narkisr/opskeleton"
14
14
  gem.add_dependency('thor')
15
15
  gem.add_dependency('bintray_deploy')
16
16
  gem.add_dependency('aws-sdk', '~> 2')
17
17
  gem.add_dependency('net-scp')
18
18
  gem.add_dependency('git')
19
- gem.add_dependency('git_clone_url')
20
- gem.add_development_dependency('puppet','=3.7.5')
21
- gem.add_development_dependency('chef')
19
+ gem.add_dependency('git_clone_url', '~> 1.0')
20
+ gem.add_development_dependency('puppet','=3.8.7')
22
21
  gem.add_development_dependency('rspec-puppet')
23
22
  gem.add_development_dependency('librarian-puppet', '= 2.1.0')
24
23
  gem.add_development_dependency('puppetlabs_spec_helper', '>= 0.1.0')
25
- gem.add_development_dependency('pry')
26
24
  gem.add_development_dependency('asciidoctor')
27
25
  gem.add_development_dependency('pygments.rb')
28
- gem.add_development_dependency('guard')
26
+ gem.add_development_dependency('guard', '= 2.13.0')
29
27
  gem.add_development_dependency('guard-shell')
30
28
  gem.add_development_dependency('guard-minitest')
31
-
29
+
32
30
  gem.files = `git ls-files`.split($/)
33
31
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
34
32
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
data/test/test_helper.rb CHANGED
@@ -7,7 +7,6 @@ require 'opskeleton'
7
7
  module Opsk
8
8
  class Root < Thor
9
9
  register Opsk::GeneratePuppet, 'generate_puppet', 'generate_puppet [name] [box]', 'generates opskelaton project structure'
10
- register Opsk::GenerateChef, 'generate_chef', 'generate_chef [name] [box]', 'generates opskelaton project structure'
11
10
  register Opsk::Package, 'package', 'package', 'packages current module for celestial'
12
11
  register Opsk::Commit, 'commit', 'commit', 'commits current module for celestial'
13
12
  register Opsk::Push, 'push', 'push', 'push changed repos'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opskeleton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - narkisr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-26 00:00:00.000000000 Z
11
+ date: 2017-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -84,44 +84,30 @@ dependencies:
84
84
  name: git_clone_url
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '1.0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '1.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: puppet
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 3.7.5
103
+ version: 3.8.7
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 3.7.5
111
- - !ruby/object:Gem::Dependency
112
- name: chef
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
110
+ version: 3.8.7
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: rspec-puppet
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -164,20 +150,6 @@ dependencies:
164
150
  - - ">="
165
151
  - !ruby/object:Gem::Version
166
152
  version: 0.1.0
167
- - !ruby/object:Gem::Dependency
168
- name: pry
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
153
  - !ruby/object:Gem::Dependency
182
154
  name: asciidoctor
183
155
  requirement: !ruby/object:Gem::Requirement
@@ -210,16 +182,16 @@ dependencies:
210
182
  name: guard
211
183
  requirement: !ruby/object:Gem::Requirement
212
184
  requirements:
213
- - - ">="
185
+ - - '='
214
186
  - !ruby/object:Gem::Version
215
- version: '0'
187
+ version: 2.13.0
216
188
  type: :development
217
189
  prerelease: false
218
190
  version_requirements: !ruby/object:Gem::Requirement
219
191
  requirements:
220
- - - ">="
192
+ - - '='
221
193
  - !ruby/object:Gem::Version
222
- version: '0'
194
+ version: 2.13.0
223
195
  - !ruby/object:Gem::Dependency
224
196
  name: guard-shell
225
197
  requirement: !ruby/object:Gem::Requirement
@@ -248,7 +220,8 @@ dependencies:
248
220
  - - ">="
249
221
  - !ruby/object:Gem::Version
250
222
  version: '0'
251
- description: A generator for ops projects that include vagrant puppet and fpm
223
+ description: Managing services lifecycle from Development to production using Vagrant
224
+ and Puppet
252
225
  email:
253
226
  - narkisr@gmail.com
254
227
  executables:
@@ -268,6 +241,7 @@ files:
268
241
  - README.md
269
242
  - Rakefile
270
243
  - TODOS
244
+ - autocomplete/_opsk
271
245
  - autocomplete/opsk_bash_completion
272
246
  - bin/opsk
273
247
  - docs/chef.md
@@ -280,14 +254,13 @@ files:
280
254
  - img/puppet-cycle.png
281
255
  - img/puppet-layout.png
282
256
  - lib/opskeleton.rb
257
+ - lib/opskeleton/analyze.rb
283
258
  - lib/opskeleton/bump.rb
284
259
  - lib/opskeleton/clean.rb
285
260
  - lib/opskeleton/commit.rb
286
261
  - lib/opskeleton/deploy_bintray.rb
287
262
  - lib/opskeleton/deploy_s3.rb
288
263
  - lib/opskeleton/deploy_scp.rb
289
- - lib/opskeleton/dockerize.rb
290
- - lib/opskeleton/generate_chef.rb
291
264
  - lib/opskeleton/generate_puppet.rb
292
265
  - lib/opskeleton/git.rb
293
266
  - lib/opskeleton/module.rb
@@ -295,25 +268,12 @@ files:
295
268
  - lib/opskeleton/push.rb
296
269
  - lib/opskeleton/thorable.rb
297
270
  - lib/opskeleton/uncommited.rb
271
+ - lib/opskeleton/update.rb
298
272
  - lib/opskeleton/version.rb
299
273
  - opskeleton.gemspec
300
274
  - templates/LICENSE-2.0.txt
301
275
  - templates/README.erb
302
- - templates/chef/Cheffile
303
- - templates/chef/Gemfile.erb
304
- - templates/chef/Rakefile.erb
305
- - templates/chef/boot.sh
306
- - templates/chef/dna.json.erb
307
- - templates/chef/environments/dev.rb
308
- - templates/chef/gitignore
309
- - templates/chef/opsk.yaml
310
- - templates/chef/roles.erb
311
- - templates/chef/run.sh
312
- - templates/chef/solo.rb
313
- - templates/chef/ubuntu_docker.erb
314
- - templates/chef/vagrant.erb
315
276
  - templates/clean.yaml
316
- - templates/fig.yml.erb
317
277
  - templates/gitignore
318
278
  - templates/hiera.yaml
319
279
  - templates/hiera_vagrant.yaml
@@ -338,7 +298,6 @@ files:
338
298
  - templates/ruby-gemset.erb
339
299
  - templates/ruby-version.erb
340
300
  - templates/spec.erb
341
- - test/chef_package_test.rb
342
301
  - test/git_test.rb
343
302
  - test/puppet_package_test.rb
344
303
  - test/test_helper.rb
@@ -361,12 +320,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
320
  version: '0'
362
321
  requirements: []
363
322
  rubyforge_project:
364
- rubygems_version: 2.2.2
323
+ rubygems_version: 2.4.8
365
324
  signing_key:
366
325
  specification_version: 4
367
- summary: A generator for ops projects that include vagrant puppet and fpm
326
+ summary: Managing services lifecycle from Development to production using Vagrant
327
+ and Puppet
368
328
  test_files:
369
- - test/chef_package_test.rb
370
329
  - test/git_test.rb
371
330
  - test/puppet_package_test.rb
372
331
  - test/test_helper.rb
@@ -1,29 +0,0 @@
1
- module Opsk
2
- class Dockerize < Thor::Group
3
- include Thorable, Thor::Actions
4
-
5
- argument :from, :type => :string, :desc => 'Which source image to use'
6
- argument :os_type, :type=> :string, :desc => 'Flavor of container Ubuntu/Centos'
7
-
8
-
9
- desc 'Creates a docker image using the current opsk sandbox'
10
-
11
- def validate
12
- check_root
13
- end
14
-
15
-
16
- def create_dockerfiles
17
- empty_directory('dockerfiles')
18
- machines.each {|m|
19
- empty_directory("dockerfiles/#{m}/")
20
- template("templates/#{type_of}/docker/#{os_type}_docker.erb", "dockerfiles/#{m}/Dockerfile")
21
- }
22
- end
23
-
24
- def fig
25
- template("templates/fig.yml.erb", 'fig.yml')
26
- end
27
-
28
- end
29
- end
@@ -1,85 +0,0 @@
1
- module Opsk
2
- class GenerateChef < Thor::Group
3
- include Thorable, Thor::Actions
4
-
5
- argument :name, :type => :string, :desc => 'project name'
6
- argument :box, :type => :string, :desc => 'Vagrant box type'
7
- class_option :box_url, :type=> :string, :desc => 'vagrant box url'
8
- class_option :os_type, :type=> :string, :desc => 'Operating system type (bsd/linux)'
9
- class_option :bench_enable, :type=> :boolean, :desc => 'Control if to enable benchmarking support'
10
-
11
- desc 'Generate a Vagrant, Chef librarian and fpm project'
12
-
13
- def path
14
- "#{name}-sandbox"
15
- end
16
-
17
- def create_vagrant_file
18
- empty_directory(path)
19
- template('templates/chef/vagrant.erb', "#{path}/Vagrantfile")
20
- end
21
-
22
- def create_gemfile
23
- template('templates/chef/Gemfile.erb', "#{path}/Gemfile")
24
- end
25
-
26
- def create_rakefile
27
- template('templates/chef/Rakefile.erb', "#{path}/Rakefile")
28
- end
29
-
30
- def create_version
31
- template('templates/chef/opsk.yaml', "#{path}/opsk.yaml")
32
- end
33
-
34
- def create_rvmrc
35
- remove_file("#{path}/.rvmrc")
36
- template('templates/ruby-gemset.erb', "#{path}/.ruby-gemset")
37
- template('templates/ruby-version.erb', "#{path}/.ruby-version")
38
- end
39
-
40
- def create_environment
41
- empty_directory("#{path}/environments")
42
- copy_file('templates/chef/environments/dev.rb', "#{path}/environments/dev.rb")
43
- end
44
-
45
- def create_chef_base
46
- empty_directory("#{path}/static-cookbooks/")
47
- copy_file('templates/chef/Cheffile', "#{path}/Cheffile")
48
- empty_directory("#{path}/roles/")
49
- template('templates/chef/roles.erb', "#{path}/roles/#{name}.rb")
50
- template('templates/chef/dna.json.erb', "#{path}/dna.json")
51
- copy_file('templates/chef/run.sh', "#{path}/run.sh")
52
- copy_file('templates/chef/solo.rb', "#{path}/solo.rb")
53
- copy_file('templates/chef/boot.sh', "#{path}/boot.sh")
54
- chmod("#{path}/run.sh", 0755)
55
- chmod("#{path}/boot.sh", 0755)
56
- end
57
-
58
- def readme
59
- template('templates/README.erb', "#{path}/README.md")
60
- copy_file('templates/LICENSE-2.0.txt',"#{path}/LICENSE-2.0.txt")
61
- end
62
-
63
- def travis
64
- template('templates/parent/travis.erb', "#{path}/.travis.yml")
65
- end
66
-
67
- def server_spec
68
- empty_directory("#{path}/spec")
69
- template('templates/parent/spec/spec_helper.erb', "#{path}/spec/spec_helper.rb")
70
- directory('templates/parent/spec/default', "#{path}/spec/default")
71
- end
72
-
73
- def git
74
- if(!File.exists?("#{path}/.git"))
75
- copy_file('templates/gitignore', "#{path}/.gitignore")
76
- inside(path) do
77
- run('git init .')
78
- run('git add -A')
79
- run("git commit -m 'initial sandbox import'")
80
- end
81
- end
82
- end
83
-
84
- end
85
- end