opskeleton 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,16 +1,19 @@
1
- Intro
2
- ==========
3
1
 
4
- Opskelaton is an opinionated bootstrap tool for local sandboxes project that uses/creates:
2
+ <img src="https://raw.github.com/narkisr/vagrant-sketching-board/master/images/opskeleton.png" width='100%' hight='100%' alt="" />
5
3
 
6
- * A vagrant file matching OS
7
- * RVM (creates an .rvmrc with a matching gemset)
8
- * bundler (with dependencies defined)
9
- * librarian-puppet for puppet module depdency managment
10
- * basic folder strucuture (
11
- * static-module for currently developed modules and modules for imported ones
12
- * run.sh (for simple running of puppet within the sandbox)
13
- * License and README
4
+ # Intro
5
+
6
+ Opskelaton is an opinionated bootstrap tool for local Sandbox projects.
7
+
8
+ Opsk aims to solve the following common issues:
9
+ * Devops develop Puppet modules on master machines which results with 'It works on my (machine) master' approach.
10
+ * Implicit/Missing dependencies, like ruby version used, operating system, gems, third party puppet module
11
+ * Manual steps in setting up puppet modules and local sandboxes (like installing third party code).
12
+ * Non standard layout, projects missing README and LICENSE files, no clear seperation between developed and depdendant code.
13
+ * No clear development guidelines, for example extracting general modules and exporting them.
14
+
15
+
16
+ See it in action [here](https://www.youtube.com/watch?v=LNlHC54Ej8c).
14
17
 
15
18
  Usage
16
19
  =========
@@ -18,3 +21,27 @@ Usage
18
21
  ```bash
19
22
  $ opsk generate name box-type
20
23
  ```
24
+
25
+
26
+ ## Layout
27
+
28
+ Opskelaton creates the complete folder structure fine tuned to match best practices:
29
+
30
+ Folder layout:
31
+
32
+ <img src="https://raw.github.com/narkisr/vagrant-sketching-board/master/images/opsk-folders.png" width='30%' hight='50%' alt="" />
33
+
34
+
35
+ ## Lifecycle
36
+
37
+ Opskelaton defines a simple module life cycle:
38
+
39
+ 1. Internal non reusable modules (usually specific to a client site) go under static-modules
40
+ 2. If we create a general reusable module which is ready for prime time we pull out to a new git repository.
41
+ 3. The extracted module is added back as a third party (using [librarian-puppet](https://github.com/rodjek/librarian-puppet) module which reside under module folder.
42
+
43
+ Life cycle scheme:
44
+
45
+ <img src="https://raw.github.com/narkisr/vagrant-sketching-board/master/images/module-lifecycle-black.png" width='30%' hight='50%' alt="" />
46
+
47
+
data/TODOS ADDED
@@ -0,0 +1,3 @@
1
+ * Add testing support, both smoke and rspec
2
+ * Add travis.ci support
3
+ * Test thor tasks using http://tinyurl.com/a7x4j8r
data/bin/opsk CHANGED
@@ -1,10 +1,65 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $:.push 'lib'
3
4
  require 'rubygems'
4
5
  require 'thor'
5
6
  require 'thor/group'
7
+ require 'opskeleton/version'
6
8
 
7
9
  module Opsk
10
+ class Package < Thor::Group
11
+ include Thor::Actions
12
+
13
+ def self.source_root
14
+ # during dev time
15
+ if(File.dirname(__FILE__) == './bin')
16
+ File.dirname('.')
17
+ else
18
+ "#{File.dirname(__FILE__)}/../"
19
+ end
20
+ end
21
+
22
+ def create_pkg
23
+ empty_directory('pkg')
24
+ end
25
+
26
+ def package
27
+ name = File.basename(Dir.getwd)
28
+ ignored = IO.readlines('.gitignore').map(&:chomp)
29
+ ignored.delete('modules')
30
+ excludes = ignored.map{|f| "'#{f}'"}.join(" --exclude=") << ' --exclude-backups --exclude-vcs --exclude=pkg'
31
+ run("tar --exclude=#{excludes} -czf pkg/#{name}.tar.gz ../#{name} > /dev/null", :verbose => false)
32
+ end
33
+
34
+ end
35
+
36
+
37
+ class Specgen < Thor::Group
38
+ include Thor::Actions
39
+
40
+ argument :name, :type => :string, :desc => "static module name"
41
+
42
+ def self.source_root
43
+ # during dev time
44
+ if(File.dirname(__FILE__) == './bin')
45
+ File.dirname('.')
46
+ else
47
+ "#{File.dirname(__FILE__)}/../"
48
+ end
49
+ end
50
+
51
+ def create_spec_folders
52
+ %w(classes defines functions hosts).each do |t|
53
+ empty_directory("static-modules/#{name}/spec/#{t}")
54
+ end
55
+ end
56
+
57
+ def create_class_spec
58
+ template('templates/spec.erb', "static-modules/#{name}/spec/classes/")
59
+ end
60
+
61
+ end
62
+
8
63
  class Generate < Thor::Group
9
64
  include Thor::Actions
10
65
 
@@ -32,17 +87,14 @@ module Opsk
32
87
  template('templates/vagrant.erb', "#{path}/Vagrantfile")
33
88
  end
34
89
 
35
- def git
36
- copy_file('templates/gitignore', "#{path}/.gitignore")
37
- inside(path) do
38
- run('git init .')
39
- end
40
- end
41
-
42
90
  def create_gemfile
43
91
  copy_file('templates/gemfile', "#{path}/Gemfile")
44
92
  end
45
93
 
94
+ def create_rakefile
95
+ copy_file('templates/Rakefile', "#{path}/Rakefile")
96
+ end
97
+
46
98
  def create_rvmrc
47
99
  template('templates/rvmrc.erb', "#{path}/.rvmrc")
48
100
  end
@@ -70,6 +122,15 @@ module Opsk
70
122
  template('templates/README.erb', "#{path}/README.md")
71
123
  copy_file('templates/LICENSE-2.0.txt',"#{path}/LICENSE-2.0.txt")
72
124
  end
125
+
126
+ def git
127
+ copy_file('templates/gitignore', "#{path}/.gitignore")
128
+ inside(path) do
129
+ run('git init .')
130
+ run('git add -A')
131
+ run("git commit -m 'initial sandbox import'")
132
+ end
133
+ end
73
134
  end
74
135
  end
75
136
 
@@ -77,6 +138,13 @@ end
77
138
  module Opsk
78
139
  class Root < Thor
79
140
  register Opsk::Generate, 'generate', 'generate [name] [box]', 'generates opskelaton project structure'
141
+ register Opsk::Specgen, 'specgen', 'specgen [module]', 'generates rspec-puppet for static-modules/module'
142
+ register Opsk::Package, 'package', 'package', 'packages current module for celestial'
143
+
144
+ desc 'version', 'print opsk version'
145
+ def version
146
+ puts Opskeleton::VERSION
147
+ end
80
148
  end
81
149
  end
82
150
 
@@ -1,3 +1,3 @@
1
1
  module Opskeleton
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,9 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+ require 'puppet-lint/tasks/puppet-lint'
4
+
5
+ RSpec::Core::RakeTask.new(:spec) do |t|
6
+ t.pattern = 'spec/*/*_spec.rb'
7
+ end
8
+
9
+ task :default => [:spec, :lint]
data/templates/gemfile CHANGED
@@ -6,3 +6,5 @@ gem 'puppet'
6
6
  gem 'puppet-lint'
7
7
  gem 'librarian-puppet'
8
8
  gem 'rake'
9
+ gem 'rspec-puppet'
10
+ gem 'opskeleton'
@@ -1,11 +1,8 @@
1
1
  forge "http://forge.puppetlabs.com"
2
2
 
3
3
  mod 'puppetlabs/stdlib'
4
-
5
-
6
4
  <% if(box.include?('ubuntu')) %>
7
5
  mod 'puppetlabs/apt'
8
6
  <% end %>
9
-
10
7
  mod 'editfile',
11
8
  :git => 'git://github.com/mstrauss/puppet-editfile.git'
data/templates/run.sh CHANGED
@@ -1 +1 @@
1
- puppet apply --modulepath=modules:static-modules manifests/default.pp $@
1
+ puppet apply --modulepath=modules:static-modules manifests/default.pp --hiera_config hiera.yaml $@
@@ -0,0 +1,4 @@
1
+ describe 'init', :type => :class do
2
+
3
+ end
4
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opskeleton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-18 00:00:00.000000000 Z
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -41,12 +41,14 @@ files:
41
41
  - Gemfile.lock
42
42
  - README.md
43
43
  - Rakefile
44
+ - TODOS
44
45
  - bin/opsk
45
46
  - lib/opskeleton.rb
46
47
  - lib/opskeleton/version.rb
47
48
  - opskeleton.gemspec
48
49
  - templates/LICENSE-2.0.txt
49
50
  - templates/README.erb
51
+ - templates/Rakefile
50
52
  - templates/clean.yaml
51
53
  - templates/default.erb
52
54
  - templates/gemfile
@@ -55,6 +57,7 @@ files:
55
57
  - templates/puppetfile.erb
56
58
  - templates/run.sh
57
59
  - templates/rvmrc.erb
60
+ - templates/spec.erb
58
61
  - templates/vagrant.erb
59
62
  homepage: https://github.com/narkisr/opskeleton
60
63
  licenses: []