puppet-magnum 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.rspec +3 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +1 -0
  6. data/Gemfile +2 -0
  7. data/Gemfile.lock +73 -0
  8. data/LICENSE +13 -0
  9. data/README.md +247 -0
  10. data/Rakefile +20 -0
  11. data/VERSION +1 -0
  12. data/bin/puppet-magnum +6 -0
  13. data/generator_files/CHANGELOG.md.erb +0 -0
  14. data/generator_files/README.md.erb +11 -0
  15. data/generator_files/git/gitignore.erb +40 -0
  16. data/generator_files/licenses/apachev2.erb +13 -0
  17. data/generator_files/licenses/mit.erb +20 -0
  18. data/generator_files/licenses/reserved.erb +2 -0
  19. data/generator_files/puppet-magnum.init.erb +1 -0
  20. data/generator_files/puppet/init.pp.erb +47 -0
  21. data/generator_files/puppet/metadata.json.erb +26 -0
  22. data/generator_files/puppet/params.pp.erb +16 -0
  23. data/generator_files/spec/fixtures.yml.erb +9 -0
  24. data/generator_files/spec/rspec.erb +2 -0
  25. data/generator_files/spec/rspec/init_spec.rb.erb +6 -0
  26. data/generator_files/spec/rspec/spec_helper.rb.erb +10 -0
  27. data/generator_files/spec/serverspec/init_spec.rb.erb +5 -0
  28. data/generator_files/util/Gemfile.erb +10 -0
  29. data/generator_files/util/Rakefile.erb +35 -0
  30. data/generator_files/vagrant/Vagrantfile.erb +33 -0
  31. data/generator_files/vagrant/environment/environment.conf.erb +18 -0
  32. data/generator_files/vagrant/environment/manifests/init.pp.erb +1 -0
  33. data/generator_files/vagrant/init.sh.erb +23 -0
  34. data/lib/puppet-magnum.rb +13 -0
  35. data/lib/puppet-magnum/cli.rb +16 -0
  36. data/lib/puppet-magnum/cli/module.rb +32 -0
  37. data/lib/puppet-magnum/generators/base_generator.rb +23 -0
  38. data/lib/puppet-magnum/generators/create_generator.rb +188 -0
  39. data/lib/puppet-magnum/version.rb +3 -0
  40. data/puppet-magnum.gemspec +40 -0
  41. data/spec/lib/puppet-magnum/cli_spec.rb +18 -0
  42. data/spec/lib/puppet-magnum/generators/base_generator_spec.rb +11 -0
  43. data/spec/lib/puppet-magnum/generators/create_generator_spec.rb +4 -0
  44. data/spec/lib/puppet_magnum_spec.rb +20 -0
  45. data/spec/spec_helper.rb +35 -0
  46. metadata +264 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57ae8ee81fd6f3f7db0952af9ab709f6c5f82dd6
