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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Configuration file for the httpd service.
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# The default processing model (MPM) is the process-based
|
|
5
|
+
# 'prefork' model. A thread-based model, 'worker', is also
|
|
6
|
+
# available, but does not work with some modules (such as PHP).
|
|
7
|
+
# The service must be stopped before changing this variable.
|
|
8
|
+
#
|
|
9
|
+
#HTTPD=/usr/sbin/httpd.worker
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# To pass additional options (for instance, -D definitions) to the
|
|
13
|
+
# httpd binary at startup, set OPTIONS here.
|
|
14
|
+
#
|
|
15
|
+
#OPTIONS=
|
|
16
|
+
#OPTIONS=-DDOWN
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
# By default, the httpd process is started in the C locale; to
|
|
20
|
+
# change the locale in which the server runs, the HTTPD_LANG
|
|
21
|
+
# variable can be set.
|
|
22
|
+
#
|
|
23
|
+
#HTTPD_LANG=C
|
|
24
|
+
export SHORTHOST=`hostname -s`
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Test vhost
|
|
3
|
+
#
|
|
4
|
+
NameVirtualHost *:80
|
|
5
|
+
<VirtualHost *:80>
|
|
6
|
+
ServerName testvhost
|
|
7
|
+
DocumentRoot /tmp/testvhost
|
|
8
|
+
<Directory /tmp/testvhost>
|
|
9
|
+
Options Indexes FollowSymLinks MultiViews
|
|
10
|
+
AllowOverride None
|
|
11
|
+
Order allow,deny
|
|
12
|
+
allow from all
|
|
13
|
+
</Directory>
|
|
14
|
+
ErrorLog /var/log/apache2/error.log
|
|
15
|
+
LogLevel warn
|
|
16
|
+
CustomLog /var/log/apache2/access.log combined
|
|
17
|
+
ServerSignature On
|
|
18
|
+
</VirtualHost>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Puppet::Type.type(:a2mod).provide(:debian) do
|
|
2
|
+
desc "Manage Apache 2 modules on Debian-like OSes (e.g. Ubuntu)"
|
|
3
|
+
|
|
4
|
+
commands :encmd => "a2enmod"
|
|
5
|
+
commands :discmd => "a2dismod"
|
|
6
|
+
|
|
7
|
+
defaultfor :operatingsystem => [:debian, :ubuntu]
|
|
8
|
+
|
|
9
|
+
def create
|
|
10
|
+
encmd resource[:name]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def destroy
|
|
14
|
+
discmd resource[:name]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def exists?
|
|
18
|
+
mod= "/etc/apache2/mods-enabled/" + resource[:name] + ".load"
|
|
19
|
+
File.exists?(mod)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# ensure apache is installed
|
|
2
|
+
class apache {
|
|
3
|
+
include apache::params
|
|
4
|
+
package{'httpd':
|
|
5
|
+
name => $apache::params::apache_name,
|
|
6
|
+
ensure => present,
|
|
7
|
+
}
|
|
8
|
+
service { 'httpd':
|
|
9
|
+
name => $apache::params::apache_name,
|
|
10
|
+
ensure => running,
|
|
11
|
+
enable => true,
|
|
12
|
+
subscribe => Package['httpd'],
|
|
13
|
+
}
|
|
14
|
+
#
|
|
15
|
+
# May want to purge all none realize modules using the resources resource type.
|
|
16
|
+
# A2mod resource type is broken. Look into fixing it and moving it into apache.
|
|
17
|
+
#
|
|
18
|
+
A2mod { require => Package['httpd'], notify => Service['httpd']}
|
|
19
|
+
@a2mod {
|
|
20
|
+
'rewrite' : ensure => present;
|
|
21
|
+
'headers' : ensure => present;
|
|
22
|
+
'expires' : ensure => present;
|
|
23
|
+
}
|
|
24
|
+
$vdir = $operatingsystem? {
|
|
25
|
+
'ubuntu' => '/etc/apache2/sites-enabled/',
|
|
26
|
+
default => '/etc/httpd/conf.d',
|
|
27
|
+
}
|
|
28
|
+
file { $vdir:
|
|
29
|
+
ensure => directory,
|
|
30
|
+
recurse => true,
|
|
31
|
+
purge => true,
|
|
32
|
+
notify => Service['httpd'],
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class apache::params{
|
|
2
|
+
$user = 'www-data'
|
|
3
|
+
$group = 'www-data'
|
|
4
|
+
|
|
5
|
+
case $operatingsystem {
|
|
6
|
+
"centos": {
|
|
7
|
+
$apache_name = httpd
|
|
8
|
+
$ssl_package = mod_ssl
|
|
9
|
+
$apache_dev = httpd-devel
|
|
10
|
+
}
|
|
11
|
+
"ubuntu": {
|
|
12
|
+
$apache_name = apache2
|
|
13
|
+
$ssl_package = apache-ssl
|
|
14
|
+
$apache_dev = [ libaprutil1-dev, libapr1-dev, apache2-prefork-dev ]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
define apache::vhost( $port, $docroot, $ssl=true, $template='apache/vhost-default.conf.erb', $priority, $serveraliases = '' ) {
|
|
2
|
+
include apache
|
|
3
|
+
$vdir = $operatingsystem? {
|
|
4
|
+
'ubuntu' => '/etc/apache2/sites-enabled/',
|
|
5
|
+
default => '/etc/httpd/conf.d',
|
|
6
|
+
}
|
|
7
|
+
file{"${vdir}/${priority}-${name}":
|
|
8
|
+
content => template($template),
|
|
9
|
+
owner => 'root',
|
|
10
|
+
group => 'root',
|
|
11
|
+
mode => '777',
|
|
12
|
+
require => Package['httpd'],
|
|
13
|
+
notify => Service['httpd'],
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"dependencies":[],"types":[{"providers":[{"name":"a2mod","doc":"Manage Apache 2 modules on Debian and Ubuntu Required binaries: ``a2enmod``, ``a2dismod``. Default for ``operatingsystem`` == ``debianubuntu``. "}],"parameters":[{"name":"name","doc":"The name of the module to be managed"}],"properties":[{"name":"ensure","doc":"The basic property that the resource should be in. Valid values are ``present``, ``absent``."}],"name":"a2mod","doc":"Manage Apache 2 modules on Debian and Ubuntu"}],"checksums":{"manifests/params.pp":"71734796921dbdbfd58f503622527616","tests/ssl.pp":"191912535199531fd631f911c6329e56","tests/vhost.pp":"1b91e03c8ef89a7ecb6793831ac18399","manifests/php.pp":"b78cc593f1c4cd800c906e0891c9b11f","files/httpd":"295f5e924afe6f752d29327e73fe6d0a","tests/php.pp":"ce7bb9eef69d32b42a32ce32d9653625","lib/puppet/provider/a2mod/a2mod.rb":"18c5bb180b75a2375e95e07f88a94257","files/test.vhost":"0602022c19a7b6b289f218c7b93c1aea","manifests/ssl.pp":"b4334a161a2ba5fa8a62cf7b38f352c8","manifests/dev.pp":"510813942246cc9a7786d8f2d8874a35","manifests/vhost.pp":"cbc4657b0cce5cd432057393d5f6b0c2","tests/init.pp":"4eac4a7ef68499854c54a78879e25535","lib/puppet/type/a2mod.rb":"0e1b4843431413a10320ac1f6a055d15","tests/apache.pp":"4eac4a7ef68499854c54a78879e25535","tests/dev.pp":"4cf15c1fecea3ca86009f182b402c7ab","templates/vhost-default.conf.erb":"9055aed946e1111c30ab81fedac2c8b0","manifests/init.pp":"dc503e26e8021351078813b541c4bd3d","Modulefile":"d43334b4072cd1744121b3b25cd9ed15"},"version":"0.0.1","name":"jamtur01-apache"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
NameVirtualHost *:<%= port %>
|
|
2
|
+
<VirtualHost *:<%= port %>>
|
|
3
|
+
ServerName <%= name %>
|
|
4
|
+
<%if serveraliases.is_a? Array -%>
|
|
5
|
+
<% serveraliases.each do |name| -%><%= " ServerAlias #{name}\n" %><% end -%>
|
|
6
|
+
<% elsif serveraliases != '' -%>
|
|
7
|
+
<%= " ServerAlias #{serveraliases}" -%>
|
|
8
|
+
<% end -%>
|
|
9
|
+
DocumentRoot <%= docroot %>
|
|
10
|
+
<Directory <%= docroot %>>
|
|
11
|
+
Options Indexes FollowSymLinks MultiViews
|
|
12
|
+
AllowOverride None
|
|
13
|
+
Order allow,deny
|
|
14
|
+
allow from all
|
|
15
|
+
</Directory>
|
|
16
|
+
ErrorLog /var/log/apache2/<%= name %>_error.log
|
|
17
|
+
LogLevel warn
|
|
18
|
+
CustomLog /var/log/apache2/<%= name %>_access.log combined
|
|
19
|
+
ServerSignature On
|
|
20
|
+
</VirtualHost>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include apache
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include apache::dev
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include apache
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include apache::php
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include apache::ssl
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
|
2
|
+
|
|
3
|
+
# Directory that contains sample releases.
|
|
4
|
+
RELEASE_FIXTURES_DIR = File.join(File.dirname(File.expand_path(__FILE__)), "..", "fixtures", "releases")
|
|
5
|
+
|
|
6
|
+
# Return the pathname string to the directory containing the release fixture called +name+.
|
|
7
|
+
def release_fixture(name)
|
|
8
|
+
return File.join(RELEASE_FIXTURES_DIR, name)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Copy the release fixture called +name+ into the current working directory.
|
|
12
|
+
def install_release_fixture(name)
|
|
13
|
+
release_fixture(name)
|
|
14
|
+
FileUtils.cp_r(release_fixture(name), name)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe "cli" do
|
|
18
|
+
# Return STDOUT and STDERR output generated from +block+ as it's run within a temporary test directory.
|
|
19
|
+
def run(&block)
|
|
20
|
+
return output_for do
|
|
21
|
+
mktestdircd do
|
|
22
|
+
block.call
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def app
|
|
28
|
+
return Puppet::Module::Tool::CLI.new
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
before :all do
|
|
32
|
+
Puppet::Module::Tool.prepare_settings
|
|
33
|
+
|
|
34
|
+
@username = "myuser"
|
|
35
|
+
@module_name = "mymodule"
|
|
36
|
+
@full_name = "#{@username}-#{@module_name}"
|
|
37
|
+
@version = "0.0.1"
|
|
38
|
+
@release_name = "#{@full_name}-#{@version}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
before :each do
|
|
42
|
+
Puppet::Module::Tool::Cache.clean
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
after :each do
|
|
46
|
+
Puppet::Module::Tool::Cache.clean
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe "version" do
|
|
50
|
+
it "should display a version" do
|
|
51
|
+
run do
|
|
52
|
+
app.version
|
|
53
|
+
end.should =~ /#{Puppet::Module::Tool.version}/
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "generate" do
|
|
58
|
+
it "should generate a module if given a dashed name" do
|
|
59
|
+
run do
|
|
60
|
+
app.generate(@full_name)
|
|
61
|
+
|
|
62
|
+
File.directory?(@full_name).should == true
|
|
63
|
+
modulefile = File.join(@full_name, "Modulefile")
|
|
64
|
+
File.file?(modulefile).should == true
|
|
65
|
+
metadata = Puppet::Module::Tool::Metadata.new
|
|
66
|
+
Puppet::Module::Tool::Modulefile.evaluate(metadata, modulefile)
|
|
67
|
+
metadata.full_name.should == @full_name
|
|
68
|
+
metadata.username.should == @username
|
|
69
|
+
metadata.name.should == @module_name
|
|
70
|
+
end.should =~ /Generating module/
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should fail if given an undashed name" do
|
|
74
|
+
run do
|
|
75
|
+
lambda { app.generate("invalid") }.should raise_error(SystemExit)
|
|
76
|
+
end.should =~ /Could not generate directory "invalid", you must specify a dash-separated username and module name./
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "should fail if directory already exists" do
|
|
80
|
+
run do
|
|
81
|
+
app.generate(@full_name)
|
|
82
|
+
lambda { app.generate(@full_name) }.should raise_error(SystemExit)
|
|
83
|
+
end.should =~ /already exists/
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe "build" do
|
|
88
|
+
it "should build a module in a directory" do
|
|
89
|
+
run do
|
|
90
|
+
app.generate(@full_name)
|
|
91
|
+
app.build(@full_name)
|
|
92
|
+
|
|
93
|
+
File.directory?(File.join(@full_name, "pkg", @release_name)).should == true
|
|
94
|
+
File.file?(File.join(@full_name, "pkg", @release_name + ".tar.gz")).should == true
|
|
95
|
+
metadata_file = File.join(@full_name, "pkg", @release_name, "metadata.json")
|
|
96
|
+
File.file?(metadata_file).should == true
|
|
97
|
+
metadata = PSON.parse(File.read(metadata_file))
|
|
98
|
+
metadata["name"].should == @full_name
|
|
99
|
+
metadata["version"].should == @version
|
|
100
|
+
metadata["checksums"].should be_a_kind_of(Hash)
|
|
101
|
+
metadata["dependencies"].should == []
|
|
102
|
+
metadata["types"].should == []
|
|
103
|
+
end.should =~ /Building.+Built/m
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "should build a module's checksums" do
|
|
107
|
+
run do
|
|
108
|
+
app.generate(@full_name)
|
|
109
|
+
app.build(@full_name)
|
|
110
|
+
|
|
111
|
+
metadata_file = File.join(@full_name, "pkg", @release_name, "metadata.json")
|
|
112
|
+
metadata = PSON.parse(File.read(metadata_file))
|
|
113
|
+
metadata["checksums"].should be_a_kind_of(Hash)
|
|
114
|
+
|
|
115
|
+
modulefile_path = Pathname.new(File.join(@full_name, "Modulefile"))
|
|
116
|
+
metadata["checksums"]["Modulefile"].should == Digest::MD5.hexdigest(modulefile_path.read)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "should build a module's types and providers" do
|
|
121
|
+
run do
|
|
122
|
+
name = "jamtur01-apache"
|
|
123
|
+
install_release_fixture name
|
|
124
|
+
app.build(name)
|
|
125
|
+
|
|
126
|
+
metadata_file = File.join(name, "pkg", "#{name}-0.0.1", "metadata.json")
|
|
127
|
+
metadata = PSON.parse(File.read(metadata_file))
|
|
128
|
+
|
|
129
|
+
metadata["types"].size.should == 1
|
|
130
|
+
type = metadata["types"].first
|
|
131
|
+
type["name"].should == "a2mod"
|
|
132
|
+
type["doc"].should == "Manage Apache 2 modules"
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
type["parameters"].size.should == 1
|
|
136
|
+
type["parameters"].first.tap do |o|
|
|
137
|
+
o["name"].should == "name"
|
|
138
|
+
o["doc"].should == "The name of the module to be managed"
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
type["properties"].size.should == 1
|
|
142
|
+
type["properties"].first.tap do |o|
|
|
143
|
+
o["name"].should == "ensure"
|
|
144
|
+
o["doc"].should =~ /present.+absent/
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
type["providers"].size.should == 1
|
|
148
|
+
type["providers"].first.tap do |o|
|
|
149
|
+
o["name"].should == "debian"
|
|
150
|
+
o["doc"].should =~ /Manage Apache 2 modules on Debian-like OSes/
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "should build a module's dependencies" do
|
|
156
|
+
run do
|
|
157
|
+
app.generate(@full_name)
|
|
158
|
+
modulefile = File.join(@full_name, "Modulefile")
|
|
159
|
+
|
|
160
|
+
dependency1_name = "anotheruser-anothermodule"
|
|
161
|
+
dependency1_requirement = ">= 1.2.3"
|
|
162
|
+
dependency2_name = "someuser-somemodule"
|
|
163
|
+
dependency2_requirement = "4.2"
|
|
164
|
+
dependency2_repository = "http://some.repo"
|
|
165
|
+
|
|
166
|
+
File.open(modulefile, "a") do |handle|
|
|
167
|
+
handle.puts "dependency '#{dependency1_name}', '#{dependency1_requirement}'"
|
|
168
|
+
handle.puts "dependency '#{dependency2_name}', '#{dependency2_requirement}', '#{dependency2_repository}'"
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
app.build(@full_name)
|
|
172
|
+
|
|
173
|
+
metadata_file = File.join(@full_name, "pkg", "#{@full_name}-#{@version}", "metadata.json")
|
|
174
|
+
metadata = PSON.parse(File.read(metadata_file))
|
|
175
|
+
|
|
176
|
+
metadata['dependencies'].size.should == 2
|
|
177
|
+
metadata['dependencies'].sort_by{|t| t['name']}.tap do |dependencies|
|
|
178
|
+
dependencies[0].tap do |dependency1|
|
|
179
|
+
dependency1['name'].should == dependency1_name
|
|
180
|
+
dependency1['version_requirement'].should == dependency1_requirement
|
|
181
|
+
dependency1['repository'].should be_nil
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
dependencies[1].tap do |dependency2|
|
|
185
|
+
dependency2['name'].should == dependency2_name
|
|
186
|
+
dependency2['version_requirement'].should == dependency2_requirement
|
|
187
|
+
dependency2['repository'].should == dependency2_repository
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
it "should rebuild a module in a directory" do
|
|
195
|
+
run do
|
|
196
|
+
app.generate(@full_name)
|
|
197
|
+
app.build(@full_name)
|
|
198
|
+
app.build(@full_name)
|
|
199
|
+
end.should =~ /Building.+Built.+Building.+Built/m
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it "should build a module in the current directory" do
|
|
203
|
+
run do
|
|
204
|
+
app.generate(@full_name)
|
|
205
|
+
Dir.chdir(@full_name)
|
|
206
|
+
app.build
|
|
207
|
+
|
|
208
|
+
File.file?(File.join("pkg", @release_name + ".tar.gz")).should == true
|
|
209
|
+
end.should =~ /Building.+Built/m
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it "should fail to build a module without a Modulefile" do
|
|
213
|
+
run do
|
|
214
|
+
app.generate(@full_name)
|
|
215
|
+
FileUtils.rm(File.join(@full_name, "Modulefile"))
|
|
216
|
+
|
|
217
|
+
lambda { app.build(@full_name) }.should raise_error(SystemExit)
|
|
218
|
+
end.should =~ /Could not find a valid module at "#{@full_name}"/
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
it "should fail to build a module directory that doesn't exist" do
|
|
222
|
+
run do
|
|
223
|
+
lambda { app.build(@full_name) }.should raise_error(SystemExit)
|
|
224
|
+
end.should =~ /Could not find a valid module at "#{@full_name}"/
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
it "should fail to build a module in the current directory that's not a module" do
|
|
228
|
+
run do
|
|
229
|
+
lambda { app.build }.should raise_error(SystemExit)
|
|
230
|
+
end.should =~ /Could not find a valid module at current directory/
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
describe "search" do
|
|
235
|
+
it "should display matching modules" do
|
|
236
|
+
run do
|
|
237
|
+
stub_repository_read 200, <<-HERE
|
|
238
|
+
[
|
|
239
|
+
{"full_name": "cli", "version": "1.0"},
|
|
240
|
+
{"full_name": "web", "version": "2.0"}
|
|
241
|
+
]
|
|
242
|
+
HERE
|
|
243
|
+
app.search("mymodule")
|
|
244
|
+
end.should =~ /2 found.+cli.+1\.0.+web.+2\.0/m
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
it "should display no matches" do
|
|
248
|
+
run do
|
|
249
|
+
stub_repository_read 200, "[]"
|
|
250
|
+
app.search("mymodule")
|
|
251
|
+
end.should =~ /0 found/m
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
it "should fail if can't get a connection" do
|
|
255
|
+
run do
|
|
256
|
+
stub_repository_read 500, "OH NOES!!1!"
|
|
257
|
+
app.search("mymodule")
|
|
258
|
+
end.should =~ /Could not execute search.+HTTP 500/m
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
describe "install" do
|
|
263
|
+
it "should install a module from a filesystem path" do
|
|
264
|
+
run do
|
|
265
|
+
app.generate(@full_name)
|
|
266
|
+
app.build(@full_name)
|
|
267
|
+
|
|
268
|
+
FileUtils.mv("#{@full_name}/pkg/#{@release_name}.tar.gz", "#{@release_name}.tar.gz")
|
|
269
|
+
FileUtils.rm_rf(@full_name)
|
|
270
|
+
|
|
271
|
+
app.install("#{@release_name}.tar.gz")
|
|
272
|
+
|
|
273
|
+
File.directory?(@full_name).should == true
|
|
274
|
+
File.file?(File.join(@full_name, 'metadata.json')).should == true
|
|
275
|
+
end.should =~ /Installed "myuser-mymodule-0.0.1" into directory: myuser-mymodule/
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
it "should install a module from a webserver URL" do
|
|
279
|
+
run do
|
|
280
|
+
app.generate(@full_name)
|
|
281
|
+
app.build(@full_name)
|
|
282
|
+
|
|
283
|
+
stub_cache_read File.read("#{@full_name}/pkg/#{@release_name}.tar.gz")
|
|
284
|
+
FileUtils.rm_rf(@full_name)
|
|
285
|
+
|
|
286
|
+
stub_installer_read <<-HERE
|
|
287
|
+
{"file": "/foo/bar/#{@release_name}.tar.gz", "version": "#{@version}"}
|
|
288
|
+
HERE
|
|
289
|
+
|
|
290
|
+
app.install(@full_name)
|
|
291
|
+
|
|
292
|
+
File.directory?(@full_name).should == true
|
|
293
|
+
File.file?(File.join(@full_name, 'metadata.json')).should == true
|
|
294
|
+
end.should =~ /Installed #{@release_name.inspect} into directory: #{@full_name}/
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
it "should install a module from a webserver URL using a version requirement" # TODO
|
|
298
|
+
|
|
299
|
+
it "should fail if module isn't a slashed name" do
|
|
300
|
+
run do
|
|
301
|
+
lambda { app.install("invalid") }.should raise_error(SystemExit)
|
|
302
|
+
end.should =~ /Could not install module with invalid name/
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
it "should fail if module doesn't exist on webserver" do
|
|
306
|
+
run do
|
|
307
|
+
stub_installer_read "{}"
|
|
308
|
+
lambda { app.install("not-found") }.should raise_error(SystemExit)
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
it "should fail gracefully when receiving invalid PSON" do
|
|
313
|
+
pending "Implement PSON error wrapper" # TODO
|
|
314
|
+
run do
|
|
315
|
+
stub_installer_read "1/0"
|
|
316
|
+
lambda { app.install("not-found") }.should raise_error(SystemExit)
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
it "should fail if installing a module that's already installed" do
|
|
321
|
+
run do
|
|
322
|
+
name = "myuser-mymodule"
|
|
323
|
+
Dir.mkdir name
|
|
324
|
+
lambda { app.install(name) }.should raise_error(SystemExit)
|
|
325
|
+
end.should =~ /already installed/
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
describe "clean" do
|
|
331
|
+
it "should clean cache" do
|
|
332
|
+
run do
|
|
333
|
+
app.generate(@full_name)
|
|
334
|
+
app.build(@full_name)
|
|
335
|
+
FileUtils.mv("#{@full_name}/pkg/#{@release_name}.tar.gz", "#{@release_name}.tar.gz")
|
|
336
|
+
FileUtils.rm_rf(@full_name)
|
|
337
|
+
app.install("#{@release_name}.tar.gz")
|
|
338
|
+
|
|
339
|
+
Puppet::Module::Tool::Cache.base_path.directory?.should == true
|
|
340
|
+
|
|
341
|
+
app.clean
|
|
342
|
+
|
|
343
|
+
Puppet::Module::Tool::Cache.base_path.directory?.should == false
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
describe "changes" do
|
|
349
|
+
it "should display changes" do
|
|
350
|
+
run do
|
|
351
|
+
app.generate(@full_name)
|
|
352
|
+
app.build(@full_name)
|
|
353
|
+
Dir.chdir("#{@full_name}/pkg/#{@release_name}")
|
|
354
|
+
File.open("Modulefile", "a") do |handle|
|
|
355
|
+
handle.puts
|
|
356
|
+
handle.puts "# Added"
|
|
357
|
+
end
|
|
358
|
+
puts "CHANGES:"
|
|
359
|
+
app.changes(".")
|
|
360
|
+
end.should =~ /CHANGES:.+Modulefile\s*\z/m
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
describe "repository" do
|
|
365
|
+
it "should display repository" do
|
|
366
|
+
run do
|
|
367
|
+
# TODO How to avoid accessing "~/.puppet/puppet.conf" without stubbing parts we want to exercise?
|
|
368
|
+
app.repository
|
|
369
|
+
end.should =~ %r{http://}
|
|
370
|
+
end
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
end
|