scaffold 0.0.1

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.
@@ -0,0 +1,74 @@
1
+ = scaffold
2
+
3
+ * http://github.com/jamtur01/puppet-scaffold
4
+
5
+ == DESCRIPTION:
6
+
7
+ A simple templating scaffolding system for Puppet
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ Creates:
12
+
13
+ * Modules - using the first module directory in the modulepath
14
+ * Class in a module
15
+ * Definition in a module
16
+ * Functions - in a specific module
17
+ * Puppet configuration - creates a base configuration in Puppet's confdir
18
+
19
+ == SYNOPSIS:
20
+
21
+ Create a module:
22
+ $ scaffold module module_name
23
+
24
+ Create a node:
25
+ $ scaffold node node_name
26
+
27
+ Create a class:
28
+ $ scaffold class module_name class_name
29
+
30
+ Create a definition:
31
+ $ scaffold define module_name define_name
32
+
33
+ Create a function:
34
+ $ scaffold function module_name function_name function_type
35
+
36
+ Create a type/provider:
37
+ $ scaffold type module_name type_name
38
+
39
+ Create Puppet configuration:
40
+ $ scaffold puppet
41
+
42
+ == REQUIREMENTS:
43
+
44
+ * templater
45
+ * Puppet
46
+
47
+ == INSTALL:
48
+
49
+ $ gem install templater
50
+
51
+ == LICENSE:
52
+
53
+ (The MIT License)
54
+
55
+ Copyright (c) 2010 James Turnbull
56
+
57
+ Permission is hereby granted, free of charge, to any person obtaining
58
+ a copy of this software and associated documentation files (the
59
+ 'Software'), to deal in the Software without restriction, including
60
+ without limitation the rights to use, copy, modify, merge, publish,
61
+ distribute, sublicense, and/or sell copies of the Software, and to
62
+ permit persons to whom the Software is furnished to do so, subject to
63
+ the following conditions:
64
+
65
+ The above copyright notice and this permission notice shall be
66
+ included in all copies or substantial portions of the Software.
67
+
68
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
69
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
70
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
71
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
72
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
73
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
74
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'newgem/tasks'
3
+ require 'fileutils'
4
+ require 'templater'
5
+ require File.dirname(__FILE__)+'/lib/scaffold.rb'
6
+
7
+ desc "Build gem"
8
+ task :build do
9
+ system "gem build .gemspec"
10
+ end
11
+
12
+ desc "Release gem to Gemcutter"
13
+ task :release => :build do
14
+ system "gem push scaffold"
15
+ end
@@ -0,0 +1,6 @@
1
+ = scaffold TODO
2
+
3
+ * Create generators for:
4
+ - Check for presence of modules before creation
5
+ - Tests
6
+
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'puppet'
5
+ require 'templater'
6
+ require File.dirname(__FILE__)+'/../lib/scaffold.rb'
7
+
8
+ Puppet.parse_config
9
+
10
+ case ARGV[0]
11
+ when 'puppet', 'node'
12
+ dir = Puppet[:confdir]
13
+ puts "#{dir}"
14
+ Scaffold::Generator.run_cli(dir, 'scaffold', Scaffold::VERSION, ARGV)
15
+ when 'module', 'class', 'define'
16
+ dir = Puppet[:modulepath].split(':')
17
+ Scaffold::Generator.run_cli(dir[0], 'scaffold', Scaffold::VERSION, ARGV)
18
+ when 'function', 'type'
19
+ dir = Puppet[:modulepath].split(':')
20
+ Scaffold::Generator.run_cli(dir[0], 'scaffold', Scaffold::VERSION, ARGV)
21
+ end
@@ -0,0 +1,9 @@
1
+ path = File.dirname(__FILE__) + '/scaffold/'
2
+
3
+ require path + 'generator'
4
+
5
+ module Scaffold
6
+
7
+ VERSION = '0.0.1'
8
+
9
+ end
@@ -0,0 +1,206 @@
1
+ module Scaffold
2
+ module Generator
3
+ extend Templater::Manifold
4
+
5
+ desc <<-DESC
6
+ Create template Puppet objects and configurations.
7
+ DESC
8
+
9
+ ##
10
+ class ModuleGenerator < Templater::Generator
11
+ desc <<-DESC
12
+ Create an empty Puppet module
13
+ DESC
14
+
15
+ first_argument :module_name, :required => true, :desc => "Your module name."
16
+
17
+ def self.source_root
18
+ File.expand_path(File.join(Dir.pwd, 'templates/module'))
19
+ end
20
+
21
+ # Create all subsdirectories
22
+ empty_directory :manifests_directory do |d|
23
+ d.destination = "#{module_name}/manifests"
24
+ end
25
+ empty_directory :files_directory do |d|
26
+ d.destination = "#{module_name}/files"
27
+ end
28
+ empty_directory :templates_directory do |d|
29
+ d.destination = "#{module_name}/templates"
30
+ end
31
+ empty_directory :tests_directory do |d|
32
+ d.destination = "#{module_name}/tests"
33
+ end
34
+ empty_directory :lib_directory do |d|
35
+ d.destination = "#{module_name}/lib/puppet/parser/functions"
36
+ end
37
+ empty_directory :libfacter_directory do |d|
38
+ d.destination = "#{module_name}/lib/facter"
39
+ end
40
+
41
+ template :readme_file do |f|
42
+ f.source = "#{source_root}/README"
43
+ f.destination = "#{module_name}/README"
44
+ end
45
+ template :init_file do |f|
46
+ f.source = "#{source_root}/manifests/init.pp"
47
+ f.destination = "#{module_name}/manifests/init.pp"
48
+ end
49
+ template :testinit_file do |f|
50
+ f.source = "#{source_root}/tests/init.pp"
51
+ f.destination = "#{module_name}/tests/init.pp"
52
+ end
53
+
54
+ end
55
+
56
+ class NodeGenerator < Templater::Generator
57
+ desc <<-DESC
58
+ Generate a basic Puppet node
59
+ DESC
60
+
61
+ first_argument :node_name, :required => true, :desc => "Your node name."
62
+
63
+ def self.source_root
64
+ File.expand_path(File.join(Dir.pwd, 'templates/puppet'))
65
+ end
66
+
67
+ # Create all subsdirectories
68
+ empty_directory :manifests_directory do |d|
69
+ d.destination = "manifests/nodes/"
70
+ end
71
+
72
+ template :node_file do |f|
73
+ f.source = "#{source_root}/manifests/nodes/node.pp"
74
+ f.destination = "manifests/nodes/#{node_name}.pp"
75
+ end
76
+
77
+ end
78
+
79
+ class ClassGenerator < Templater::Generator
80
+ desc <<-DESC
81
+ Create a Puppet class.
82
+ DESC
83
+
84
+ first_argument :module_name, :required => true, :desc => "The module that contains the class"
85
+ second_argument :class_name, :required => true, :desc => "Your class name."
86
+
87
+ def self.source_root
88
+ File.expand_path(File.join(Dir.pwd, 'templates/module'))
89
+ end
90
+
91
+ template :class_file do |f|
92
+ f.source = "#{source_root}/manifests/class.pp"
93
+ f.destination = "#{module_name}/manifests/#{class_name}.pp"
94
+ end
95
+ end
96
+
97
+ class DefineGenerator < Templater::Generator
98
+ desc <<-DESC
99
+ Create a Puppet definition.
100
+ DESC
101
+
102
+ first_argument :module_name, :required => true, :desc => "The module that contains the definition"
103
+ second_argument :define_name, :required => true, :desc => "Your definition name."
104
+
105
+ def self.source_root
106
+ File.expand_path(File.join(Dir.pwd, 'templates/module'))
107
+ end
108
+
109
+ template :class_file do |f|
110
+ f.source = "#{source_root}/manifests/define.pp"
111
+ f.destination = "#{module_name}/manifests/#{define_name}.pp"
112
+ end
113
+ end
114
+
115
+ class FunctionGenerator < Templater::Generator
116
+ desc <<-DESC
117
+ Create a Puppet function.
118
+ DESC
119
+
120
+ first_argument :module_name, :required => true, :desc => "The module that contains the function"
121
+ second_argument :function_name, :required => true, :desc => "Your function name."
122
+ third_argument :type, :required => :true, :default => "statement", :desc => "The type of function."
123
+
124
+ def self.source_root
125
+ File.expand_path(File.join(Dir.pwd, 'templates/function'))
126
+ end
127
+
128
+ # Create all subsdirectories
129
+ empty_directory :lib_directory do |d|
130
+ d.destination = "#{module_name}/lib/puppet/parser/functions"
131
+ end
132
+
133
+ template :function_file do |f|
134
+ f.source = "#{source_root}/function.rb"
135
+ f.destination = "#{module_name}/lib/puppet/parser/functions/#{function_name}.rb"
136
+ end
137
+ end
138
+
139
+ class TypeGenerator < Templater::Generator
140
+ desc <<-DESC
141
+ Create a Puppet type and provider.
142
+ DESC
143
+
144
+ first_argument :module_name, :required => true, :desc => "The module that contains the type"
145
+ second_argument :type_name, :required => true, :desc => "Your type name."
146
+
147
+ def self.source_root
148
+ File.expand_path(File.join(Dir.pwd, 'templates/type'))
149
+ end
150
+
151
+ # Create all subsdirectories
152
+ empty_directory :type_directory do |d|
153
+ d.destination = "#{module_name}/lib/puppet/type"
154
+ end
155
+ empty_directory :provider_directory do |d|
156
+ d.destination = "#{module_name}/lib/puppet/provider/#{type_name}"
157
+ end
158
+
159
+
160
+ template :type_file do |f|
161
+ f.source = "#{source_root}/type.rb"
162
+ f.destination = "#{module_name}/lib/puppet/type/#{type_name}.rb"
163
+ end
164
+ template :provider_file do |f|
165
+ f.source = "#{source_root}/provider.rb"
166
+ f.destination = "#{module_name}/lib/puppet/provider/#{type_name}/#{type_name}.rb"
167
+ end
168
+
169
+ end
170
+
171
+ class PuppetGenerator < Templater::Generator
172
+ desc <<-DESC
173
+ Generate a basic Puppet configuration - specify the location of your Puppet configuration directory, for example /etc/puppet.
174
+ DESC
175
+
176
+ def self.source_root
177
+ File.expand_path(File.join(Dir.pwd, 'templates/puppet'))
178
+ end
179
+
180
+ # Create all subsdirectories
181
+ empty_directory :manifests_directory do |d|
182
+ d.destination = "manifests/nodes"
183
+ end
184
+ empty_directory :files_directory do |d|
185
+ d.destination = "files"
186
+ end
187
+
188
+ template :site_file do |f|
189
+ f.source = "#{source_root}/manifests/site.pp"
190
+ f.destination = "manifests/site.pp"
191
+ end
192
+ file :fileserver_file do |f|
193
+ f.source = "#{source_root}/fileserver.conf"
194
+ f.destination = "fileserver.conf"
195
+ end
196
+ end
197
+
198
+ add :module, ModuleGenerator
199
+ add :node, NodeGenerator
200
+ add :class, ClassGenerator
201
+ add :define, DefineGenerator
202
+ add :function, FunctionGenerator
203
+ add :type, TypeGenerator
204
+ add :puppet, PuppetGenerator
205
+ end
206
+ end
@@ -0,0 +1,4 @@
1
+ # The <%= function_name %> function does ....
2
+ Puppet::Parser::Functions::newfunction(:<%= function_name %>, :type => :<%= type %>, :doc => "Documentation here.") do |vals|
3
+
4
+ end
@@ -0,0 +1,3 @@
1
+ <%= module_name %>
2
+
3
+ This is the <%= module_name %> module.
@@ -0,0 +1,16 @@
1
+ # Class: <%= class_name %>
2
+ #
3
+ # This is the <%= class_name %> in the <%= module_name %> module.
4
+ #
5
+ # Parameters:
6
+ #
7
+ # Actions:
8
+ #
9
+ # Requires:
10
+ #
11
+ # Sample Usage:
12
+ #
13
+ class <%= class_name %> {
14
+
15
+
16
+ }
@@ -0,0 +1,16 @@
1
+ # Definition: <%= define_name %>
2
+ #
3
+ # This is the <%= define_name %> in the <%= module_name %> module.
4
+ #
5
+ # Parameters:
6
+ #
7
+ # Actions:
8
+ #
9
+ # Requires:
10
+ #
11
+ # Sample Usage:
12
+ #
13
+ define <%= define_name %> {
14
+
15
+
16
+ }
@@ -0,0 +1,16 @@
1
+ # Class: <%= module_name %>
2
+ #
3
+ # This module manages <%= module_name %>
4
+ #
5
+ # Parameters:
6
+ #
7
+ # Actions:
8
+ #
9
+ # Requires:
10
+ #
11
+ # Sample Usage:
12
+ #
13
+ class <%= module_name %> {
14
+
15
+
16
+ }
@@ -0,0 +1 @@
1
+ include <%= module_name %>
@@ -0,0 +1,7 @@
1
+ [files]
2
+ path <%= File.expand_path destination_root, 'files' %>
3
+ allow *
4
+
5
+ [plugins]
6
+ path <%= File.expand_path destination_root, 'plugins' %>
7
+ allow *
@@ -0,0 +1,5 @@
1
+ # Node <%= node_name %> Definition
2
+ node '<%= node_name %>' {
3
+
4
+
5
+ }
@@ -0,0 +1,10 @@
1
+ # Site Manifest
2
+
3
+ Exec { path => "/usr/bin:/usr/sbin/:/bin:/sbin:/usr/local/bin:/usr/local/sbin" }
4
+
5
+ File {
6
+ ignore => ['.svn', '.git', 'CVS', '*~' ],
7
+ }
8
+
9
+ import "nodes/*.pp"
10
+
@@ -0,0 +1,11 @@
1
+ [main]
2
+ factpath=$vardir/lib/facter
3
+ pluginsync=true
4
+ color=false
5
+
6
+ # To unable storeconfigs (requires gems sqlite3)
7
+ #
8
+ #[puppetmaster]
9
+ #storeconfigs = true
10
+ #dbadapter = sqlite3
11
+ #dblocation = $vardir/storeconfigs.sqlite
@@ -0,0 +1,3 @@
1
+ Puppet::Type.type(:<%= type_name %>).provide :<%= type_name %> do
2
+ desc "Documentation here"
3
+ end
@@ -0,0 +1,6 @@
1
+ module Puppet
2
+ newtype(:<%= type_name %>) do
3
+ @doc = "Documentation here."
4
+
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scaffold
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - James Turnbull
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-04 00:00:00 +10:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: puppet
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 24
30
+ - 8
31
+ version: 0.24.8
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: templater
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 5
44
+ - 0
45
+ version: 0.5.0
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ description: Scaffold allows you to create basic Puppet configuration, modules, nodes, classes, functions and types.
49
+ email: james@lovedthanlost.net
50
+ executables:
51
+ - scaffold
52
+ extensions: []
53
+
54
+ extra_rdoc_files: []
55
+
56
+ files:
57
+ - TODO.rdoc
58
+ - Rakefile
59
+ - README.rdoc
60
+ - bin/scaffold
61
+ - lib/scaffold/generator.rb
62
+ - lib/scaffold.rb
63
+ - templates/module/tests/init.pp
64
+ - templates/module/manifests/class.pp
65
+ - templates/module/manifests/define.pp
66
+ - templates/module/manifests/init.pp
67
+ - templates/module/README
68
+ - templates/function/function.rb
69
+ - templates/puppet/fileserver.conf
70
+ - templates/puppet/manifests/site.pp
71
+ - templates/puppet/manifests/nodes/node.pp
72
+ - templates/puppet/puppet.conf
73
+ - templates/type/provider.rb
74
+ - templates/type/type.rb
75
+ has_rdoc: true
76
+ homepage: http://github.com/jamtur01/puppet-scaffold
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options:
81
+ - --main
82
+ - README.rdoc
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ segments:
97
+ - 0
98
+ version: "0"
99
+ requirements: []
100
+
101
+ rubyforge_project:
102
+ rubygems_version: 1.3.6
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Scaffold is a templating tool for Puppet
106
+ test_files: []
107
+