opskeleton 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +43 -6
- data/Guardfile +12 -0
- data/README.md +10 -50
- data/Rakefile +20 -0
- data/bin/opsk +1 -0
- data/docs/doc-docinfo.html +2 -0
- data/docs/doc.adoc +434 -0
- data/lib/opskeleton/commit.rb +43 -21
- data/lib/opskeleton/push.rb +13 -9
- data/lib/opskeleton/uncommited.rb +64 -0
- data/lib/opskeleton/version.rb +1 -1
- data/lib/opskeleton.rb +1 -0
- data/opskeleton.gemspec +5 -0
- metadata +76 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db0cc5b42bae8a325f0dc39601081e56e4ffe78d
|
4
|
+
data.tar.gz: acd80a01463506ae34c11de387f612701d42b68b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e1fcb1c227fc69cc80522195605ec8e1f8f8a44ee51aba55bb29a81c974b6be69fa6357d67cd935564819fff58b05c28ec7365d4600b6d42fae90f9ad7105c
|
7
|
+
data.tar.gz: 0061f5575d2a0862f287d61a0072068ba2eb0b54a41f9cfec838f97e82fc5853f4ef6e7980253b264cd9f043f2e0fdfeb24285b38f219ff4864b97f57aec179e
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
opskeleton (0.
|
4
|
+
opskeleton (0.9.3)
|
5
5
|
aws-sdk (~> 2)
|
6
6
|
bintray_deploy
|
7
7
|
git
|
@@ -21,6 +21,7 @@ GEM
|
|
21
21
|
minitest (~> 5.1)
|
22
22
|
thread_safe (~> 0.3, >= 0.3.4)
|
23
23
|
tzinfo (~> 1.1)
|
24
|
+
asciidoctor (1.5.2)
|
24
25
|
aws-sdk (2.1.3)
|
25
26
|
aws-sdk-resources (= 2.1.3)
|
26
27
|
aws-sdk-core (2.1.3)
|
@@ -77,7 +78,24 @@ GEM
|
|
77
78
|
ffi (1.9.10)
|
78
79
|
ffi-yajl (2.2.0)
|
79
80
|
libyajl2 (~> 1.2)
|
81
|
+
formatador (0.2.5)
|
80
82
|
git (1.2.9.1)
|
83
|
+
guard (2.12.8)
|
84
|
+
formatador (>= 0.2.4)
|
85
|
+
listen (>= 2.7, <= 4.0)
|
86
|
+
lumberjack (~> 1.0)
|
87
|
+
nenv (~> 0.1)
|
88
|
+
notiffany (~> 0.0)
|
89
|
+
pry (>= 0.9.12)
|
90
|
+
shellany (~> 0.0)
|
91
|
+
thor (>= 0.18.1)
|
92
|
+
guard-compat (1.2.1)
|
93
|
+
guard-minitest (2.4.4)
|
94
|
+
guard-compat (~> 1.2)
|
95
|
+
minitest (>= 3.0)
|
96
|
+
guard-shell (0.7.1)
|
97
|
+
guard (>= 2.0.0)
|
98
|
+
guard-compat (~> 1.0)
|
81
99
|
hashie (2.1.2)
|
82
100
|
her (0.7.6)
|
83
101
|
activemodel (>= 3.0.0, <= 4.3.0)
|
@@ -102,6 +120,10 @@ GEM
|
|
102
120
|
librarianp (0.6.3)
|
103
121
|
thor (~> 0.15)
|
104
122
|
libyajl2 (1.2.0)
|
123
|
+
listen (3.0.2)
|
124
|
+
rb-fsevent (>= 0.9.3)
|
125
|
+
rb-inotify (>= 0.9)
|
126
|
+
lumberjack (1.0.9)
|
105
127
|
metaclass (0.0.4)
|
106
128
|
method_source (0.8.2)
|
107
129
|
mime-types (2.6.1)
|
@@ -116,6 +138,7 @@ GEM
|
|
116
138
|
metaclass (~> 0.0.1)
|
117
139
|
multi_json (1.11.2)
|
118
140
|
multipart-post (2.0.0)
|
141
|
+
nenv (0.2.0)
|
119
142
|
net-scp (1.2.1)
|
120
143
|
net-ssh (>= 2.6.5)
|
121
144
|
net-ssh (2.9.2)
|
@@ -126,6 +149,9 @@ GEM
|
|
126
149
|
net-ssh-gateway (>= 1.2.0)
|
127
150
|
net-telnet (0.1.1)
|
128
151
|
netrc (0.10.3)
|
152
|
+
notiffany (0.0.6)
|
153
|
+
nenv (~> 0.1)
|
154
|
+
shellany (~> 0.0)
|
129
155
|
ohai (8.5.0)
|
130
156
|
ffi (~> 1.9)
|
131
157
|
ffi-yajl (~> 2.2)
|
@@ -139,6 +165,7 @@ GEM
|
|
139
165
|
systemu (~> 2.6.4)
|
140
166
|
wmi-lite (~> 1.0)
|
141
167
|
plist (3.1.0)
|
168
|
+
posix-spawn (0.3.11)
|
142
169
|
pry (0.10.1)
|
143
170
|
coderay (~> 1.1.0)
|
144
171
|
method_source (~> 0.8.1)
|
@@ -158,8 +185,14 @@ GEM
|
|
158
185
|
puppet-syntax
|
159
186
|
rake
|
160
187
|
rspec-puppet
|
188
|
+
pygments.rb (0.6.3)
|
189
|
+
posix-spawn (~> 0.3.6)
|
190
|
+
yajl-ruby (~> 1.2.0)
|
161
191
|
rack (1.6.4)
|
162
192
|
rake (10.4.2)
|
193
|
+
rb-fsevent (0.9.5)
|
194
|
+
rb-inotify (0.9.5)
|
195
|
+
ffi (>= 0.5.0)
|
163
196
|
rest-client (1.8.0)
|
164
197
|
http-cookie (>= 1.0.2, < 2.0)
|
165
198
|
mime-types (>= 1.16, < 3.0)
|
@@ -192,10 +225,11 @@ GEM
|
|
192
225
|
rspec-its
|
193
226
|
specinfra (~> 2.35)
|
194
227
|
sfl (2.2)
|
228
|
+
shellany (0.0.1)
|
195
229
|
slop (3.6.0)
|
196
|
-
specinfra (2.37.
|
230
|
+
specinfra (2.37.1)
|
197
231
|
net-scp
|
198
|
-
net-ssh
|
232
|
+
net-ssh (~> 2.7)
|
199
233
|
net-telnet
|
200
234
|
sfl
|
201
235
|
syslog-logger (1.6.8)
|
@@ -209,18 +243,21 @@ GEM
|
|
209
243
|
unf_ext (0.0.7.1)
|
210
244
|
uuidtools (2.1.5)
|
211
245
|
wmi-lite (1.0.0)
|
246
|
+
yajl-ruby (1.2.1)
|
212
247
|
|
213
248
|
PLATFORMS
|
214
249
|
ruby
|
215
250
|
|
216
251
|
DEPENDENCIES
|
252
|
+
asciidoctor
|
217
253
|
chef
|
254
|
+
guard
|
255
|
+
guard-minitest
|
256
|
+
guard-shell
|
218
257
|
librarian-puppet (= 2.1.0)
|
219
258
|
opskeleton!
|
220
259
|
pry
|
221
260
|
puppet (= 3.7.5)
|
222
261
|
puppetlabs_spec_helper (>= 0.1.0)
|
262
|
+
pygments.rb
|
223
263
|
rspec-puppet
|
224
|
-
|
225
|
-
BUNDLED WITH
|
226
|
-
1.10.5
|
data/Guardfile
ADDED
data/README.md
CHANGED
@@ -2,59 +2,19 @@
|
|
2
2
|
|
3
3
|
# Intro
|
4
4
|
|
5
|
-
Opskelaton is an opinionated bootstrap tool for local Sandbox projects
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
* No continues build, linting and testing, provisioning code is second class citizen.
|
5
|
+
Opskelaton is an opinionated bootstrap tool for local Sandbox projects, it aims to solve the following common issues:
|
6
|
+
|
7
|
+
* Developing Puppet/Chef modules/cookbooks on master machines which results with 'It works on my master/server' approach.
|
8
|
+
* Large monolithic Puppet/Chef code bases, code isn't modular or reusable.
|
9
|
+
* Implicit/Missing dependencies including: Ruby version, OS, gems, modules/cookbooks.
|
10
|
+
* Manual steps in setting up and maintaining such projects.
|
11
|
+
* Non standard layout, projects missing README and LICENSE files, no clear separation between developed and dependant code.
|
12
|
+
* Lacking development guidelines (for example extracting general modules and exporting them).
|
13
|
+
* No continues build, linting and testing, provisioning code is second class citizen.
|
15
14
|
|
16
15
|
Opskeleton comes to solve these issues by introducing a decentralized development work flow with pre-defined layout, packaging and dependency management.
|
17
16
|
|
18
|
-
[
|
19
|
-
|
20
|
-
|
21
|
-
# Usage
|
22
|
-
|
23
|
-
## Installation
|
24
|
-
|
25
|
-
Perquisites (on Ubuntu):
|
26
|
-
|
27
|
-
* Vagrant 1.7.x
|
28
|
-
* RVM
|
29
|
-
* Ruby 2.1.x
|
30
|
-
|
31
|
-
```bash
|
32
|
-
$ rvm use system
|
33
|
-
$ sudo gem install opskeleton
|
34
|
-
```
|
35
|
-
|
36
|
-
Now Follow either [Chef](docs/chef.md) or [Puppet](docs/puppet.md).
|
37
|
-
|
38
|
-
# Boxes
|
39
|
-
Opskeleton recommends the use of [box-cutter](https://github.com/box-cutter) in order to create Vagrant boxes in a consistent manner (as no free hosting solution currently exist):
|
40
|
-
```bash
|
41
|
-
# make sure to have latest packer
|
42
|
-
$ packer version
|
43
|
-
Packer v0.6.0
|
44
|
-
$ git clone git@github.com:box-cutter/ubuntu-vm.git
|
45
|
-
$ cd ubuntu-vm
|
46
|
-
# Edit Makefile.local
|
47
|
-
$ cat Makefile.local
|
48
|
-
# Makefile.local
|
49
|
-
CM := puppet
|
50
|
-
CM_VERSION := 3.6.1
|
51
|
-
$ make virtualbox/ubuntu1404
|
52
|
-
```
|
53
|
-
A useful convention for Box names:
|
54
|
-
|
55
|
-
```bash
|
56
|
-
ubuntu-14.04_puppet-3.6.1 ([os]-[version]_[provisioner]-[version])
|
57
|
-
```
|
17
|
+
For [Usage](http://opskeleton.github.io/opskeleton/latest/) and more info please follow the [docs](http://opskeleton.github.io/opskeleton/latest/).
|
58
18
|
|
59
19
|
# Copyright and license
|
60
20
|
|
data/Rakefile
CHANGED
@@ -6,3 +6,23 @@ Rake::TestTask.new do |t|
|
|
6
6
|
t.pattern = "test/*_test.rb"
|
7
7
|
t.verbose = true
|
8
8
|
end
|
9
|
+
|
10
|
+
namespace :asciidoc do
|
11
|
+
|
12
|
+
desc 'create asciidoc'
|
13
|
+
task :create do
|
14
|
+
sh 'asciidoctor -a docinfo -a stylesheet! -o dist/latest/index.html docs/doc.adoc'
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'publish ascciidoc to gh-pages'
|
18
|
+
task :publish => [:create] do
|
19
|
+
sh 'ghp-import -m "Generate documentation" -b gh-pages dist/'
|
20
|
+
sh 'git push origin gh-pages'
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'clear asciidoc'
|
24
|
+
task :clear do
|
25
|
+
rm_rf 'dist'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/bin/opsk
CHANGED
@@ -21,6 +21,7 @@ module Opsk
|
|
21
21
|
register Opsk::Package, 'package', 'package', 'packages current module for celestial'
|
22
22
|
register Opsk::Dockerize, 'dockerize', 'dockerize [from] [os_type]', 'Creates a docker image from the current sandbox'
|
23
23
|
register Opsk::Commit, 'commit', 'commit [message]', 'commit each changed puppet module under modules folder'
|
24
|
+
register Opsk::Uncommited, 'uncommited', 'uncommited', 'list uncommited modules changes'
|
24
25
|
register Opsk::Push, 'push', 'push', 'push each changed puppet module under modules folder'
|
25
26
|
register Opsk::Clean, 'clean', 'clean', 'cleans up packaging products'
|
26
27
|
register Opsk::Bump, 'bump', 'bump', 'bumps up version (clearing old version also)'
|
data/docs/doc.adoc
ADDED
@@ -0,0 +1,434 @@
|
|
1
|
+
= Opskeleton
|
2
|
+
Ronen Narkis, <narkisr@gmail.com>
|
3
|
+
v0.9.2
|
4
|
+
:toc: left
|
5
|
+
:!numbered:
|
6
|
+
:idseparator: -
|
7
|
+
:idprefix:
|
8
|
+
:source-highlighter: pygments
|
9
|
+
:pygments-style: friendly
|
10
|
+
:sectlinks:
|
11
|
+
|
12
|
+
== Introduction
|
13
|
+
|
14
|
+
Opskelaton is an opinionated bootstrap tool for local Sandbox projects, it aims to solve the following common issues:
|
15
|
+
|
16
|
+
* Developing Puppet/Chef modules/cookbooks on master machines which results with 'It works on my master/server' approach.
|
17
|
+
* Large monolithic Puppet/Chef code bases, code isn't modular or reusable.
|
18
|
+
* Implicit/Missing dependencies including: Ruby version, OS, gems, modules/cookbooks.
|
19
|
+
* Manual steps in setting up and maintaining such projects.
|
20
|
+
* Non standard layout, projects missing README and LICENSE files, no clear separation between developed and dependant code.
|
21
|
+
* Lacking development guidelines (for example extracting general modules and exporting them).
|
22
|
+
* No continues build, linting and testing, provisioning code is second class citizen.
|
23
|
+
|
24
|
+
Opskeleton comes to solve these issues by introducing a decentralized development work flow with pre-defined layout, packaging and dependency management.
|
25
|
+
|
26
|
+
Currently Opskeleton supports Puppet and Chef, this guide is segmented to common functionality the respective separate sections for Puppet and Chef.
|
27
|
+
|
28
|
+
== Usage
|
29
|
+
|
30
|
+
=== Installation
|
31
|
+
|
32
|
+
Perquisites (on Ubuntu):
|
33
|
+
|
34
|
+
* Vagrant 1.7.x
|
35
|
+
* RVM
|
36
|
+
* Ruby 2.1.x
|
37
|
+
|
38
|
+
```bash
|
39
|
+
$ rvm use system
|
40
|
+
$ sudo gem install opskeleton
|
41
|
+
```
|
42
|
+
|
43
|
+
=== Boxes
|
44
|
+
|
45
|
+
Opskeleton recommends the use of https://github.com/box-cutter[box-cutter] in order to create Vagrant boxes in a consistent manner (as no free hosting solution currently exist):
|
46
|
+
```bash
|
47
|
+
# make sure to have latest packer
|
48
|
+
$ packer version
|
49
|
+
Packer v0.6.0
|
50
|
+
$ git clone git@github.com:box-cutter/ubuntu-vm.git
|
51
|
+
$ cd ubuntu-vm
|
52
|
+
# Edit Makefile.local
|
53
|
+
$ cat Makefile.local
|
54
|
+
# Makefile.local
|
55
|
+
CM := puppet
|
56
|
+
CM_VERSION := 3.6.1
|
57
|
+
$ make virtualbox/ubuntu1404
|
58
|
+
```
|
59
|
+
A useful convention for Box names:
|
60
|
+
|
61
|
+
```bash
|
62
|
+
ubuntu-14.04_puppet-3.6.1 ([os]-[version]_[provisioner]-[version])
|
63
|
+
```
|
64
|
+
|
65
|
+
== Puppet
|
66
|
+
|
67
|
+
=== Introduction
|
68
|
+
|
69
|
+
Opskeleton supports the creation of Puppet based projects supporting dependency management (using librarian-puppet), linting and testing.
|
70
|
+
|
71
|
+
|
72
|
+
=== Structure
|
73
|
+
|
74
|
+
==== Layout
|
75
|
+
|
76
|
+
Opskeleton generates the complete folder structure for projects:
|
77
|
+
|
78
|
+
image:https://raw.githubusercontent.com/opskeleton/opskeleton/master/img/puppet-layout.png[width=30%,hight=50%]
|
79
|
+
|
80
|
+
==== Lifecycle
|
81
|
+
|
82
|
+
Opskelaton defines a module life cycle:
|
83
|
+
|
84
|
+
1. Internal non reusable modules (usually specific to a client site) go under static-modules
|
85
|
+
2. If we create a general reusable module which is ready for prime time we pull out to a new git repository.
|
86
|
+
3. The extracted module is added back as a third party (using link:https://github.com/rodjek/librarian-puppet[librarian-puppet] module which resides under modules folder.
|
87
|
+
|
88
|
+
Life cycle scheme:
|
89
|
+
|
90
|
+
image:https://raw.githubusercontent.com/opskeleton/opskeleton/master/img/puppet-cycle.png[width='40%',hight='50%']
|
91
|
+
|
92
|
+
Creating new (static) modules is easy as:
|
93
|
+
|
94
|
+
```bash
|
95
|
+
$ opsk module foo
|
96
|
+
```
|
97
|
+
|
98
|
+
Each generated module will contain puppet-rspec with matching Rakefile.
|
99
|
+
|
100
|
+
==== Pushing changes
|
101
|
+
|
102
|
+
Making changes to third party modules is quite easy once librarian-puppet installed them locally (you can push only git based modules):
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
forge "https://forgeapi.puppetlabs.com"
|
106
|
+
|
107
|
+
mod 'puppetlabs/stdlib'
|
108
|
+
mod 'puppetlabs/apt'
|
109
|
+
|
110
|
+
mod 'strings/artifactory',
|
111
|
+
:git => 'git://github.com/pulling-strings/puppet-artifactory.git'
|
112
|
+
|
113
|
+
mod 'rip/module-data',
|
114
|
+
:git => 'git://github.com/ripienaar/puppet-module-data.git'
|
115
|
+
```
|
116
|
+
|
117
|
+
Its best practice to use git protocol (read only) which makes pushing changes from multiple modules a bit tedious, Opskeleton fixes that:
|
118
|
+
|
119
|
+
|
120
|
+
We can list the changes:
|
121
|
+
|
122
|
+
```bash
|
123
|
+
$ opsk uncommited
|
124
|
+
Listing changes for modules/artifactory:
|
125
|
+
|
126
|
+
changed files:
|
127
|
+
|
128
|
+
- metadata.json
|
129
|
+
|
130
|
+
added files:
|
131
|
+
|
132
|
+
untracked files:
|
133
|
+
```
|
134
|
+
|
135
|
+
We can commit them (providing a commit message per module or --message for all):
|
136
|
+
```bash
|
137
|
+
# We hacked a number of submodules, now we commit
|
138
|
+
$ opsk commit
|
139
|
+
Listing changes for modules/artifactory:
|
140
|
+
|
141
|
+
changed files:
|
142
|
+
|
143
|
+
- metadata.json
|
144
|
+
|
145
|
+
added files:
|
146
|
+
|
147
|
+
untracked files:
|
148
|
+
|
149
|
+
Commit the changes under modules/artifactory? (y/n) y
|
150
|
+
Commit message:
|
151
|
+
This is a nice change
|
152
|
+
```
|
153
|
+
|
154
|
+
|
155
|
+
Once commits are made we can push the changes:
|
156
|
+
|
157
|
+
```bash
|
158
|
+
$ opsk push
|
159
|
+
Push modules/artifactory? (y/n) y
|
160
|
+
pushing modules/artifactory ..
|
161
|
+
```
|
162
|
+
|
163
|
+
|
164
|
+
=== Testing
|
165
|
+
|
166
|
+
Opskelaton supports two levels of testing:
|
167
|
+
|
168
|
+
* Static module testing that includes rspec and linting.
|
169
|
+
* Integration testing using http://serverspec.org/[serverspec]and Vagrant.
|
170
|
+
|
171
|
+
```bash
|
172
|
+
# linting all static modules
|
173
|
+
$ rake lint
|
174
|
+
# rspecing
|
175
|
+
$ rake modspec
|
176
|
+
# running serverspec
|
177
|
+
$ rake spec
|
178
|
+
```
|
179
|
+
|
180
|
+
=== Packaging
|
181
|
+
Opskelaton fully supports deployment and portable execution of sandboxes on non Vagrant environments:
|
182
|
+
|
183
|
+
```bash
|
184
|
+
$ opsk generate_puppet foo ubuntu-13.10
|
185
|
+
$ cd foo-sandbox
|
186
|
+
# The package version file
|
187
|
+
$ cat opsk.yaml
|
188
|
+
---
|
189
|
+
version: '0.0.1'
|
190
|
+
name: foo
|
191
|
+
|
192
|
+
# post bundle and gem install ..
|
193
|
+
$ opsk package
|
194
|
+
create pkg/foo-sandbox-0.0.1
|
195
|
+
create pkg/foo-sandbox-0.0.1/scripts
|
196
|
+
create pkg/foo-sandbox-0.0.1/scripts/lookup.rb
|
197
|
+
chmod pkg/foo-sandbox-0.0.1/scripts/lookup.rb
|
198
|
+
create pkg/foo-sandbox-0.0.1/scripts/run.sh
|
199
|
+
chmod pkg/foo-sandbox-0.0.1/scripts/run.sh
|
200
|
+
create pkg/foo-sandbox-0.0.1/manifests/site.pp
|
201
|
+
exist pkg
|
202
|
+
$ ls pkg
|
203
|
+
foo-sandbox-0.0.1 foo-sandbox-0.0.1.tar.gz
|
204
|
+
```
|
205
|
+
The packaging process creates a portable tar file that can be run on any machine with puppet installed via the bundled run.sh:
|
206
|
+
|
207
|
+
```bash
|
208
|
+
$ tar -xvzf foo-sandbox-0.0.1.tar.gz
|
209
|
+
$ cd foo-sandbox-0.0.1
|
210
|
+
$ sudo ./run.sh
|
211
|
+
```
|
212
|
+
|
213
|
+
An external node classifier based runner is also available under scripts/run.sh, this runner expects to get a <hostname>.yaml input file with the required node classes.
|
214
|
+
|
215
|
+
=== Updating
|
216
|
+
Keeping you box up to date with latest opsk version is easy, just re-generate it again and resolve conflicts by answering y/n:
|
217
|
+
```bash
|
218
|
+
# Moving to latest opsk
|
219
|
+
$ gem update opskeleton
|
220
|
+
# foo box already exists
|
221
|
+
$ opsk generate foo <vagrant-box>
|
222
|
+
exist foo-sandbox
|
223
|
+
conflict foo-sandbox/Vagrantfile
|
224
|
+
Overwrite /home/ronen/code/foo-sandbox/Vagrantfile? (enter "h" for help) [Ynaqdh]
|
225
|
+
```
|
226
|
+
|
227
|
+
=== Vagrant
|
228
|
+
Opskeleton generates a Vagrant file with couple of enhancements:
|
229
|
+
|
230
|
+
* VAGRANT_BRIDGE (default eth0) for setting up public bridge on the go.
|
231
|
+
* PUPPET_ENV (default dev) for setting puppet environment.
|
232
|
+
* Puppet options preset to match modules and hiera folders.
|
233
|
+
|
234
|
+
=== Docker
|
235
|
+
The only assumption that Opskelaton makes is that the target host will have Pupppet installed, this enables us to create docker images from our sandboxes quite easily:
|
236
|
+
|
237
|
+
```bash
|
238
|
+
# creates dockerfiles/<host> and fig.yml
|
239
|
+
$ opsk dockerize
|
240
|
+
$ opsk package
|
241
|
+
# grabs the opsk tar file
|
242
|
+
$ sudo fig build
|
243
|
+
```
|
244
|
+
|
245
|
+
=== Benchmarking
|
246
|
+
Tracking the speed of our provisioning code is important for keeping a consistent level of service with the produced sandboxes, enabling benchmarking:
|
247
|
+
|
248
|
+
```bash
|
249
|
+
$ opsk generate_puppet redis ubuntu-14.04 --bench-enable
|
250
|
+
# install imagemagic before bundle install
|
251
|
+
$ sudo apt-get install imagemagick libmagickwand-dev
|
252
|
+
$ rake serverspec:redis
|
253
|
+
# with each run more result lines will be recorded
|
254
|
+
$ cat benchmark.json
|
255
|
+
{"total":656,"host":"redis","revision":"5d03a41ade9fc3dd5296d4119ccb0b0ad8290b9e","time":"2014-12-17 02:57:45 +0200"}
|
256
|
+
# add it to git for tracking
|
257
|
+
$ git add benchmark.json
|
258
|
+
```
|
259
|
+
|
260
|
+
Now after a number of runs we could plot and view the results of a single host or of all the hosts side by side:
|
261
|
+
|
262
|
+
```bash
|
263
|
+
$ rake plot:hosts plot:per_hosts
|
264
|
+
# resulting png files
|
265
|
+
$ google-chrome plots
|
266
|
+
```
|
267
|
+
|
268
|
+
== Chef
|
269
|
+
|
270
|
+
=== Introduction
|
271
|
+
Opskelaton fully supports Chef based projects it offers similar features to the Puppet based sandboxes with additional support for roles, environments and cookbooks.
|
272
|
+
|
273
|
+
Creating out first sandbox
|
274
|
+
|
275
|
+
```bash
|
276
|
+
$ opsk generate_chef redis ubuntu-14.04
|
277
|
+
$ cd redis-sandbox
|
278
|
+
```
|
279
|
+
|
280
|
+
=== Structure
|
281
|
+
|
282
|
+
==== layout
|
283
|
+
Opskelaton creates the complete folder structure fine tuned to match best practices:
|
284
|
+
|
285
|
+
Folder layout:
|
286
|
+
|
287
|
+
image:https://raw.githubusercontent.com/opskeleton/opskeleton/master/img/chef-layout.png[width='30%',hight='50%']
|
288
|
+
|
289
|
+
==== lifecycle
|
290
|
+
|
291
|
+
Opskelaton defines a simple cookbook life cycle:
|
292
|
+
|
293
|
+
1. Internal non reusable cookbooks (usually specific to a client site) go under static-cookbooks
|
294
|
+
2. If we create a general reusable cookbook which is ready for prime time we pull out to a new git repository.
|
295
|
+
3. The extracted cookbook is added back as a third party (using [librarian-chef](https://github.com/applicationsonline/librarian-chef) thatd will place them under cookbooks folder).
|
296
|
+
|
297
|
+
Life cycle scheme:
|
298
|
+
|
299
|
+
image:https://raw.githubusercontent.com/opskeleton/opskeleton/master/img/chef-cycle.png[width='40%',hight='50%']
|
300
|
+
|
301
|
+
Creating new cookbooks is easy as:
|
302
|
+
|
303
|
+
```bash
|
304
|
+
$ opsk cookbook foo
|
305
|
+
```
|
306
|
+
|
307
|
+
=== Testing
|
308
|
+
|
309
|
+
Opskelaton supports testing/linting:
|
310
|
+
|
311
|
+
* Static cookbook testing that includes rspec and food-critic. (TBD)
|
312
|
+
* Integration testing using [serverspec](http://serverspec.org/) and Vagrant.
|
313
|
+
|
314
|
+
```bash
|
315
|
+
# running serverspec
|
316
|
+
$ rake spec
|
317
|
+
```
|
318
|
+
|
319
|
+
=== Packaging
|
320
|
+
Opskelaton fully supports deployment and portable execution of sandboxes on non Vagrant environments:
|
321
|
+
|
322
|
+
```bash
|
323
|
+
$ opsk generate_chef foo ubuntu-14.04.
|
324
|
+
$ cd foo-sandbox
|
325
|
+
# The package version file
|
326
|
+
$ cat opsk.yaml
|
327
|
+
|
328
|
+
---
|
329
|
+
version: '0.0.1'
|
330
|
+
name: redis
|
331
|
+
includes:
|
332
|
+
- Cheffile
|
333
|
+
- cookbooks
|
334
|
+
- static-cookbooks
|
335
|
+
- dna.json
|
336
|
+
- environments
|
337
|
+
- Gemfile
|
338
|
+
- Gemfile.lock
|
339
|
+
- opsk.yaml
|
340
|
+
- roles
|
341
|
+
- LICENSE-2.0.txt
|
342
|
+
- run.sh
|
343
|
+
- boot.sh
|
344
|
+
- solo.rb
|
345
|
+
|
346
|
+
# post bundle and gem install ..
|
347
|
+
$ opsk package
|
348
|
+
create pkg/foo-sandbox-0.0.1
|
349
|
+
create pkg/foo-sandbox-0.0.1/scripts
|
350
|
+
create pkg/foo-sandbox-0.0.1/scripts/lookup.rb
|
351
|
+
chmod pkg/foo-sandbox-0.0.1/scripts/lookup.rb
|
352
|
+
create pkg/foo-sandbox-0.0.1/scripts/run.sh
|
353
|
+
chmod pkg/foo-sandbox-0.0.1/scripts/run.sh
|
354
|
+
exist pkg
|
355
|
+
$ ls pkg
|
356
|
+
foo-sandbox-0.0.1 foo-sandbox-0.0.1.tar.gz
|
357
|
+
```
|
358
|
+
The packaging process creates a portable tar file that can be run on any machine with chef-solo installed via the bundled run.sh:
|
359
|
+
|
360
|
+
```bash
|
361
|
+
$ tar -xvzf foo-sandbox-0.0.1.tar.gz
|
362
|
+
$ cd foo-sandbox-0.0.1
|
363
|
+
# expects to get the chef environment
|
364
|
+
$ sudo ./run.sh dev
|
365
|
+
```
|
366
|
+
|
367
|
+
=== Updating
|
368
|
+
|
369
|
+
Keeping you box up to date with latest opsk version is easy, just re-generate it again and resolve conflicts by answering y/n:
|
370
|
+
```bash
|
371
|
+
# Moving to latest opsk
|
372
|
+
$ gem update opskeleton
|
373
|
+
# foo box already exists
|
374
|
+
$ opsk generate_chef foo <vagrant-box>
|
375
|
+
exist foo-sandbox
|
376
|
+
conflict foo-sandbox/Vagrantfile
|
377
|
+
Overwrite /home/ronen/code/foo-sandbox/Vagrantfile? (enter "h" for help) [Ynaqdh]
|
378
|
+
```
|
379
|
+
|
380
|
+
=== Vagrant
|
381
|
+
Opskeleton generates a Vagrant file with couple of enhancements:
|
382
|
+
|
383
|
+
* CHEF_ENV (default dev) for setting chef environment.
|
384
|
+
* Default role (sandbox name) created under roles/{type}.rb
|
385
|
+
* static-cookbooks/cookbooks roles/environments folders are set.
|
386
|
+
|
387
|
+
== Deployment
|
388
|
+
|
389
|
+
The packaged tar files can be consumed using any tool and protocol (http, s3 etc), opsk has built in support for deploying public sandboxes into:
|
390
|
+
|
391
|
+
* Bintray (make sure to https://github.com/narkisr/bintray-deploy#usage[configure] the bintray API key):
|
392
|
+
|
393
|
+
```bash
|
394
|
+
$ opsk package
|
395
|
+
$ opsk deploy_bintray <bintray-repo>
|
396
|
+
deployed foo-sandbox-0.0.1.tar.gz to http://dl.bintray.com/narkisr/<bintray-repo>/foo-sandbox-0.0.1.tar.gz
|
397
|
+
```
|
398
|
+
|
399
|
+
* S3 (Make sure to configure s3 section under ~/.configuration.rb):
|
400
|
+
|
401
|
+
```bash
|
402
|
+
$ opsk package
|
403
|
+
$ opsk deploy_s3 <bucket> <path>
|
404
|
+
deployed foo-sandbox-0.0.1.tar.gz to opsk-boxes/foo/foo-sandbox-0.0.1.tar.gz
|
405
|
+
```
|
406
|
+
|
407
|
+
```ruby
|
408
|
+
Configuration.for('s3') {
|
409
|
+
access_key ''
|
410
|
+
secret_key ''
|
411
|
+
region ''
|
412
|
+
}
|
413
|
+
```
|
414
|
+
|
415
|
+
* Scp (Make sure to configure scp section under ~/.configuration.rb):
|
416
|
+
|
417
|
+
```bash
|
418
|
+
$ opsk package
|
419
|
+
$ opsk deploy_scp bar
|
420
|
+
deployed foo-sandbox-0.0.1.tar.gz to foo@opsk-boxes:/var/boxes
|
421
|
+
```
|
422
|
+
|
423
|
+
```ruby
|
424
|
+
Configuration.for('scp') {
|
425
|
+
bar {
|
426
|
+
host 'opsk-boxes'
|
427
|
+
user 'foo'
|
428
|
+
dest '/var/boxes'
|
429
|
+
# optional
|
430
|
+
port 2222
|
431
|
+
}
|
432
|
+
}
|
433
|
+
```
|
434
|
+
|
data/lib/opskeleton/commit.rb
CHANGED
@@ -1,14 +1,42 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
|
3
|
+
module Opsk
|
4
|
+
class CommitGit
|
5
|
+
def initialize(d,options,thor)
|
6
|
+
@g = Git.init(d)
|
7
|
+
@options = options
|
8
|
+
@thor = thor
|
9
|
+
end
|
10
|
+
|
11
|
+
def changed?
|
12
|
+
@g.status.changed.keys.length > 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def report
|
16
|
+
%i(changed added untracked).each do |state|
|
17
|
+
@thor.say "#{state} files:\n\n"
|
18
|
+
@g.status.send(state).each do |k,v|
|
19
|
+
@thor.say "- #{k}"
|
20
|
+
end
|
21
|
+
@thor.say "\n"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def master_commit(d)
|
26
|
+
resp = @thor.yes? "Commit the changes under #{d}? (y/n)" unless @options['all']
|
27
|
+
if(@options['all'] or resp)
|
28
|
+
@g.checkout('master')
|
29
|
+
if @options['message']
|
30
|
+
@g.commit_all(@options['message'])
|
31
|
+
else
|
32
|
+
@thor.say 'Commit message:'
|
33
|
+
@g.commit_all(STDIN.gets.chomp)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
7
37
|
end
|
8
38
|
end
|
9
|
-
end
|
10
39
|
|
11
|
-
module Opsk
|
12
40
|
class Commit < Thor::Group
|
13
41
|
include Thorable, Thor::Actions
|
14
42
|
|
@@ -23,25 +51,19 @@ module Opsk
|
|
23
51
|
def commit
|
24
52
|
Dir["modules/*"].reject{|o| not File.directory?(o)}.each do |d|
|
25
53
|
if File.exists?("#{d}/.git")
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
g.checkout('master')
|
33
|
-
if options['message']
|
34
|
-
g.commit_all(options['message'])
|
35
|
-
else
|
36
|
-
say 'Commit message:'
|
37
|
-
g.commit_all(STDIN.gets.chomp)
|
38
|
-
end
|
54
|
+
begin
|
55
|
+
cg = Opsk::CommitGit.new(d,options,self)
|
56
|
+
if cg.changed?
|
57
|
+
say "Listing changes for #{d}:\n\n"
|
58
|
+
cg.report
|
59
|
+
cg.master_commit(d)
|
39
60
|
end
|
61
|
+
rescue => e
|
62
|
+
say "Failed to commit #{d} due to #{e}"
|
40
63
|
end
|
41
64
|
end
|
42
65
|
end
|
43
66
|
end
|
44
67
|
|
45
|
-
|
46
68
|
end
|
47
69
|
end
|
data/lib/opskeleton/push.rb
CHANGED
@@ -32,17 +32,21 @@ module Opsk
|
|
32
32
|
|
33
33
|
def push
|
34
34
|
Dir["modules/*"].reject{|o| not File.directory?(o)}.each do |d|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
begin
|
36
|
+
if File.exists?("#{d}/.git")
|
37
|
+
g = Git.init(d)
|
38
|
+
add_writable(g,options['protocol'].to_sym)
|
39
|
+
if !options['dry'] and g.diff('origin').stats[:files].keys.length > 0
|
40
|
+
resp = yes?("Push #{d}? (y/n)") unless options['all']
|
41
|
+
if(options['all'] or resp)
|
42
|
+
say "pushing #{d} .."
|
43
|
+
g.push('writable')
|
44
|
+
g.pull
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
48
|
+
rescue => e
|
49
|
+
say "Failed to push #{d} due to #{e}"
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Opsk
|
4
|
+
class CommitGit
|
5
|
+
def initialize(d,options,thor)
|
6
|
+
@g = Git.init(d)
|
7
|
+
@options = options
|
8
|
+
@thor = thor
|
9
|
+
end
|
10
|
+
|
11
|
+
def changed?
|
12
|
+
@g.status.changed.keys.length > 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def report
|
16
|
+
%i(changed added untracked).each do |state|
|
17
|
+
@thor.say "#{state} files:\n\n"
|
18
|
+
@g.status.send(state).each do |k,v|
|
19
|
+
@thor.say "- #{k}"
|
20
|
+
end
|
21
|
+
@thor.say "\n"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def master_commit(d)
|
26
|
+
resp = @thor.yes? "Commit the changes under #{d}? (y/n)" unless @options['all']
|
27
|
+
if(@options['all'] or resp)
|
28
|
+
@g.checkout('master')
|
29
|
+
if @options['message']
|
30
|
+
@g.commit_all(@options['message'])
|
31
|
+
else
|
32
|
+
@thor.say 'Commit message:'
|
33
|
+
@g.commit_all(STDIN.gets.chomp)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Uncommited < Thor::Group
|
41
|
+
include Thorable, Thor::Actions
|
42
|
+
|
43
|
+
def validate
|
44
|
+
check_root
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def uncommited
|
49
|
+
Dir["modules/*"].reject{|o| not File.directory?(o)}.each do |d|
|
50
|
+
if File.exists?("#{d}/.git")
|
51
|
+
begin
|
52
|
+
cg = Opsk::CommitGit.new(d,options,self)
|
53
|
+
if cg.changed?
|
54
|
+
say "Listing changes for #{d}:\n\n"
|
55
|
+
cg.report
|
56
|
+
end
|
57
|
+
rescue => e
|
58
|
+
say "Failed to check uncommited under #{d} due to #{e}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/opskeleton/version.rb
CHANGED
data/lib/opskeleton.rb
CHANGED
data/opskeleton.gemspec
CHANGED
@@ -22,6 +22,11 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.add_development_dependency('librarian-puppet', '= 2.1.0')
|
23
23
|
gem.add_development_dependency('puppetlabs_spec_helper', '>= 0.1.0')
|
24
24
|
gem.add_development_dependency('pry')
|
25
|
+
gem.add_development_dependency('asciidoctor')
|
26
|
+
gem.add_development_dependency('pygments.rb')
|
27
|
+
gem.add_development_dependency('guard')
|
28
|
+
gem.add_development_dependency('guard-shell')
|
29
|
+
gem.add_development_dependency('guard-minitest')
|
25
30
|
|
26
31
|
gem.files = `git ls-files`.split($/)
|
27
32
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
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.
|
4
|
+
version: 0.9.3
|
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-
|
11
|
+
date: 2015-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -164,6 +164,76 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: asciidoctor
|
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
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: pygments.rb
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: guard
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: guard-shell
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: guard-minitest
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
167
237
|
description: A generator for ops projects that include vagrant puppet and fpm
|
168
238
|
email:
|
169
239
|
- narkisr@gmail.com
|
@@ -179,6 +249,7 @@ files:
|
|
179
249
|
- CHANGES.md
|
180
250
|
- Gemfile
|
181
251
|
- Gemfile.lock
|
252
|
+
- Guardfile
|
182
253
|
- LICENSE-2.0.txt
|
183
254
|
- README.md
|
184
255
|
- Rakefile
|
@@ -187,6 +258,8 @@ files:
|
|
187
258
|
- bin/opsk
|
188
259
|
- docs/chef.md
|
189
260
|
- docs/deploy.md
|
261
|
+
- docs/doc-docinfo.html
|
262
|
+
- docs/doc.adoc
|
190
263
|
- docs/puppet.md
|
191
264
|
- img/chef-cycle.png
|
192
265
|
- img/chef-layout.png
|
@@ -206,6 +279,7 @@ files:
|
|
206
279
|
- lib/opskeleton/package.rb
|
207
280
|
- lib/opskeleton/push.rb
|
208
281
|
- lib/opskeleton/thorable.rb
|
282
|
+
- lib/opskeleton/uncommited.rb
|
209
283
|
- lib/opskeleton/version.rb
|
210
284
|
- opskeleton.gemspec
|
211
285
|
- templates/LICENSE-2.0.txt
|