puppet-module 0.3.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/CHANGES.markdown +91 -0
- data/LICENSE +17 -0
- data/README.markdown +221 -0
- data/Rakefile +87 -0
- data/VERSION +1 -0
- data/bin/puppet-module +7 -0
- data/lib/puppet/module/tool.rb +124 -0
- data/lib/puppet/module/tool/applications.rb +18 -0
- data/lib/puppet/module/tool/applications/application.rb +83 -0
- data/lib/puppet/module/tool/applications/builder.rb +88 -0
- data/lib/puppet/module/tool/applications/checksummer.rb +38 -0
- data/lib/puppet/module/tool/applications/cleaner.rb +14 -0
- data/lib/puppet/module/tool/applications/freezer.rb +20 -0
- data/lib/puppet/module/tool/applications/generator.rb +117 -0
- data/lib/puppet/module/tool/applications/installer.rb +83 -0
- data/lib/puppet/module/tool/applications/registrar.rb +34 -0
- data/lib/puppet/module/tool/applications/releaser.rb +48 -0
- data/lib/puppet/module/tool/applications/searcher.rb +34 -0
- data/lib/puppet/module/tool/applications/unpacker.rb +69 -0
- data/lib/puppet/module/tool/applications/unreleaser.rb +42 -0
- data/lib/puppet/module/tool/cache.rb +56 -0
- data/lib/puppet/module/tool/checksums.rb +52 -0
- data/lib/puppet/module/tool/cli.rb +127 -0
- data/lib/puppet/module/tool/contents_description.rb +84 -0
- data/lib/puppet/module/tool/dependency.rb +26 -0
- data/lib/puppet/module/tool/metadata.rb +80 -0
- data/lib/puppet/module/tool/modulefile.rb +47 -0
- data/lib/puppet/module/tool/repository.rb +74 -0
- data/lib/puppet/module/tool/skeleton.rb +39 -0
- data/lib/puppet/module/tool/utils.rb +9 -0
- data/lib/puppet/module/tool/utils/interrogation.rb +39 -0
- data/lib/puppet/module/tool/utils/settings.rb +36 -0
- data/lib/puppet/module/tool/utils/uri.rb +16 -0
- data/spec/fixtures/releases/jamtur01-apache/Modulefile +2 -0
- data/spec/fixtures/releases/jamtur01-apache/files/httpd +24 -0
- data/spec/fixtures/releases/jamtur01-apache/files/test.vhost +18 -0
- data/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb +21 -0
- data/spec/fixtures/releases/jamtur01-apache/lib/puppet/type/a2mod.rb +12 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/dev.pp +5 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/init.pp +34 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/params.pp +17 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/php.pp +5 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/ssl.pp +15 -0
- data/spec/fixtures/releases/jamtur01-apache/manifests/vhost.pp +15 -0
- data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -0
- data/spec/fixtures/releases/jamtur01-apache/templates/vhost-default.conf.erb +20 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/apache.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/dev.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/init.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/php.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/ssl.pp +1 -0
- data/spec/fixtures/releases/jamtur01-apache/tests/vhost.pp +2 -0
- data/spec/integration/cli_spec.rb +373 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/output_support.rb +19 -0
- data/spec/support/stub_http_support.rb +14 -0
- data/spec/support/testdir_support.rb +26 -0
- data/spec/unit/application_spec.rb +25 -0
- data/spec/unit/repository_spec.rb +51 -0
- data/templates/generator/Modulefile.erb +5 -0
- data/templates/generator/README.erb +3 -0
- data/templates/generator/files/README.markdown +22 -0
- data/templates/generator/lib/puppet/facter/README.markdown +22 -0
- data/templates/generator/lib/puppet/parser/functions/README.markdown +17 -0
- data/templates/generator/lib/puppet/provider/README.markdown +14 -0
- data/templates/generator/lib/puppet/type/README.markdown +14 -0
- data/templates/generator/manifests/README.markdown +28 -0
- data/templates/generator/manifests/init.pp.erb +17 -0
- data/templates/generator/metadata.json +12 -0
- data/templates/generator/spec/README.markdown +7 -0
- data/templates/generator/spec/spec.opts +6 -0
- data/templates/generator/spec/spec_helper.rb +18 -0
- data/templates/generator/spec/unit/puppet/provider/README.markdown +4 -0
- data/templates/generator/spec/unit/puppet/type/README.markdown +4 -0
- data/templates/generator/templates/README.markdown +23 -0
- data/templates/generator/tests/init.pp.erb +1 -0
- data/vendor/facets-2.8.2-partial/lib/facets/kernel/returning.rb +23 -0
- data/vendor/facets-2.8.2-partial/lib/facets/kernel/tap.rb +39 -0
- data/vendor/multipart-post-1.0/Manifest.txt +9 -0
- data/vendor/multipart-post-1.0/README.txt +61 -0
- data/vendor/multipart-post-1.0/Rakefile +21 -0
- data/vendor/multipart-post-1.0/lib/composite_io.rb +89 -0
- data/vendor/multipart-post-1.0/lib/multipartable.rb +13 -0
- data/vendor/multipart-post-1.0/lib/net/http/post/multipart.rb +27 -0
- data/vendor/multipart-post-1.0/lib/parts.rb +66 -0
- data/vendor/multipart-post-1.0/test/net/http/post/test_multipart.rb +55 -0
- data/vendor/multipart-post-1.0/test/test_composite_io.rb +50 -0
- data/vendor/thor-852190ae/CHANGELOG.rdoc +89 -0
- data/vendor/thor-852190ae/LICENSE +20 -0
- data/vendor/thor-852190ae/README.rdoc +297 -0
- data/vendor/thor-852190ae/REVISION +1 -0
- data/vendor/thor-852190ae/Thorfile +69 -0
- data/vendor/thor-852190ae/bin/rake2thor +86 -0
- data/vendor/thor-852190ae/bin/thor +6 -0
- data/vendor/thor-852190ae/lib/thor.rb +244 -0
- data/vendor/thor-852190ae/lib/thor/actions.rb +275 -0
- data/vendor/thor-852190ae/lib/thor/actions/create_file.rb +103 -0
- data/vendor/thor-852190ae/lib/thor/actions/directory.rb +91 -0
- data/vendor/thor-852190ae/lib/thor/actions/empty_directory.rb +134 -0
- data/vendor/thor-852190ae/lib/thor/actions/file_manipulation.rb +223 -0
- data/vendor/thor-852190ae/lib/thor/actions/inject_into_file.rb +104 -0
- data/vendor/thor-852190ae/lib/thor/base.rb +540 -0
- data/vendor/thor-852190ae/lib/thor/core_ext/file_binary_read.rb +9 -0
- data/vendor/thor-852190ae/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/vendor/thor-852190ae/lib/thor/core_ext/ordered_hash.rb +100 -0
- data/vendor/thor-852190ae/lib/thor/error.rb +30 -0
- data/vendor/thor-852190ae/lib/thor/group.rb +271 -0
- data/vendor/thor-852190ae/lib/thor/invocation.rb +180 -0
- data/vendor/thor-852190ae/lib/thor/parser.rb +4 -0
- data/vendor/thor-852190ae/lib/thor/parser/argument.rb +67 -0
- data/vendor/thor-852190ae/lib/thor/parser/arguments.rb +150 -0
- data/vendor/thor-852190ae/lib/thor/parser/option.rb +128 -0
- data/vendor/thor-852190ae/lib/thor/parser/options.rb +169 -0
- data/vendor/thor-852190ae/lib/thor/rake_compat.rb +66 -0
- data/vendor/thor-852190ae/lib/thor/runner.rb +314 -0
- data/vendor/thor-852190ae/lib/thor/shell.rb +83 -0
- data/vendor/thor-852190ae/lib/thor/shell/basic.rb +239 -0
- data/vendor/thor-852190ae/lib/thor/shell/color.rb +108 -0
- data/vendor/thor-852190ae/lib/thor/task.rb +102 -0
- data/vendor/thor-852190ae/lib/thor/util.rb +230 -0
- data/vendor/thor-852190ae/lib/thor/version.rb +3 -0
- data/vendor/thor-852190ae/spec/actions/create_file_spec.rb +170 -0
- data/vendor/thor-852190ae/spec/actions/directory_spec.rb +131 -0
- data/vendor/thor-852190ae/spec/actions/empty_directory_spec.rb +91 -0
- data/vendor/thor-852190ae/spec/actions/file_manipulation_spec.rb +271 -0
- data/vendor/thor-852190ae/spec/actions/inject_into_file_spec.rb +135 -0
- data/vendor/thor-852190ae/spec/actions_spec.rb +292 -0
- data/vendor/thor-852190ae/spec/base_spec.rb +263 -0
- data/vendor/thor-852190ae/spec/core_ext/hash_with_indifferent_access_spec.rb +43 -0
- data/vendor/thor-852190ae/spec/core_ext/ordered_hash_spec.rb +115 -0
- data/vendor/thor-852190ae/spec/fixtures/application.rb +2 -0
- data/vendor/thor-852190ae/spec/fixtures/bundle/execute.rb +6 -0
- data/vendor/thor-852190ae/spec/fixtures/bundle/main.thor +1 -0
- data/vendor/thor-852190ae/spec/fixtures/doc/%file_name%.rb.tt +1 -0
- data/vendor/thor-852190ae/spec/fixtures/doc/README +3 -0
- data/vendor/thor-852190ae/spec/fixtures/doc/config.rb +1 -0
- data/vendor/thor-852190ae/spec/fixtures/group.thor +83 -0
- data/vendor/thor-852190ae/spec/fixtures/invoke.thor +112 -0
- data/vendor/thor-852190ae/spec/fixtures/script.thor +140 -0
- data/vendor/thor-852190ae/spec/fixtures/task.thor +10 -0
- data/vendor/thor-852190ae/spec/group_spec.rb +171 -0
- data/vendor/thor-852190ae/spec/invocation_spec.rb +107 -0
- data/vendor/thor-852190ae/spec/parser/argument_spec.rb +47 -0
- data/vendor/thor-852190ae/spec/parser/arguments_spec.rb +64 -0
- data/vendor/thor-852190ae/spec/parser/option_spec.rb +202 -0
- data/vendor/thor-852190ae/spec/parser/options_spec.rb +292 -0
- data/vendor/thor-852190ae/spec/rake_compat_spec.rb +68 -0
- data/vendor/thor-852190ae/spec/runner_spec.rb +202 -0
- data/vendor/thor-852190ae/spec/shell/basic_spec.rb +205 -0
- data/vendor/thor-852190ae/spec/shell/color_spec.rb +41 -0
- data/vendor/thor-852190ae/spec/shell_spec.rb +34 -0
- data/vendor/thor-852190ae/spec/spec.opts +1 -0
- data/vendor/thor-852190ae/spec/spec_helper.rb +54 -0
- data/vendor/thor-852190ae/spec/task_spec.rb +69 -0
- data/vendor/thor-852190ae/spec/thor_spec.rb +237 -0
- data/vendor/thor-852190ae/spec/util_spec.rb +167 -0
- data/vendor/thor-852190ae/thor.gemspec +120 -0
- metadata +229 -0
data/spec/spec.opts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
|
+
|
|
4
|
+
require 'spec'
|
|
5
|
+
require 'spec/autorun'
|
|
6
|
+
|
|
7
|
+
require 'puppet/module/tool'
|
|
8
|
+
|
|
9
|
+
Dir[File.join(File.dirname(__FILE__), 'support', '*.rb')].each do |support_file|
|
|
10
|
+
require support_file
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Spec::Runner.configure do |config|
|
|
14
|
+
config.mock_with :mocha
|
|
15
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Return string containing the STDIN and STDOUT output emitted within
|
|
2
|
+
# the +block+.
|
|
3
|
+
def output_for(&block)
|
|
4
|
+
output = StringIO.new
|
|
5
|
+
|
|
6
|
+
stdout_old = $stdout
|
|
7
|
+
stderr_old = $stderr
|
|
8
|
+
|
|
9
|
+
$stdout = output
|
|
10
|
+
$stderr = output
|
|
11
|
+
|
|
12
|
+
block.call
|
|
13
|
+
|
|
14
|
+
output.rewind
|
|
15
|
+
return output.read
|
|
16
|
+
ensure
|
|
17
|
+
$stdout = stdout_old
|
|
18
|
+
$stderr = stderr_old
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
def stub_repository_read(code, body)
|
|
2
|
+
kind = Net::HTTPResponse.send(:response_class, code.to_s)
|
|
3
|
+
response = kind.new('1.0', code.to_s, 'HTTP MESSAGE')
|
|
4
|
+
response.stubs(:read_body).returns(body)
|
|
5
|
+
Puppet::Module::Tool::Repository.any_instance.stubs(:read_contact).returns(response)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def stub_installer_read(body)
|
|
9
|
+
Puppet::Module::Tool::Applications::Installer.any_instance.stubs(:read_match).returns(body)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def stub_cache_read(body)
|
|
13
|
+
Puppet::Module::Tool::Cache.any_instance.stubs(:read_retrieve).returns(body)
|
|
14
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
3
|
+
# Return path to temparory directory for testing.
|
|
4
|
+
def testdir
|
|
5
|
+
return @testdir ||= File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'tmp', 'spec'))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Create a temporary testing directory, change into it, and execute the
|
|
9
|
+
# +block+. When the block exists, remove the test directory and change back
|
|
10
|
+
# to the previous directory.
|
|
11
|
+
def mktestdircd(&block)
|
|
12
|
+
previousdir = Dir.pwd
|
|
13
|
+
rmtestdir
|
|
14
|
+
FileUtils.mkdir_p(testdir)
|
|
15
|
+
Dir.chdir(testdir)
|
|
16
|
+
block.call
|
|
17
|
+
ensure
|
|
18
|
+
rmtestdir
|
|
19
|
+
Dir.chdir previousdir
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Remove the temporary test directory.
|
|
23
|
+
def rmtestdir
|
|
24
|
+
FileUtils.rm_rf(testdir) if File.directory?(testdir)
|
|
25
|
+
end
|
|
26
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe Puppet::Module::Tool::Applications::Application do
|
|
4
|
+
|
|
5
|
+
describe 'inherited classes' do
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@app = Class.new(described_class).new
|
|
9
|
+
Puppet::Module::Tool.stubs(:prepare_settings)
|
|
10
|
+
Puppet.stubs(:settings => {:puppet_module_repository => 'http://fake.modules.site.com'})
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe '#repository' do
|
|
14
|
+
before do
|
|
15
|
+
@url = 'http://fake.com'
|
|
16
|
+
Puppet.settings.expects(:[]).with(:puppet_module_repository).returns(@url)
|
|
17
|
+
end
|
|
18
|
+
it "should use the :puppet_module_repository setting" do
|
|
19
|
+
@app.repository.uri.should == URI.parse(@url)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
|
2
|
+
|
|
3
|
+
describe Puppet::Module::Tool::Repository do
|
|
4
|
+
describe 'instances' do
|
|
5
|
+
before do
|
|
6
|
+
@repository = described_class.new('http://fake.com')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe '#contact' do
|
|
10
|
+
before do
|
|
11
|
+
Net::HTTP.expects(:start)
|
|
12
|
+
end
|
|
13
|
+
context "when not given an :authenticate option" do
|
|
14
|
+
it "should authenticate" do
|
|
15
|
+
@repository.expects(:authenticate).never
|
|
16
|
+
@repository.contact(nil)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
context "when given an :authenticate option" do
|
|
20
|
+
it "should authenticate" do
|
|
21
|
+
@repository.expects(:authenticate)
|
|
22
|
+
@repository.contact(nil, :authenticate => true)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#authenticate' do
|
|
28
|
+
before do
|
|
29
|
+
@request = stub
|
|
30
|
+
@repository.expects(:header)
|
|
31
|
+
@repository.expects(:prompt).twice
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should set basic auth on the request" do
|
|
35
|
+
@request.expects(:basic_auth)
|
|
36
|
+
@repository.authenticate(@request)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe '#retrieve' do
|
|
41
|
+
before do
|
|
42
|
+
@uri = URI.parse('http://some.url.com')
|
|
43
|
+
@repository.cache.expects(:retrieve).with(@uri)
|
|
44
|
+
end
|
|
45
|
+
it "should access the cache" do
|
|
46
|
+
@repository.retrieve(@uri)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Files
|
|
2
|
+
=====
|
|
3
|
+
|
|
4
|
+
Puppet comes with both a client and server for copying files around. The file
|
|
5
|
+
serving function is provided as part of the central Puppet daemon,
|
|
6
|
+
puppetmasterd, and the client function is used through the source attribute of
|
|
7
|
+
file objects. Learn more at
|
|
8
|
+
http://projects.puppetlabs.com/projects/puppet/wiki/File_Serving_Configuration
|
|
9
|
+
|
|
10
|
+
You can use managed files like this:
|
|
11
|
+
|
|
12
|
+
class myclass {
|
|
13
|
+
package { mypackage: ensure => latest }
|
|
14
|
+
service { myservice: ensure => running }
|
|
15
|
+
file { "/etc/myfile":
|
|
16
|
+
source => "puppet://$servername/modules/mymodule/myfile"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
The files are searched for in:
|
|
21
|
+
|
|
22
|
+
$modulepath/mymodule/files/myfile
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Facter
|
|
2
|
+
======
|
|
3
|
+
|
|
4
|
+
Define facts in this directory.
|
|
5
|
+
|
|
6
|
+
Sometimes you need to be able to write conditional expressions based
|
|
7
|
+
on site-specific data that just isn’t available via Facter. The
|
|
8
|
+
solution may be to add a fact to Facter. These additional facts can
|
|
9
|
+
then be distributed to Puppet clients and are available for use in
|
|
10
|
+
manifests. Learn more at
|
|
11
|
+
http://projects.puppetlabs.com/projects/puppet/wiki/Adding_Facts
|
|
12
|
+
|
|
13
|
+
File paths should match the fact name; for example, a fact
|
|
14
|
+
`hardware_platform`, defined like this:
|
|
15
|
+
|
|
16
|
+
Facter.add("hardware_platform") do
|
|
17
|
+
setcode do
|
|
18
|
+
%x{/bin/uname -i}.chomp
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
Should be found in `hardware_platform.rb` in this directory.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Functions
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
Define functions in this directory.
|
|
5
|
+
|
|
6
|
+
File paths should match the function name; for example, a function
|
|
7
|
+
`myfunction`, defined like this:
|
|
8
|
+
|
|
9
|
+
Puppet::Parser::Functions::newfunction(
|
|
10
|
+
:myfunction,
|
|
11
|
+
:type => :statement,
|
|
12
|
+
:doc => "Documentation here."
|
|
13
|
+
) do |vals|
|
|
14
|
+
# ...
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Should be found in `myfunction.rb` in this directory.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Providers
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
Define providers under this directory.
|
|
5
|
+
|
|
6
|
+
File paths should match the resource type name and provider name; for
|
|
7
|
+
example, a provider `myprovider` for a resource type `mytype`, defined like this:
|
|
8
|
+
|
|
9
|
+
Puppet::Type.type(:mytype).provide(:myprovider) do
|
|
10
|
+
desc "Documentation here"
|
|
11
|
+
# ...
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Should be found in `mytype/myprovider.rb` under this directory.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Resource Types
|
|
2
|
+
==============
|
|
3
|
+
|
|
4
|
+
Define resource types in this directory.
|
|
5
|
+
|
|
6
|
+
Filenames should match the resource type name; for example, a resource
|
|
7
|
+
type `mytype`, defined like this:
|
|
8
|
+
|
|
9
|
+
Puppet::Type.newtype(:mytype) do
|
|
10
|
+
@doc = "Documentation here."
|
|
11
|
+
# ...
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Should be found in `mytype.rb`
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Manifests
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
Module manifest files belong in this directory.
|
|
5
|
+
|
|
6
|
+
`init.pp` defines how the module will carry out its tasks in this file.
|
|
7
|
+
|
|
8
|
+
Add additional definitions in this directory. Their file paths should match the
|
|
9
|
+
definition name; for example, a definition `mydefinition`, defined like this:
|
|
10
|
+
|
|
11
|
+
# Definition: mydefinition
|
|
12
|
+
#
|
|
13
|
+
# This is the mydefinition in the mymodule module.
|
|
14
|
+
#
|
|
15
|
+
# Parameters:
|
|
16
|
+
#
|
|
17
|
+
# Actions:
|
|
18
|
+
#
|
|
19
|
+
# Requires:
|
|
20
|
+
#
|
|
21
|
+
# Sample Usage:
|
|
22
|
+
#
|
|
23
|
+
# [Remember: No empty lines between comments and class definition]
|
|
24
|
+
define mydefinition {
|
|
25
|
+
# ...
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Should be found in `mydefinition.pp` in this directory.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Class: <%= metadata.name %>
|
|
2
|
+
#
|
|
3
|
+
# This module manages <%= metadata.name %>
|
|
4
|
+
#
|
|
5
|
+
# Parameters:
|
|
6
|
+
#
|
|
7
|
+
# Actions:
|
|
8
|
+
#
|
|
9
|
+
# Requires:
|
|
10
|
+
#
|
|
11
|
+
# Sample Usage:
|
|
12
|
+
#
|
|
13
|
+
# [Remember: No empty lines between comments and class definition]
|
|
14
|
+
class <%= metadata.name %> {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
+-----------------------------------------------------------------------+
|
|
3
|
+
| |
|
|
4
|
+
| ==> DO NOT EDIT THIS FILE! <== |
|
|
5
|
+
| |
|
|
6
|
+
| You should edit the `Modulefile` and run `puppet-module build` |
|
|
7
|
+
| to generate the `metadata.json` file for your releases. |
|
|
8
|
+
| |
|
|
9
|
+
+-----------------------------------------------------------------------+
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
{}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
dir = Pathname.new(__FILE__).parent
|
|
3
|
+
$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')
|
|
4
|
+
|
|
5
|
+
require 'mocha'
|
|
6
|
+
require 'puppet'
|
|
7
|
+
gem 'rspec', '=1.2.9'
|
|
8
|
+
require 'spec/autorun'
|
|
9
|
+
|
|
10
|
+
Spec::Runner.configure do |config|
|
|
11
|
+
config.mock_with :mocha
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# We need this because the RAL uses 'should' as a method. This
|
|
15
|
+
# allows us the same behaviour but with a different method name.
|
|
16
|
+
class Object
|
|
17
|
+
alias :must :should
|
|
18
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Templates
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
Puppet supports templates and templating via ERB, which is part of the Ruby
|
|
5
|
+
standard library and is used for many other projects including Ruby on Rails.
|
|
6
|
+
Templates allow you to manage the content of template files, for example
|
|
7
|
+
configuration files that cannot yet be managed as a Puppet type. Learn more at
|
|
8
|
+
http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Templating
|
|
9
|
+
|
|
10
|
+
You can use templates like this:
|
|
11
|
+
|
|
12
|
+
class myclass {
|
|
13
|
+
package { mypackage: ensure => latest }
|
|
14
|
+
service { myservice: ensure => running }
|
|
15
|
+
file { "/etc/myfile":
|
|
16
|
+
content => template("mymodule/myfile.erb")
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
The templates are searched for in:
|
|
21
|
+
|
|
22
|
+
$templatedir/mymodule/myfile.erb
|
|
23
|
+
$modulepath/mymodule/templates/myfile.erb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include <%= metadata.name %>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Kernel
|
|
2
|
+
|
|
3
|
+
# A Ruby-ized realization of the K combinator.
|
|
4
|
+
#
|
|
5
|
+
# returning Book.new do |book|
|
|
6
|
+
# book.title = "Imperium"
|
|
7
|
+
# book.author = "Ulick Varange"
|
|
8
|
+
# end
|
|
9
|
+
#
|
|
10
|
+
# Technically, #returning probably should force the return of
|
|
11
|
+
# the stated object irregardless of any return statements that
|
|
12
|
+
# might appear within it's block. This might differentiate
|
|
13
|
+
# #returning from #with, however it also would require
|
|
14
|
+
# implementation in Ruby itself.
|
|
15
|
+
#
|
|
16
|
+
# CREDIT: Mikael Brockman
|
|
17
|
+
|
|
18
|
+
def returning(obj=self) #:yield:
|
|
19
|
+
yield obj
|
|
20
|
+
obj
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Kernel
|
|
2
|
+
|
|
3
|
+
unless method_defined?(:tap) # 1.8.7+
|
|
4
|
+
|
|
5
|
+
# The tap K-Combinator. This yields self -and- returns self.
|
|
6
|
+
#
|
|
7
|
+
# Note, Ruby 1.9+ does not appear to support the zero arity
|
|
8
|
+
# instance_eval option.
|
|
9
|
+
#
|
|
10
|
+
def tap(&b)
|
|
11
|
+
if block_given?
|
|
12
|
+
b.arity == 1 ? yield(self) : instance_eval(&b)
|
|
13
|
+
end
|
|
14
|
+
self
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# == Future definition?
|
|
18
|
+
#
|
|
19
|
+
# This is a consideration for a future #tap using Functor:
|
|
20
|
+
#
|
|
21
|
+
# require 'facets/functor'
|
|
22
|
+
#
|
|
23
|
+
# def tap(&b)
|
|
24
|
+
# if block_given?
|
|
25
|
+
# b.arity == 1 ? yield(self) : instance_eval(&b)
|
|
26
|
+
# self
|
|
27
|
+
# else
|
|
28
|
+
# Functor.new{ |op, *args| self.send(op, *args); self }
|
|
29
|
+
# end
|
|
30
|
+
# end
|
|
31
|
+
#
|
|
32
|
+
# It would allow a single call, before returning the original.
|
|
33
|
+
# However there are not very many useful things you can do with
|
|
34
|
+
# that.
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|