4
+ data.tar.gz: 1c95a2d6587db3993349edb8b00b4199cd95354f
5
+ SHA512:
6
+ metadata.gz: ef9c44712385ea9210c4e2aef507fe245ad232956bcc8ca38c271650f9e13e996a58983c8672998dd164fc70f1de441e83c0894513d98526d2e18d6bfdcc911d
7
+ data.tar.gz: 3235a2aa488184eb25253c031316c8cf2a1eec1da758530547463391af4e47060238829bbb6d32f94eb827553f6395bd0154115698444ebeebd8aa3f194d9a91
@@ -0,0 +1,20 @@
1
+ .DS_Store*
2
+ ._*
3
+ *~
4
+ *#
5
+ .#*
6
+ \#*#
7
+ .*.sw[a-z]
8
+ *.un~
9
+ *.gem
10
+ *.rbc
11
+ *.html
12
+ .bundle
13
+ .config
14
+ InstalledFiles
15
+ vendor
16
+ coverage
17
+ doc/
18
+ pkg/
19
+
20
+ spec/spec_output.txt
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
@@ -0,0 +1 @@
1
+ 2.3.0
@@ -0,0 +1 @@
1
+ language: ruby
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,73 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ puppet-magnum (3.0.0)
5
+ bundler (>= 1.11.2)
6
+ colorize (>= 0.7.7)
7
+ puppet (~> 4.4.1)
8
+ puppet-lint (~> 1.1.0)
9
+ puppetlabs_spec_helper (~> 1.1.1)
10
+ redcarpet (>= 3.3.4)
11
+ rspec (~> 3.1.0)
12
+ rspec-puppet (~> 2.4.0)
13
+ thor (>= 0.19.1)
14
+ version (>= 1.0.0)
15
+
16
+ GEM
17
+ remote: https://rubygems.org/
18
+ specs:
19
+ CFPropertyList (2.2.8)
20
+ colorize (0.7.7)
21
+ diff-lcs (1.2.5)
22
+ facter (2.4.6)
23
+ CFPropertyList (~> 2.2.6)
24
+ hiera (3.1.1)
25
+ json_pure
26
+ json_pure (1.8.3)
27
+ metaclass (0.0.4)
28
+ mocha (1.1.0)
29
+ metaclass (~> 0.0.1)
30
+ puppet (4.4.1)
31
+ CFPropertyList (~> 2.2.6)
32
+ facter (> 2.0, < 4)
33
+ hiera (>= 2.0, < 4)
34
+ json_pure
35
+ puppet-lint (1.1.0)
36
+ puppet-syntax (2.1.0)
37
+ rake
38
+ puppetlabs_spec_helper (1.1.1)
39
+ mocha
40
+ puppet-lint
41
+ puppet-syntax
42
+ rake
43
+ rspec-puppet
44
+ rake (11.1.2)
45
+ redcarpet (3.3.4)
46
+ rspec (3.1.0)
47
+ rspec-core (~> 3.1.0)
48
+ rspec-expectations (~> 3.1.0)
49
+ rspec-mocks (~> 3.1.0)
50
+ rspec-core (3.1.7)
51
+ rspec-support (~> 3.1.0)
52
+ rspec-expectations (3.1.2)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.1.0)
55
+ rspec-mocks (3.1.3)
56
+ rspec-support (~> 3.1.0)
57
+ rspec-puppet (2.4.0)
58
+ rspec
59
+ rspec-support (3.1.2)
60
+ sem_ver (0.1.1)
61
+ thor (0.19.1)
62
+ version (1.0.0)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ puppet-magnum!
69
+ rake (>= 10.5.0)
70
+ sem_ver (>= 0.1.1)
71
+
72
+ BUNDLED WITH
73
+ 1.11.2
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2013-2016 Tehmasp Chaudhri <tehmasp@gmail.com>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,247 @@
1
+ # puppet-magnum
2
+
3
+ [![Build Status](https://travis-ci.org/tehmaspc/puppet-magnum.svg?branch=master)](https://travis-ci.org/tehmaspc/puppet-magnum)
4
+
5
+ puppet-magnum - a tool for rapid, consistent, and best practice [Puppet](http://puppetlabs.com) module development.
6
+
7
+ puppet-magnum is essentially a Puppet module project generator and a wrapper
8
+ around tools such as: [puppetlabs_spec_helper](http://github.com/puppetlabs/puppetlabs_spec_helper), [rspec-puppet](http://rspec-puppet.com/), [puppet-lint](http://puppet-lint.com/), [vagrant-serverspec](https://github.com/jvoorhis/vagrant-serverspec), [vagrant](http://vagrantup.com), and more!
9
+
10
+ ## Requirements
11
+
12
+ puppet-magnum is a Ruby gem and thus requires a working Ruby environment on your development machine.
13
+ It's recommended to use [rbenv](http://github.com/sstephenson/rbenv) to install and manage the Ruby versions on your machine.
14
+
15
+ Currently, using Ruby 2.3.0 latest and above should work fine with puppet-magnum.
16
+ Additionally, ensure that [bundler](http://bundler.io/) (a Ruby gem manager) is installed and available in your gem path.
17
+
18
+ ## Installation
19
+
20
+ Install puppet-magnum for yourself by doing the following inside a copy of this repo:
21
+
22
+ % bundle install && rake install
23
+
24
+ ## Usage
25
+
26
+ % puppet-magnum --help
27
+ Commands:
28
+ puppet-magnum help [COMMAND] # Describe available commands or one specific command
29
+ puppet-magnum module # Module related tasks. Type 'puppet-magnum module' for more help.
30
+ puppet-magnum version # Display version and copyright information
31
+
32
+ ## Example Creating An 'nginx' Puppet Module
33
+
34
+ The following shows how one can get started quickly creating an 'nginx' Puppet module:
35
+
36
+ % puppet-magnum module create nginx
37
+ create nginx/manifests
38
+ create nginx/templates
39
+ create nginx/files
40
+ create nginx/spec
41
+ create nginx/serverspec
42
+ create nginx/.vagrant_puppet
43
+ create nginx/README.md
44
+ create nginx/LICENSE
45
+ create nginx/metadata.json
46
+ create nginx/manifests/init.pp
47
+ create nginx/spec/classes
48
+ create nginx/spec/defines
49
+ create nginx/spec/functions
50
+ create nginx/spec/hosts
51
+ create nginx/spec/unit
52
+ create nginx/spec/fixtures/manifests
53
+ create nginx/spec/fixtures/manifests/site.pp
54
+ create nginx/spec/fixtures/modules/nginx
55
+ remove nginx/spec/fixtures/modules/nginx/manifests
56
+ create nginx/spec/fixtures/modules/nginx/manifests
57
+ remove nginx/spec/fixtures/modules/nginx/templates
58
+ create nginx/spec/fixtures/modules/nginx/templates
59
+ remove nginx/spec/fixtures/modules/nginx/files
60
+ create nginx/spec/fixtures/modules/nginx/files
61
+ create nginx/spec/spec_helper.rb
62
+ create nginx/spec/classes/nginx_spec.rb
63
+ create nginx/.rspec
64
+ create nginx/serverspec/nginx_spec.rb
65
+ create nginx/.fixtures.yml
66
+ remove nginx/Gemfile
67
+ create nginx/Gemfile
68
+ remove nginx/Rakefile
69
+ create nginx/Rakefile
70
+ create nginx/Vagrantfile
71
+ create nginx/.vagrant_puppet/init.sh
72
+ create nginx/.vagrant_puppet/environments/vagrant/environment.conf
73
+ create nginx/.vagrant_puppet/environments/vagrant/manifests/init.pp
74
+ remove nginx/.magnum.init
75
+ create nginx/.magnum.init
76
+ remove nginx/.gitignore
77
+ create nginx/.gitignore
78
+ run git init from "./nginx"
79
+ run git add -A from "./nginx"
80
+
81
+ ## Parameters
82
+
83
+ puppet-magnum can take several parameters which will be used for populating the templates of things like manifest documentation, licensing and maintainer information.
84
+
85
+ - maintainer: maintainer name of module.
86
+ - maintainer_email: maintainer email of module.
87
+ - copyright_year: defaults to current year.
88
+ - copyright_holder: defaults to maintainer if not declared.
89
+
90
+ ### .magnumrc file
91
+ The values above can be set via a file in your home directory called *_.magnumrc_*
92
+
93
+ ```
94
+ ---
95
+ maintainer: Infrastructure Team
96
+ maintainer_email: infrastructure_team@example.com
97
+ copyright_holder: Example.com LLC
98
+ ```
99
+
100
+ ## Testing within a puppet-magnum Managed Puppet Module
101
+
102
+ puppet-magnum provides the following Puppet testing tools to allow the Puppet module developer a means to test their Puppet code. The tools provided are [puppet-lint](http://puppet-lint.com/), [rspec-puppet](http://rspec-puppet.com/), [serverspec](http://serverspec.org/), and [vagrant](http://vagrantup.com).
103
+
104
+ The following will describe what each tool provided does and how it can be used within a puppet-magnum managed Puppet module.
105
+
106
+ ### puppet-lint
107
+
108
+ [puppet-lint](http://puppet-lint.com/) allows the Puppet module developer to statically check that the content of their Puppet code conforms to the Puppet style standard. It checks for trailing whitespace, indentation and tabs, and many other Puppet style guidelines as listed [here](http://puppet-lint.com/checks/). With puppet-lint checking for unconformity, it's a lot easier for a team of Puppet developers to adhere to a general style guideline.
109
+
110
+ puppet-magnum sets up the puppet-lint tool in the Puppet module directory and provides the Rake task 'lint' to run puppet-lint against your code, as shown:
111
+
112
+ % rake lint
113
+ manifests/client.pp - WARNING: class not documented on line 1
114
+ manifests/crowsnest.pp - WARNING: class not documented on line 1
115
+ manifests/params.pp - WARNING: top-scope variable being used without an explicit namespace on line 3
116
+ manifests/params.pp - WARNING: class not documented on line 1
117
+ manifests/params.pp - ERROR: trailing whitespace found on line 21
118
+ ...
119
+
120
+ The developer should check for puppet-lint warnings and errors and fix their code to conform to the style guidelines. Errors should definitely be fixed as they will cause further tests to fail.
121
+
122
+ If the developer runs the 'lint' task and there is no output - then all the puppet-lint checks passed successfully.
123
+
124
+ For more details about puppet-lint, please check the [project website](http://puppet-lint.com/).
125
+
126
+ ### rspec-puppet
127
+
128
+ [rspec-puppet](http://rspec-puppet.com/) allows the Puppet module developer to write [RSpec](https://relishapp.com/rspec) unit tests for their Puppet code.
129
+
130
+ Each puppet-magnum managed Puppet module directory will have a subdirectory called 'spec' with a directory tree as follows:
131
+
132
+ spec
133
+ ├── spec/classes
134
+ │   └── spec/classes/ntp_spec.rb
135
+ ├── spec/defines
136
+ ├── spec/fixtures
137
+ │   ├── spec/fixtures/manifests
138
+ │   │   └── spec/fixtures/manifests/site.pp
139
+ │   └── spec/fixtures/modules
140
+ │   └── spec/fixtures/modules/ntp
141
+ │   ├── spec/fixtures/modules/ntp/files -> ../../../../files
142
+ │   ├── spec/fixtures/modules/ntp/lib
143
+ │   │   └── spec/fixtures/modules/ntp/lib/puppet
144
+ │   │   └── spec/fixtures/modules/ntp/lib/puppet/parser
145
+ │   │   └── spec/fixtures/modules/ntp/lib/puppet/parser/functions
146
+ │   │   └── spec/fixtures/modules/ntp/lib/puppet/parser/functions/zabbix_registration.rb
147
+ │   ├── spec/fixtures/modules/ntp/manifests -> ../../../../manifests
148
+ │   └── spec/fixtures/modules/ntp/templates -> ../../../../templates
149
+ ├── spec/functions
150
+ ├── spec/hosts
151
+ ├── spec/spec_helper.rb
152
+ └── spec/unit
153
+
154
+ All rspec-puppet tests for Puppet classes should be written in the 'spec/classes/MODULE_spec.rb' file.
155
+
156
+ All rspec-puppet tests for Puppet define types should be written in the 'spec/defines/MODULE_spec.rb' file.
157
+
158
+ As you can see above there are numerous files underneath the 'spec' subdirectory. A lot of these files - especially the files under 'spec/fixtures' - exist to glue together our RSpec testing tools. The 'spec/fixtures' directory is unique in that all module dependencies, including the module being developed, should be found under the 'spec/fixtures' directory. rspec-puppet, serverspec, and vagrant will all make use of this special 'spec/fixtures' directory.
159
+
160
+ In order to add additional module dependencies into your Puppet module, puppet-magnum provides a .fixtures.yml file which can be modified to add additional Puppet modules to your project. The default .fixtures.yml file will look like the following:
161
+
162
+ fixtures:
163
+ # repositories:
164
+ # stdlib: 'git://github.com/puppetlabs/puppetlabs-stdlib'
165
+ symlinks:
166
+ ntp/files: '../../../../files'
167
+ ntp/manifests: '../../../../manifests'
168
+ ntp/templates: '../../../../templates'
169
+
170
+ As you can see, additional modules - like 'stdlib' - can be added to your Puppet module project directory.
171
+
172
+ #### Running rspec-puppet tests
173
+
174
+ % rake unit
175
+ HEAD is now at 44c181e Merge branch 'fix/master/add_recursive_merge'
176
+ /usr/local/opt/rbenv/shims/ruby -S rspec spec/classes/config_spec.rb spec/classes/install_spec.rb spec/classes/ntp_spec.rb spec/classes/service_spec.rb --color
177
+ ........
178
+
179
+ Finished in 0.53874 seconds
180
+ 8 examples, 0 failures
181
+
182
+ For more details about rspec-puppet and how to write the actual rspec-puppet tests, please check the [project website](http://rspec-puppet.com/).
183
+
184
+ ### serverspec
185
+
186
+ [serverspec](http://serverspec.org/) allows the Puppet module developer to write [RSpec](https://relishapp.com/rspec) integration tests for their Puppet code. serverspec integration tests work in conjunction with [vagrant](http://www.vagrantup.com/) and allow a Puppet developer the ability to quickly provision a vagrant virtual box Linux system and then run these tests against this live system.
187
+
188
+ Each puppet-magnum managed Puppet module directory will have a subdirectory called 'serverspec' with a directory tree as follows:
189
+
190
+ serverspec
191
+ ├── serverspec/spec
192
+ │   └── serverspec/spec/MODULE_spec.rb
193
+ └── serverspec/spec_helper.rb
194
+
195
+ All serverspec tests should be written in the 'serverspec/spec/MODULE_spec.rb' file.
196
+
197
+ #### Running serverspec tests
198
+
199
+ % rake integ
200
+ HEAD is now at 44c181e Merge branch 'fix/master/add_recursive_merge'
201
+
202
+ Running integration tests on Vagrant image; this will take a few moments...
203
+
204
+ /usr/local/opt/rbenv/shims/ruby -S rspec serverspec/spec/ntp_spec.rb --color
205
+ ................
206
+
207
+ Finished in 48.7 seconds
208
+ 16 examples, 0 failures
209
+
210
+ For more details about serverspec and how to write the actual serverspec tests, please check the [project website](http://serverspec.org/).
211
+
212
+ ### vagrant
213
+
214
+ [vagrant](http://vagrantup.com) allows the Puppet developer to start local VirtualBox instances in their Puppet module project and provision the instance with the Puppet module being tested. vagrant requires a Vagrantfile which specifies how to launch a VirtualBox instance. puppet-magnum sets up the required Vagrantfile with the proper configurations required to start the VirtualBox VM (w/ 'vagrant up') and provision the instance with the module being tested.
215
+
216
+ puppet-magnum also creates a .vagrant_puppet/ directory in your Puppet module project and more importantly a .vagrant_puppet/init.pp file containing the necessary configuration for Puppet provisioning your VirtualBox instance. The Puppet module developer should change the .vagrant_puppet/init.pp file to provision their VirtualBox instance according to their needs. The best way to understand this is to take a look at some of the Puppet module examples below.
217
+
218
+ During the development of a Puppet module, the Puppet module developer can run 'vagrant provision' to continuously test their Puppet module changes. The developer can login to the VirtualBox instance (w/ 'vagrant ssh') and check the state of their Puppet provisioning.
219
+
220
+ NOTE: vagrant does NOT implicitly re-provision your VirtualBox instance each time. Only on a new VirtualBox instance creation will VirtualBox automatically run a 'provision' for you. The Puppet module developer should run 'vagrant provision' each time they need to check their latest Puppet code changes.
221
+
222
+ For more details about vagrant, please check the [project website](http://www.vagrantup.com/).
223
+
224
+ ## Credits
225
+
226
+ Standing on the shoulder's of giants - thanks to the following projects for inspiration!:
227
+
228
+ * [Thor](http://whatisthor.com/)
229
+ * [Berkshelf](http://berkshelf.com/)
230
+
231
+ ## Authors and License
232
+
233
+ * Author:: Tehmasp Chaudhri (<tehmasp@gmail.com>)
234
+
235
+ Copyright 2013-2016 Tehmasp Chaudhri
236
+
237
+ Licensed under the Apache License, Version 2.0 (the "License");
238
+ you may not use this file except in compliance with the License.
239
+ You may obtain a copy of the License at
240
+
241
+ http://www.apache.org/licenses/LICENSE-2.0
242
+
243
+ Unless required by applicable law or agreed to in writing, software
244
+ distributed under the License is distributed on an "AS IS" BASIS,
245
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
246
+ See the License for the specific language governing permissions and
247
+ limitations under the License.
@@ -0,0 +1,20 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/version_task'
3
+ require 'rspec/core/rake_task'
4
+
5
+ Rake::VersionTask.new
6
+
7
+ desc 'Run unit tests'
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ t.rspec_opts = ['--color --format progress']
11
+ end
12
+
13
+ desc 'Display the list of available rake tasks'
14
+ task :help do
15
+ system 'rake -T'
16
+ end
17
+
18
+ task :unit => 'spec'
19
+ task :test => 'spec'
20
+ task :default => 'spec'
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.0.0
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $:.push File.expand_path('../../lib', __FILE__)
3
+ require 'rubygems' # ruby1.9 doesn't 'require' it though
4
+ require 'puppet-magnum'
5
+
6
+ PuppetMagnum::Cli.start
File without changes
@@ -0,0 +1,11 @@
1
+ # <%= module_name %>
2
+
3
+ ## Description
4
+
5
+ ## Requirements
6
+
7
+ ## Platform
8
+
9
+ ## Admin Information
10
+
11
+ ## Reference
@@ -0,0 +1,40 @@
1
+ *.com
2
+ *.class
3
+ *.dll
4
+ *.exe
5
+ *.o
6
+ *.so
7
+ *.7z
8
+ *.dmg
9
+ *.gz
10
+ *.iso
11
+ *.jar
12
+ *.rar
13
+ *.tar
14
+ *.zip
15
+ *.log
16
+ *.sql
17
+ *.sqlite
18
+ .DS_Store*
19
+ ._*
20
+ *~
21
+ *#
22
+ .#*
23
+ \#*#
24
+ .*.sw[a-z]
25
+ *.un~
26
+ .Spotlight-V100
27
+ .Trashes
28
+ ehthumbs.db
29
+ Thumbs.db
30
+ Gemfile.lock
31
+ bin/*
32
+ .bundle/*
33
+ pkg
34
+
35
+ .vagrant
36
+ .vagrant_puppet/environments/vagrant/modules
37
+
38
+ # ignore all fixtures modules, except this module.
39
+ spec/fixtures/modules/*
40
+ !spec/fixtures/modules/<%= module_name %>