opskeleton 0.0.5 → 0.1.0
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.
- data/Gemfile.lock +3 -1
- data/Rakefile +7 -0
- data/bin/opsk +2 -109
- data/lib/opskeleton/generate.rb +68 -0
- data/lib/opskeleton/package.rb +46 -0
- data/lib/opskeleton/thorable.rb +14 -0
- data/lib/opskeleton/version.rb +1 -1
- data/lib/opskeleton.rb +8 -4
- data/templates/opsk.yml +3 -0
- data/templates/scripts/lookup.sh +4 -1
- data/test/generate_test.rb +22 -0
- data/test/package_test.rb +30 -0
- data/test/test_helper.rb +14 -0
- metadata +12 -2
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/bin/opsk
CHANGED
@@ -4,42 +4,9 @@ $:.push 'lib'
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'thor'
|
6
6
|
require 'thor/group'
|
7
|
-
require 'opskeleton
|
8
|
-
|
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 create_scripts
|
27
|
-
empty_directory('scripts')
|
28
|
-
template('templates/scripts/lookup.sh', "scripts/lookup.sh")
|
29
|
-
template('templates/scripts/run.sh', "scripts/run.sh")
|
30
|
-
end
|
31
|
-
|
32
|
-
def package
|
33
|
-
name = File.basename(Dir.getwd)
|
34
|
-
ignored = IO.readlines('.gitignore').map(&:chomp)
|
35
|
-
ignored.delete('modules')
|
36
|
-
excludes = ignored.map{|f| "'#{f}'"}.join(" --exclude=") << ' --exclude-backups --exclude-vcs --exclude=pkg'
|
37
|
-
run("tar --exclude=#{excludes} -czf pkg/#{name}.tar.gz ../#{name} > /dev/null", :verbose => false)
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
7
|
+
require 'opskeleton'
|
42
8
|
|
9
|
+
module Opsk
|
43
10
|
class Specgen < Thor::Group
|
44
11
|
include Thor::Actions
|
45
12
|
|
@@ -63,80 +30,6 @@ module Opsk
|
|
63
30
|
def create_class_spec
|
64
31
|
template('templates/spec.erb', "static-modules/#{name}/spec/classes/")
|
65
32
|
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
class Generate < Thor::Group
|
70
|
-
include Thor::Actions
|
71
|
-
|
72
|
-
argument :name, :type => :string, :desc => "project name"
|
73
|
-
argument :box, :type => :string, :desc => "Vagrant box type"
|
74
|
-
|
75
|
-
desc "Generate a Vagrant, Puppet librarian and fpm project"
|
76
|
-
|
77
|
-
|
78
|
-
def self.source_root
|
79
|
-
# during dev time
|
80
|
-
if(File.dirname(__FILE__) == './bin')
|
81
|
-
File.dirname('.')
|
82
|
-
else
|
83
|
-
"#{File.dirname(__FILE__)}/../"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def path
|
88
|
-
"#{name}-sandbox"
|
89
|
-
end
|
90
|
-
|
91
|
-
def create_vagrant_file
|
92
|
-
empty_directory(path)
|
93
|
-
template('templates/vagrant.erb', "#{path}/Vagrantfile")
|
94
|
-
end
|
95
|
-
|
96
|
-
def create_gemfile
|
97
|
-
copy_file('templates/gemfile', "#{path}/Gemfile")
|
98
|
-
end
|
99
|
-
|
100
|
-
def create_rakefile
|
101
|
-
copy_file('templates/Rakefile', "#{path}/Rakefile")
|
102
|
-
end
|
103
|
-
|
104
|
-
def create_rvmrc
|
105
|
-
template('templates/rvmrc.erb', "#{path}/.rvmrc")
|
106
|
-
end
|
107
|
-
|
108
|
-
def create_puppet_base
|
109
|
-
empty_directory("#{path}/static-modules/")
|
110
|
-
empty_directory("#{path}/manifests/")
|
111
|
-
template('templates/puppetfile.erb', "#{path}/Puppetfile")
|
112
|
-
template('templates/default.erb', "#{path}/manifests/default.pp")
|
113
|
-
copy_file('templates/run.sh', "#{path}/run.sh")
|
114
|
-
chmod("#{path}/run.sh", 0755)
|
115
|
-
end
|
116
|
-
|
117
|
-
def create_heira
|
118
|
-
hieradata = "#{path}/hieradata/"
|
119
|
-
empty_directory(hieradata)
|
120
|
-
%w(common virtualbox physical).each do |env|
|
121
|
-
copy_file('templates/clean.yaml', "#{hieradata}/#{env}.yaml")
|
122
|
-
end
|
123
|
-
|
124
|
-
copy_file('templates/hiera.yaml', "#{path}/hiera.yaml")
|
125
|
-
end
|
126
|
-
|
127
|
-
def readme
|
128
|
-
template('templates/README.erb', "#{path}/README.md")
|
129
|
-
copy_file('templates/LICENSE-2.0.txt',"#{path}/LICENSE-2.0.txt")
|
130
|
-
end
|
131
|
-
|
132
|
-
def git
|
133
|
-
copy_file('templates/gitignore', "#{path}/.gitignore")
|
134
|
-
inside(path) do
|
135
|
-
run('git init .')
|
136
|
-
run('git add -A')
|
137
|
-
run("git commit -m 'initial sandbox import'")
|
138
|
-
end
|
139
|
-
end
|
140
33
|
end
|
141
34
|
end
|
142
35
|
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Opsk
|
2
|
+
class Generate < 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
|
+
|
8
|
+
desc "Generate a Vagrant, Puppet librarian and fpm project"
|
9
|
+
|
10
|
+
def path
|
11
|
+
"#{name}-sandbox"
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_vagrant_file
|
15
|
+
empty_directory(path)
|
16
|
+
template('templates/vagrant.erb', "#{path}/Vagrantfile")
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_gemfile
|
20
|
+
copy_file('templates/gemfile', "#{path}/Gemfile")
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_rakefile
|
24
|
+
copy_file('templates/Rakefile', "#{path}/Rakefile")
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_version
|
28
|
+
template('templates/opsk.yml', "#{path}/opsk.yml")
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_rvmrc
|
32
|
+
template('templates/rvmrc.erb', "#{path}/.rvmrc")
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_puppet_base
|
36
|
+
empty_directory("#{path}/static-modules/")
|
37
|
+
empty_directory("#{path}/manifests/")
|
38
|
+
template('templates/puppetfile.erb', "#{path}/Puppetfile")
|
39
|
+
template('templates/default.erb', "#{path}/manifests/default.pp")
|
40
|
+
copy_file('templates/run.sh', "#{path}/run.sh")
|
41
|
+
chmod("#{path}/run.sh", 0755)
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_heira
|
45
|
+
hieradata = "#{path}/hieradata/"
|
46
|
+
empty_directory(hieradata)
|
47
|
+
%w(common virtualbox physical).each do |env|
|
48
|
+
copy_file('templates/clean.yaml', "#{hieradata}/#{env}.yaml")
|
49
|
+
end
|
50
|
+
|
51
|
+
copy_file('templates/hiera.yaml', "#{path}/hiera.yaml")
|
52
|
+
end
|
53
|
+
|
54
|
+
def readme
|
55
|
+
template('templates/README.erb', "#{path}/README.md")
|
56
|
+
copy_file('templates/LICENSE-2.0.txt',"#{path}/LICENSE-2.0.txt")
|
57
|
+
end
|
58
|
+
|
59
|
+
def git
|
60
|
+
copy_file('templates/gitignore', "#{path}/.gitignore")
|
61
|
+
inside(path) do
|
62
|
+
run('git init .')
|
63
|
+
run('git add -A')
|
64
|
+
run("git commit -m 'initial sandbox import'")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Opsk
|
2
|
+
class Package < Thor::Group
|
3
|
+
include Thorable, Thor::Actions
|
4
|
+
|
5
|
+
def meta
|
6
|
+
OpenStruct.new(YAML.load_file('opsk.yml'))
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
File.basename(Dir.getwd)
|
11
|
+
end
|
12
|
+
|
13
|
+
def artifact
|
14
|
+
"#{name}-#{meta.version}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_build
|
18
|
+
empty_directory(artifact)
|
19
|
+
path = File.basename(Dir.getwd)
|
20
|
+
directory path , artifact
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_pkg
|
24
|
+
empty_directory('pkg')
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_scripts
|
28
|
+
empty_directory('scripts')
|
29
|
+
%w(lookup.sh run.sh).each do |s|
|
30
|
+
template("templates/scripts/#{s}", "scripts/#{s}")
|
31
|
+
chmod("scripts/#{s}", 0755)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
def package
|
37
|
+
ignored = IO.readlines('.gitignore').map(&:chomp)
|
38
|
+
ignored.delete('modules')
|
39
|
+
excludes = ignored.map{|f| "'#{f}'"}.join(" --exclude=") << ' --exclude-backups --exclude-vcs --exclude=pkg'
|
40
|
+
run("tar --exclude=#{excludes} -czf pkg/#{artifact}.tar.gz #{artifact} > /dev/null", :verbose => false)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
data/lib/opskeleton/version.rb
CHANGED
data/lib/opskeleton.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require 'opskeleton/version'
|
2
|
+
require 'thor'
|
3
|
+
require 'thor/group'
|
4
|
+
require 'yaml'
|
5
|
+
require 'ostruct'
|
6
|
+
require 'opskeleton/thorable'
|
7
|
+
require 'opskeleton/package'
|
8
|
+
require 'opskeleton/generate'
|
2
9
|
|
3
|
-
module Opskeleton
|
4
|
-
# Your code goes here...
|
5
|
-
end
|
data/templates/opsk.yml
ADDED
data/templates/scripts/lookup.sh
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require_relative 'test_helper'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
class GenerateTest< MiniTest::Unit::TestCase
|
8
|
+
include FileUtils
|
9
|
+
|
10
|
+
def setup
|
11
|
+
Opsk::Root.start ['generate', 'foo', 'bar']
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
rm_rf 'foo-sandbox'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_version
|
19
|
+
assert File.exists?('foo-sandbox/opsk.yml')
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require_relative 'test_helper'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
class PackageTest < MiniTest::Unit::TestCase
|
8
|
+
include FileUtils
|
9
|
+
|
10
|
+
def setup
|
11
|
+
Opsk::Root.start ['generate', 'foo', 'bar']
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def with_cwd dir
|
16
|
+
Dir.chdir dir do
|
17
|
+
yield
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_build
|
22
|
+
with_cwd 'foo-sandbox' do
|
23
|
+
Opsk::Root.start ['package']
|
24
|
+
end
|
25
|
+
assert File.exists?('foo-sandbox/foo-sandbox-0.0.1/Puppetfile')
|
26
|
+
|
27
|
+
assert File.exists?('foo-sandbox/pkg/foo-sandbox-0.0.1.tar.gz')
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'thor'
|
3
|
+
require 'thor/group'
|
4
|
+
require 'opskeleton'
|
5
|
+
|
6
|
+
|
7
|
+
module Opsk
|
8
|
+
class Root < Thor
|
9
|
+
register Opsk::Generate, 'generate', 'generate [name] [box]', 'generates opskelaton project structure'
|
10
|
+
register Opsk::Package, 'package', 'package', 'packages current module for celestial'
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
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
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -44,6 +44,9 @@ files:
|
|
44
44
|
- TODOS
|
45
45
|
- bin/opsk
|
46
46
|
- lib/opskeleton.rb
|
47
|
+
- lib/opskeleton/generate.rb
|
48
|
+
- lib/opskeleton/package.rb
|
49
|
+
- lib/opskeleton/thorable.rb
|
47
50
|
- lib/opskeleton/version.rb
|
48
51
|
- opskeleton.gemspec
|
49
52
|
- templates/LICENSE-2.0.txt
|
@@ -54,6 +57,7 @@ files:
|
|
54
57
|
- templates/gemfile
|
55
58
|
- templates/gitignore
|
56
59
|
- templates/hiera.yaml
|
60
|
+
- templates/opsk.yml
|
57
61
|
- templates/puppetfile.erb
|
58
62
|
- templates/run.sh
|
59
63
|
- templates/rvmrc.erb
|
@@ -61,6 +65,9 @@ files:
|
|
61
65
|
- templates/scripts/run.sh
|
62
66
|
- templates/spec.erb
|
63
67
|
- templates/vagrant.erb
|
68
|
+
- test/generate_test.rb
|
69
|
+
- test/package_test.rb
|
70
|
+
- test/test_helper.rb
|
64
71
|
homepage: https://github.com/narkisr/opskeleton
|
65
72
|
licenses: []
|
66
73
|
post_install_message:
|
@@ -85,4 +92,7 @@ rubygems_version: 1.8.24
|
|
85
92
|
signing_key:
|
86
93
|
specification_version: 3
|
87
94
|
summary: A generator for ops projects that include vagrant puppet and fpm
|
88
|
-
test_files:
|
95
|
+
test_files:
|
96
|
+
- test/generate_test.rb
|
97
|
+
- test/package_test.rb
|
98
|
+
- test/test_helper.rb
|