diff --git a/README.md b/README.md index d1867bb5e7..f9ddd8dfc2 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,21 @@ Phraseanet 3.9 - Digital Asset Management application https://docs.phraseanet.com/ -#Installation +#Installation : You **must** not download the source from GitHub, but download a packaged version here : -https://sourceforge.net/projects/phraseanet/files/ +https://www.phraseanet.com/download/ And follow the install steps described at https://docs.phraseanet.com/Admin/ -#License +#Developement : + +For development purpose Phraseanet is shipped with ready to use development environments using vagrant. + +See https://docs.phraseanet.com/Devel/ + +#License : Phraseanet is licensed under GPL-v3 license. diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000000..6f032f4d2b --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,242 @@ +require 'yaml' + +root = File.dirname(File.expand_path(__FILE__)) + +Vagrant.configure("2") do |config| + Dir.glob(root+"/vagrant/vms/**/puphpet/config.yaml").each do|f| + dir = File.dirname(File.expand_path(f)+"/..") + base_path = dir[0..-21] + configValues = YAML.load_file(f) + data = configValues['vagrantfile-local'] + + config.vm.define "vm-#{data['name']}" do |node| + node.vm.box = "#{data['vm']['box']}" + node.vm.box_url = "#{data['vm']['box_url']}" + + if data['vm']['hostname'].to_s.strip.length != 0 + node.vm.hostname = "#{data['vm']['hostname']}" + end + + node.vm.provider :virtualbox do |vb| + vb.name = "#{data['name']}" + end + + if data['vm']['network']['private_network'].to_s != '' + node.vm.network "private_network", ip: "#{data['vm']['network']['private_network']}" + end + + data['vm']['network']['forwarded_port'].each do |i, port| + + if port['guest'] != '' && port['host'] != '' + node.vm.network :forwarded_port, guest: port['guest'].to_i, host: port['host'].to_i + end + end + + if Vagrant.has_plugin?('vagrant-hostsupdater') + hosts = Array.new() + + if !configValues['apache']['install'].nil? && + configValues['apache']['install'].to_i == 1 && + configValues['apache']['vhosts'].is_a?(Hash) + configValues['apache']['vhosts'].each do |i, vhost| + hosts.push(vhost['servername']) + + if vhost['serveraliases'].is_a?(Array) + vhost['serveraliases'].each do |vhost_alias| + hosts.push(vhost_alias) + end + end + end + elsif !configValues['nginx']['install'].nil? && + configValues['nginx']['install'].to_i == 1 && + configValues['nginx']['vhosts'].is_a?(Hash) + configValues['nginx']['vhosts'].each do |i, vhost| + hosts.push(vhost['server_name']) + + if vhost['server_aliases'].is_a?(Array) + vhost['server_aliases'].each do |x, vhost_alias| + hosts.push(vhost_alias) + end + end + end + end + + if hosts.any? + contents = File.open("#{dir}/puphpet/shell/hostsupdater-notice.txt", 'r'){ |file| file.read } + puts "\n\033[34m#{contents}\033[0m\n" + + if node.vm.hostname.to_s.strip.length == 0 + node.vm.hostname = 'puphpet-dev-machine' + end + + node.hostsupdater.aliases = hosts + end + end + + data['vm']['synced_folder'].each do |i, folder| + if folder['source'] == '' + folder['source'] = root + end + if folder['source'] != '' && folder['target'] != '' + if folder['sync_type'] == 'nfs' + node.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}", type: "nfs" + elsif folder['sync_type'] == 'smb' + node.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}", type: "smb" + elsif folder['sync_type'] == 'rsync' + rsync_args = !folder['rsync']['args'].nil? ? folder['rsync']['args'] : ["--verbose", "--archive", "--delete", "-z"] + rsync_auto = !folder['rsync']['auto'].nil? ? folder['rsync']['auto'] : true + rsync_exclude = !folder['rsync']['exclude'].nil? ? folder['rsync']['exclude'] : [".vagrant/"] + + node.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}", + rsync__args: rsync_args, rsync__exclude: rsync_exclude, rsync__auto: rsync_auto, type: "rsync" + else + node.vm.synced_folder "#{folder['source']}", "#{folder['target']}", id: "#{i}", + group: 'www-data', owner: 'www-data', mount_options: ["dmode=775", "fmode=764"] + end + end + end + + node.vm.usable_port_range = (10200..10500) + + if data['vm']['chosen_provider'].empty? || data['vm']['chosen_provider'] == "virtualbox" + ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox' + + node.vm.provider :virtualbox do |virtualbox| + data['vm']['provider']['virtualbox']['modifyvm'].each do |key, value| + if key == "memory" + next + end + + if key == "natdnshostresolver1" + value = value ? "on" : "off" + end + + virtualbox.customize ["modifyvm", :id, "--#{key}", "#{value}"] + end + + virtualbox.customize ["modifyvm", :id, "--memory", "#{data['vm']['memory']}"] + + if data['vm']['hostname'].to_s.strip.length != 0 + virtualbox.customize ["modifyvm", :id, "--name", node.vm.hostname] + end + end + end + + if data['vm']['chosen_provider'] == "vmware_fusion" || data['vm']['chosen_provider'] == "vmware_workstation" + ENV['VAGRANT_DEFAULT_PROVIDER'] = (data['vm']['chosen_provider'] == "vmware_fusion") ? "vmware_fusion" : "vmware_workstation" + + node.vm.provider "vmware_fusion" do |v| + data['vm']['provider']['vmware'].each do |key, value| + if key == "memsize" + next + end + + v.vmx["#{key}"] = "#{value}" + end + + v.vmx["memsize"] = "#{data['vm']['memory']}" + + if data['vm']['hostname'].to_s.strip.length != 0 + v.vmx["displayName"] = node.vm.hostname + end + end + end + + if data['vm']['chosen_provider'] == "parallels" + ENV['VAGRANT_DEFAULT_PROVIDER'] = "parallels" + + node.vm.provider "parallels" do |v| + data['vm']['provider']['parallels'].each do |key, value| + if key == "memsize" + next + end + + v.customize ["set", :id, "--#{key}", "#{value}"] + end + + v.memory = "#{data['vm']['memory']}" + + if data['vm']['hostname'].to_s.strip.length != 0 + v.name = node.vm.hostname + end + end + end + + ssh_username = !data['ssh']['username'].nil? ? data['ssh']['username'] : "vagrant" + + node.vm.provision "shell" do |s| + s.path = "#{base_path}/puphpet/shell/initial-setup.sh" + s.args = "/vagrant/vagrant/vms/#{data['name']}/puphpet" + end + + node.vm.provision "shell" do |kg| + kg.path = "#{base_path}/puphpet/shell/ssh-keygen.sh" + kg.args = "#{ssh_username}" + end + + node.vm.provision :shell, :path => "#{base_path}/puphpet/shell/update-puppet.sh" + + node.vm.provision :puppet do |puppet| + puppet.facter = { + "ssh_username" => "#{ssh_username}", + "provisioner_type" => ENV['VAGRANT_DEFAULT_PROVIDER'], + "vm_target_key" => 'vagrantfile-local', + } + puppet.manifests_path = "#{data['vm']['provision']['puppet']['manifests_path']}" + puppet.manifest_file = "#{data['vm']['provision']['puppet']['manifest_file']}" + puppet.module_path = "#{data['vm']['provision']['puppet']['module_path']}" + + if !data['vm']['provision']['puppet']['options'].empty? + puppet.options = data['vm']['provision']['puppet']['options'] + end + end + + node.vm.provision :shell do |s| + s.path = "#{base_path}/puphpet/shell/execute-files.sh" + s.args = ["exec-once", "exec-always"] + end + + node.vm.provision :shell, run: "always" do |s| + s.path = "#{base_path}/puphpet/shell/execute-files.sh" + s.args = ["startup-once", "startup-always"] + end + + node.vm.provision :shell, :path => "#{base_path}/puphpet/shell/important-notices.sh" + + if File.file?("#{dir}/puphpet/files/dot/ssh/id_rsa") + node.ssh.private_key_path = [ + "#{dir}/puphpet/files/dot/ssh/id_rsa", + "#{dir}/puphpet/files/dot/ssh/insecure_private_key" + ] + end + + if !data['ssh']['host'].nil? + node.ssh.host = "#{data['ssh']['host']}" + end + if !data['ssh']['port'].nil? + node.ssh.port = "#{data['ssh']['port']}" + end + if !data['ssh']['username'].nil? + node.ssh.username = "#{data['ssh']['username']}" + end + if !data['ssh']['guest_port'].nil? + node.ssh.guest_port = data['ssh']['guest_port'] + end + if !data['ssh']['shell'].nil? + node.ssh.shell = "#{data['ssh']['shell']}" + end + if !data['ssh']['keep_alive'].nil? + node.ssh.keep_alive = data['ssh']['keep_alive'] + end + if !data['ssh']['forward_agent'].nil? + node.ssh.forward_agent = data['ssh']['forward_agent'] + end + if !data['ssh']['forward_x11'].nil? + node.ssh.forward_x11 = data['ssh']['forward_x11'] + end + if !data['vagrant']['host'].nil? + node.vagrant.host = data['vagrant']['host'].gsub(":", "").intern + end + end + end +end diff --git a/composer.json b/composer.json index 85045aae1b..c8c16c6315 100644 --- a/composer.json +++ b/composer.json @@ -80,7 +80,8 @@ "twig/extensions" : "~1.0", "vierbergenlars/php-semver" : "~2.1", "zend/gdata" : "~1.12.1", - "doctrine/migrations" : "1.0.x-dev@dev" + "doctrine/migrations" : "1.0.x-dev@dev", + willdurand/negotiation" : "~1.3" }, "require-dev": { "phpunit/phpunit" : "~3.7", diff --git a/composer.lock b/composer.lock index 6fb4c4c5ee..075d170e0a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ec7feed650089f0abf08f741e3ee9768", + "hash": "81820d7853d2c85cbb34fc57910d6963", "packages": [ { "name": "alchemy-fr/tcpdf-clone", @@ -3985,6 +3985,56 @@ ], "time": "2013-09-20 10:41:27" }, + { + "name": "willdurand/negotiation", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/willdurand/Negotiation.git", + "reference": "a98fb6b9808610c1aa326c736893d3d77d9383b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/willdurand/Negotiation/zipball/a98fb6b9808610c1aa326c736893d3d77d9383b6", + "reference": "a98fb6b9808610c1aa326c736893d3d77d9383b6", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-0": { + "Negotiation": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com", + "homepage": "http://www.willdurand.fr" + } + ], + "description": "Content Negotiation tools for PHP provided as a standalone library.", + "homepage": "http://williamdurand.fr/Negotiation/", + "keywords": [ + "accept", + "content", + "format", + "header", + "negotiation" + ], + "time": "2014-05-16 12:34:51" + }, { "name": "zend/gdata", "version": "1.12.1", @@ -4942,6 +4992,7 @@ "behat/behat": 20, "behat/gherkin": 20 }, + "prefer-stable": false, "platform": { "php": ">=5.4" }, diff --git a/config/configuration.sample.yml b/config/configuration.sample.yml index 1cd3d7c1f7..f6a428e80c 100644 --- a/config/configuration.sample.yml +++ b/config/configuration.sample.yml @@ -31,6 +31,7 @@ main: options: [] task-manager: status: started + enabled: true logger: max-files: 10 enabled: true diff --git a/lib/Alchemy/Phrasea/Application.php b/lib/Alchemy/Phrasea/Application.php index fe22798f42..09d128f0b2 100644 --- a/lib/Alchemy/Phrasea/Application.php +++ b/lib/Alchemy/Phrasea/Application.php @@ -83,6 +83,7 @@ use Alchemy\Phrasea\Core\Provider\CacheServiceProvider; use Alchemy\Phrasea\Core\Provider\CacheConnectionServiceProvider; use Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider; use Alchemy\Phrasea\Core\Provider\ConfigurationTesterServiceProvider; +use Alchemy\Phrasea\Core\Provider\ContentNegotiationServiceProvider; use Alchemy\Phrasea\Core\Provider\CSVServiceProvider; use Alchemy\Phrasea\Core\Provider\ConvertersServiceProvider; use Alchemy\Phrasea\Core\Provider\FileServeServiceProvider; @@ -374,6 +375,7 @@ class Application extends SilexApplication $this->register(new ManipulatorServiceProvider()); $this->register(new PluginServiceProvider()); $this->register(new PhraseaEventServiceProvider()); + $this->register(new ContentNegotiationServiceProvider()); $this['phraseanet.exception_handler'] = $this->share(function ($app) { $handler = PhraseaExceptionHandler::register($app['debug']); @@ -470,6 +472,7 @@ class Application extends SilexApplication $dispatcher->addListener(KernelEvents::RESPONSE, [$app, 'addUTF8Charset'], -128); $dispatcher->addSubscriber($app['phraseanet.logout-subscriber']); $dispatcher->addSubscriber($app['phraseanet.locale-subscriber']); + $dispatcher->addSubscriber($app['phraseanet.content-negotiation-subscriber']); $dispatcher->addSubscriber($app['phraseanet.maintenance-subscriber']); $dispatcher->addSubscriber($app['phraseanet.cookie-disabler-subscriber']); $dispatcher->addSubscriber($app['phraseanet.session-manager-subscriber']); diff --git a/lib/Alchemy/Phrasea/Application/Api.php b/lib/Alchemy/Phrasea/Application/Api.php index 9b2e62c0ae..fa80dd11e4 100644 --- a/lib/Alchemy/Phrasea/Application/Api.php +++ b/lib/Alchemy/Phrasea/Application/Api.php @@ -27,7 +27,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) { - $app = new PhraseaApplication($environment); $app->loadPlugins(); @@ -40,6 +39,52 @@ return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) { return $monolog; })); + // handle API content negotiation + $app->before(function(Request $request) use ($app) { + // register custom API format + $request->setFormat(\API_V1_result::FORMAT_JSON_EXTENDED, \API_V1_adapter::$extendedContentTypes['json']); + $request->setFormat(\API_V1_result::FORMAT_YAML_EXTENDED, \API_V1_adapter::$extendedContentTypes['yaml']); + $request->setFormat(\API_V1_result::FORMAT_JSONP_EXTENDED, \API_V1_adapter::$extendedContentTypes['jsonp']); + $request->setFormat(\API_V1_result::FORMAT_JSONP, array('text/javascript', 'application/javascript')); + + // handle content negociation + $priorities = array('application/json', 'application/yaml', 'text/yaml', 'text/javascript', 'application/javascript'); + foreach (\API_V1_adapter::$extendedContentTypes['json'] as $priorities[]); + foreach (\API_V1_adapter::$extendedContentTypes['yaml'] as $priorities[]); + $format = $app['format.negociator']->getBest($request->headers->get('accept') ,$priorities); + + // throw unacceptable http error if API can not handle asked format + if (null === $format) { + $app->abort(406); + } + // set request format according to negotiated content or override format with JSONP if callback parameter is defined + if (trim($request->get('callback')) !== '') { + $request->setRequestFormat(\API_V1_result::FORMAT_JSONP); + } else { + $request->setRequestFormat($request->getFormat($format->getValue())); + } + + // tells whether asked format is extended or not + $request->attributes->set('_extended', in_array( + $request->getRequestFormat(\API_V1_result::FORMAT_JSON), + array( + \API_V1_result::FORMAT_JSON_EXTENDED, + \API_V1_result::FORMAT_YAML_EXTENDED, + \API_V1_result::FORMAT_JSONP_EXTENDED + ) + )); + }, PhraseaApplication::EARLY_EVENT); + + $app->after(function(Request $request, Response $response) use ($app) { + if ($request->getRequestFormat(\API_V1_result::FORMAT_JSON) === \API_V1_result::FORMAT_JSONP && !$response->isOk() && !$response->isServerError()) { + $response->setStatusCode(200); + } + // set response content type + if (!$response->headers->get('Content-Type')) { + $response->headers->set('Content-Type', $request->getMimeType($request->getRequestFormat(\API_V1_result::FORMAT_JSON))); + } + }); + $app->get('/api/', function (Request $request, SilexApplication $app) { return Result::create($request, [ 'name' => $app['conf']->get(['registry', 'general', 'title']), diff --git a/lib/Alchemy/Phrasea/Cache/Manager.php b/lib/Alchemy/Phrasea/Cache/Manager.php index c336c95dbf..fa01631d16 100644 --- a/lib/Alchemy/Phrasea/Cache/Manager.php +++ b/lib/Alchemy/Phrasea/Cache/Manager.php @@ -79,7 +79,11 @@ class Manager $cache = $this->factory->create('array', []); } - $cache->setNamespace(md5(gethostname().'-'.__DIR__)); + if (isset($options['namespace']) && is_string($options['namespace'])) { + $cache->setNamespace($options['namespace']); + } else { + $cache->setNamespace(md5(gethostname().'-'.__DIR__)); + } $this->drivers[$label] = $cache; diff --git a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php index 77865a9800..0a71ba2052 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php @@ -14,6 +14,8 @@ namespace Alchemy\Phrasea\Controller\Admin; use Alchemy\Phrasea\Exception\InvalidArgumentException; use Alchemy\Phrasea\Form\TaskForm; use Alchemy\Phrasea\Model\Entities\Task; +use Alchemy\Phrasea\Exception\RuntimeException; +use Alchemy\Phrasea\Exception\XMLParseErrorException; use Silex\Application; use Silex\ControllerProviderInterface; use Symfony\Component\HttpFoundation\Request; @@ -330,6 +332,10 @@ class TaskManager implements ControllerProviderInterface public function validateXML(Application $app, Request $request) { + if (false === $app['phraseanet.configuration']['main']['task-manager']['enabled']) { + throw new RuntimeException('The use of the task manager is disabled on this instance.'); + } + return $app->json(['success' => $this->doValidateXML($request->getContent())]); } diff --git a/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php b/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php index f2923a4ce0..92192033ec 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php +++ b/lib/Alchemy/Phrasea/Controller/Api/Oauth2.php @@ -48,7 +48,7 @@ class Oauth2 implements ControllerProviderInterface $params = $oauth2Adapter->getAuthorizationRequestParameters($request); $appAuthorized = false; - $errorMessage = false; + $errorMessage = $request->get('error', ''); if (null === $client = $app['repo.api-applications']->findByClientId($params['client_id'])) { throw new NotFoundHttpException(sprintf('Application with client id %s could not be found', $params['client_id'])); @@ -80,18 +80,21 @@ class Oauth2 implements ControllerProviderInterface if (null === $usrId = $app['auth.native']->getUsrId($request->get("login"), $request->get("password"), $request)) { $app['session']->getFlashBag()->set('error', $app->trans('login::erreur: Erreur d\'authentification')); - return $app->redirectPath('oauth2_authorize'); + return $app->redirectPath('oauth2_authorize', array_merge(array('error' => 'login'), $params)); } } catch (RequireCaptchaException $e) { - return $app->redirectPath('oauth2_authorize', ['error' => 'captcha']); + return $app->redirectPath('oauth2_authorize', array_merge(array('error' => 'captcha'), $params)); } catch (AccountLockedException $e) { - return $app->redirectPath('oauth2_authorize', ['error' => 'account-locked']); + return $app->redirectPath('oauth2_authorize', array_merge(array('error' => 'account-locked'), $params)); } $app['authentication']->openAccount($app['repo.users']->find($usrId)); - } + } else { + $r = new Response($app['twig']->render($template, array('error' => $error, "auth" => $oauth2_adapter))); + $r->headers->set('Content-Type', 'text/html'); - return new Response($app['twig']->render($template, ["auth" => $oauth2Adapter])); + return $r; + } } //check if current client is already authorized by current user @@ -114,10 +117,12 @@ class Oauth2 implements ControllerProviderInterface "errorMessage" => $errorMessage, ]; - return new Response($app['twig']->render($template, $params)); + $r = new Response($app['twig']->render($template, $params)); + $r->headers->set('Content-Type', 'text/html'); + + return $r; } elseif (!$appAuthorized && $actionAccept !== null) { $appAuthorized = (Boolean) $actionAccept; - if ($appAuthorized) { $app['manipulator.api-account']->authorizeAccess($account); } else { @@ -129,7 +134,10 @@ class Oauth2 implements ControllerProviderInterface if ($oauth2Adapter->isNativeApp($params['redirect_uri'])) { $params = $oauth2Adapter->finishNativeClientAuthorization($appAuthorized, $params); - return new Response($app['twig']->render("api/auth/native_app_access_token.html.twig", $params)); + $r = new Response($app['twig']->render("api/auth/native_app_access_token.html.twig", $params)); + $r->headers->set('Content-Type', 'text/html'); + + return $r; } $oauth2Adapter->finishClientAuthorization($appAuthorized, $params); diff --git a/lib/Alchemy/Phrasea/Controller/Permalink.php b/lib/Alchemy/Phrasea/Controller/Permalink.php index 2e0812866f..3fff663b2b 100644 --- a/lib/Alchemy/Phrasea/Controller/Permalink.php +++ b/lib/Alchemy/Phrasea/Controller/Permalink.php @@ -183,7 +183,7 @@ class Permalink extends AbstractDelivery $stamp = true; break; case 'wm': - $watermark = false; + $watermark = true; break; } diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Export.php b/lib/Alchemy/Phrasea/Controller/Prod/Export.php index 6385e482f3..7d10b066ad 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Export.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Export.php @@ -243,7 +243,7 @@ class Export implements ControllerProviderInterface $mail->setButtonUrl($url); $mail->setExpiration($token->getExpiration()); - $app['notification.deliverer']->deliver($mail); + $app['notification.deliverer']->deliver($mail, !!$request->request->get('reading_confirm', false)); unset($remaingEmails[$key]); } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php index e970991257..fc7bf099f6 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ApiExceptionHandlerSubscriber.php @@ -56,7 +56,9 @@ class ApiExceptionHandlerSubscriber implements EventSubscriberInterface $code = 404; } elseif ($e instanceof HttpExceptionInterface) { if (503 === $e->getStatusCode()) { - $code = 503; + $code = \API_V1_result::ERROR_MAINTENANCE; + } else if (406 === $e->getStatusCode()) { + $code = \API_V1_result::ERROR_UNACCEPTABLE; } else { $code = 500; } diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ContentNegotiationSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ContentNegotiationSubscriber.php new file mode 100644 index 0000000000..9769e71571 --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ContentNegotiationSubscriber.php @@ -0,0 +1,50 @@ +app = $app; + } + + public static function getSubscribedEvents() + { + return array( + KernelEvents::REQUEST => array('onKernelRequest', Application::EARLY_EVENT), + ); + } + + public function onKernelRequest(GetResponseEvent $event) + { + $priorities = array('text/html', 'application/json', '*/*'); + $format = $this->app['format.negociator']->getBest($event->getRequest()->headers->get('accept', '*/*'), $priorities); + + if (null === $format) { + $this->app->abort(406, 'Not acceptable'); + } + + $event->getRequest()->setRequestFormat($event->getRequest()->getFormat($format->getValue())); + } +} diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php index 67d3d9e1c6..2bc4c64f2c 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/PhraseaLocaleSubscriber.php @@ -59,18 +59,6 @@ class PhraseaLocaleSubscriber implements EventSubscriberInterface return; } - /** - * add content negotiation here - */ - $contentTypes = $event->getRequest()->getAcceptableContentTypes(); - $event->getRequest()->setRequestFormat( - $event->getRequest()->getFormat( - array_shift( - $contentTypes - ) - ) - ); - $this->app['locale'] = $this->app->share(function (Application $app) use ($event) { if (isset($app['conf'])) { $locale = $app['conf']->get(['languages', 'default'], 'en'); diff --git a/lib/Alchemy/Phrasea/Core/Provider/ContentNegotiationServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ContentNegotiationServiceProvider.php new file mode 100644 index 0000000000..afcb36ee25 --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Provider/ContentNegotiationServiceProvider.php @@ -0,0 +1,40 @@ +share(function ($app) { + return new Negotiator(); + }); + + $app['format.negociator'] = $app->share(function ($app) { + return new FormatNegotiator(); + }); + + $app['langage.negociator'] = $app->share(function ($app) { + return new LanguageNegotiator(); + }); + } + + public function boot(Application $app) + { + } +} diff --git a/lib/Alchemy/Phrasea/Core/Provider/PhraseaEventServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/PhraseaEventServiceProvider.php index 1fda4c978b..ece1f1b21e 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/PhraseaEventServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/PhraseaEventServiceProvider.php @@ -11,6 +11,7 @@ namespace Alchemy\Phrasea\Core\Provider; +use Alchemy\Phrasea\Core\Event\Subscriber\ContentNegotiationSubscriber; use Alchemy\Phrasea\Core\Event\Subscriber\CookiesDisablerSubscriber; use Alchemy\Phrasea\Core\Event\Subscriber\LogoutSubscriber; use Alchemy\Phrasea\Core\Event\Subscriber\MaintenanceSubscriber; @@ -38,6 +39,9 @@ class PhraseaEventServiceProvider implements ServiceProviderInterface $app['phraseanet.session-manager-subscriber'] = $app->share(function (Application $app) { return new SessionManagerSubscriber($app); }); + $app['phraseanet.content-negotiation-subscriber'] = $app->share(function (Application $app) { + return new ContentNegotiationSubscriber($app); + }); } public function boot(Application $app) diff --git a/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php index 09cd343052..5b6af0898d 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/RegistrationServiceProvider.php @@ -67,7 +67,7 @@ class RegistrationServiceProvider implements ServiceProviderInterface ], 'address' => [ 'label' => 'admin::compte-utilisateur adresse', - 'type' => 'textarea', + 'type' => 'text', 'constraints' => [ new Assert\NotBlank(), ] @@ -86,7 +86,7 @@ class RegistrationServiceProvider implements ServiceProviderInterface new Assert\NotBlank(), ] ], - 'position' => [ + 'job' => [ 'label' => 'admin::compte-utilisateur poste', 'type' => 'text', 'constraints' => [ @@ -100,7 +100,7 @@ class RegistrationServiceProvider implements ServiceProviderInterface new Assert\NotBlank(), ] ], - 'job' => [ + 'position' => [ 'label' => 'admin::compte-utilisateur activite', 'type' => 'text', 'constraints' => [ diff --git a/lib/classes/databox/status.php b/lib/classes/databox/status.php index 0aeddff4fb..76e2b6e4f5 100644 --- a/lib/classes/databox/status.php +++ b/lib/classes/databox/status.php @@ -104,11 +104,11 @@ class databox_status $this->status[$bit]["img_on"] = null; if (is_file($path . "-stat_" . $bit . "_0.gif")) { - $this->status[$bit]["img_off"] = $url . "-stat_" . $bit . "_0.gif"; + $this->status[$bit]["img_off"] = $url . "-stat_" . $bit . "_0.gif?etag=".md5_file($path . "-stat_" . $bit . "_0.gif"); $this->status[$bit]["path_off"] = $path . "-stat_" . $bit . "_0.gif"; } if (is_file($path . "-stat_" . $bit . "_1.gif")) { - $this->status[$bit]["img_on"] = $url . "-stat_" . $bit . "_1.gif"; + $this->status[$bit]["img_on"] = $url . "-stat_" . $bit . "_1.gif?etag=".md5_file($path . "-stat_" . $bit . "_1.gif"); $this->status[$bit]["path_on"] = $path . "-stat_" . $bit . "_1.gif"; } diff --git a/lib/classes/patch/386alpha1a.php b/lib/classes/patch/386alpha1a.php new file mode 100644 index 0000000000..f751ad4756 --- /dev/null +++ b/lib/classes/patch/386alpha1a.php @@ -0,0 +1,59 @@ +release; + } + + /** + * {@inheritdoc} + */ + public function require_all_upgrades() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function concern() + { + return $this->concern; + } + + /** + * {@inheritdoc} + */ + public function apply(base $databox, Application $app) + { + $config = $app['phraseanet.configuration']->getConfig(); + + $config['main']['task-manager']['enabled'] = true; + + $app['phraseanet.configuration']->setConfig($config); + + return true; + } +} diff --git a/lib/classes/set/export.php b/lib/classes/set/export.php index 68f8556f26..5d33ab4224 100644 --- a/lib/classes/set/export.php +++ b/lib/classes/set/export.php @@ -777,8 +777,8 @@ class set_export extends set_abstract $log["poids"] = $obj["size"]; $log["shortXml"] = $app['serializer.caption']->serialize($record_object->get_caption(), CaptionSerializer::SERIALIZE_XML); $tmplog[$record_object->get_base_id()][] = $log; - if (!$anonymous && $o == 'document') { - $app['acl']->get($app['authentication']->getUser())->remove_remaining($record_object->get_base_id()); + if (!$anonymous && $o == 'document' && null !== $app['authentication']->getUser()) { + $ $app['acl']->get($app['authentication']->getUser())->remove_remaining($record_object->get_base_id()); } } @@ -788,7 +788,7 @@ class set_export extends set_abstract $list_base = array_unique(array_keys($tmplog)); - if (!$anonymous) { + if (!$anonymous && null !== $app['authentication']->getUser()) { $sql = "UPDATE basusr SET remain_dwnld = :remain_dl WHERE base_id = :base_id AND usr_id = :usr_id"; diff --git a/lib/conf.d/configuration.yml b/lib/conf.d/configuration.yml index f310952ced..2121849d12 100644 --- a/lib/conf.d/configuration.yml +++ b/lib/conf.d/configuration.yml @@ -30,6 +30,7 @@ main: options: [] task-manager: status: started + enabled: true logger: max-files: 10 enabled: true diff --git a/templates/web/admin/setup.html.twig b/templates/web/admin/setup.html.twig index 27ddc40fb2..1ea02a590d 100644 --- a/templates/web/admin/setup.html.twig +++ b/templates/web/admin/setup.html.twig @@ -30,6 +30,15 @@ +
{{ 'Erreur de login / mot de passe' | trans }}
{% trans with {'%home_title%' : home_title} %}Bonjour, veuillez vous identifier sur %home_title% :{% endtrans %} diff --git a/templates/web/client/answers.html.twig b/templates/web/client/answers.html.twig index 6fec333aee..4e29d49182 100644 --- a/templates/web/client/answers.html.twig +++ b/templates/web/client/answers.html.twig @@ -142,7 +142,7 @@ {% else %}
and , which are strings +# you would put in $PS1 before and after the status string +# generated by the git-prompt machinery. e.g. +# Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "' +# will show username, at-sign, host, colon, cwd, then +# various status string, followed by dollar and SP, as +# your prompt. +# ZSH: precmd () { __git_ps1 "%n" ":%~$ " "|%s" } +# will show username, pipe, then various status string, +# followed by colon, cwd, dollar and SP, as your prompt. +# Optionally, you can supply a third argument with a printf +# format string to finetune the output of the branch status +# +# The repository status will be displayed only if you are currently in a +# git repository. The %s token is the placeholder for the shown status. +# +# The prompt status always includes the current branch name. +# +# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value, +# unstaged (*) and staged (+) changes will be shown next to the branch +# name. You can configure this per-repository with the +# bash.showDirtyState variable, which defaults to true once +# GIT_PS1_SHOWDIRTYSTATE is enabled. +# +# You can also see if currently something is stashed, by setting +# GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed, +# then a '$' will be shown next to the branch name. +# +# If you would like to see if there're untracked files, then you can set +# GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked +# files, then a '%' will be shown next to the branch name. You can +# configure this per-repository with the bash.showUntrackedFiles +# variable, which defaults to true once GIT_PS1_SHOWUNTRACKEDFILES is +# enabled. +# +# If you would like to see the difference between HEAD and its upstream, +# set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">" +# indicates you are ahead, "<>" indicates you have diverged and "=" +# indicates that there is no difference. You can further control +# behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list +# of values: +# +# verbose show number of commits ahead/behind (+/-) upstream +# name if verbose, then also show the upstream abbrev name +# legacy don't use the '--count' option available in recent +# versions of git-rev-list +# git always compare HEAD to @{upstream} +# svn always compare HEAD to your SVN upstream +# +# By default, __git_ps1 will compare HEAD to your SVN upstream if it can +# find one, or @{upstream} otherwise. Once you have set +# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by +# setting the bash.showUpstream config variable. +# +# If you would like to see more information about the identity of +# commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE +# to one of these values: +# +# contains relative to newer annotated tag (v1.6.3.2~35) +# branch relative to newer tag or branch (master~4) +# describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f) +# default exactly matching tag +# +# If you would like a colored hint about the current dirty state, set +# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on +# the colored output of "git status -sb" and are available only when +# using __git_ps1 for PROMPT_COMMAND or precmd. + +# check whether printf supports -v +__git_printf_supports_v= +printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1 + +# stores the divergence from upstream in $p +# used by GIT_PS1_SHOWUPSTREAM +__git_ps1_show_upstream () +{ + local key value + local svn_remote svn_url_pattern count n + local upstream=git legacy="" verbose="" name="" + + svn_remote=() + # get some config options from git-config + local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')" + while read -r key value; do + case "$key" in + bash.showupstream) + GIT_PS1_SHOWUPSTREAM="$value" + if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then + p="" + return + fi + ;; + svn-remote.*.url) + svn_remote[$((${#svn_remote[@]} + 1))]="$value" + svn_url_pattern="$svn_url_pattern\\|$value" + upstream=svn+git # default upstream is SVN if available, else git + ;; + esac + done <<< "$output" + + # parse configuration values + for option in ${GIT_PS1_SHOWUPSTREAM}; do + case "$option" in + git|svn) upstream="$option" ;; + verbose) verbose=1 ;; + legacy) legacy=1 ;; + name) name=1 ;; + esac + done + + # Find our upstream + case "$upstream" in + git) upstream="@{upstream}" ;; + svn*) + # get the upstream from the "git-svn-id: ..." in a commit message + # (git-svn uses essentially the same procedure internally) + local -a svn_upstream + svn_upstream=($(git log --first-parent -1 \ + --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) + if [[ 0 -ne ${#svn_upstream[@]} ]]; then + svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]} + svn_upstream=${svn_upstream%@*} + local n_stop="${#svn_remote[@]}" + for ((n=1; n <= n_stop; n++)); do + svn_upstream=${svn_upstream#${svn_remote[$n]}} + done + + if [[ -z "$svn_upstream" ]]; then + # default branch name for checkouts with no layout: + upstream=${GIT_SVN_ID:-git-svn} + else + upstream=${svn_upstream#/} + fi + elif [[ "svn+git" = "$upstream" ]]; then + upstream="@{upstream}" + fi + ;; + esac + + # Find how many commits we are ahead/behind our upstream + if [[ -z "$legacy" ]]; then + count="$(git rev-list --count --left-right \ + "$upstream"...HEAD 2>/dev/null)" + else + # produce equivalent output to --count for older versions of git + local commits + if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)" + then + local commit behind=0 ahead=0 + for commit in $commits + do + case "$commit" in + "<"*) ((behind++)) ;; + *) ((ahead++)) ;; + esac + done + count="$behind $ahead" + else + count="" + fi + fi + + # calculate the result + if [[ -z "$verbose" ]]; then + case "$count" in + "") # no upstream + p="" ;; + "0 0") # equal to upstream + p="=" ;; + "0 "*) # ahead of upstream + p=">" ;; + *" 0") # behind upstream + p="<" ;; + *) # diverged from upstream + p="<>" ;; + esac + else + case "$count" in + "") # no upstream + p="" ;; + "0 0") # equal to upstream + p=" u=" ;; + "0 "*) # ahead of upstream + p=" u+${count#0 }" ;; + *" 0") # behind upstream + p=" u-${count% 0}" ;; + *) # diverged from upstream + p=" u+${count#* }-${count% *}" ;; + esac + if [[ -n "$count" && -n "$name" ]]; then + __git_ps1_upstream_name=$(git rev-parse \ + --abbrev-ref "$upstream" 2>/dev/null) + if [ $pcmode = yes ]; then + # see the comments around the + # __git_ps1_branch_name variable below + p="$p \${__git_ps1_upstream_name}" + else + p="$p ${__git_ps1_upstream_name}" + # not needed anymore; keep user's + # environment clean + unset __git_ps1_upstream_name + fi + fi + fi + +} + +# Helper function that is meant to be called from __git_ps1. It +# injects color codes into the appropriate gitstring variables used +# to build a gitstring. +__git_ps1_colorize_gitstring () +{ + if [[ -n ${ZSH_VERSION-} ]]; then + local c_red='%F{red}' + local c_green='%F{green}' + local c_lblue='%F{blue}' + local c_clear='%f' + else + # Using \[ and \] around colors is necessary to prevent + # issues with command line editing/browsing/completion! + local c_red='\[\e[31m\]' + local c_green='\[\e[32m\]' + local c_lblue='\[\e[1;34m\]' + local c_clear='\[\e[0m\]' + fi + local bad_color=$c_red + local ok_color=$c_green + local flags_color="$c_lblue" + + local branch_color="" + if [ $detached = no ]; then + branch_color="$ok_color" + else + branch_color="$bad_color" + fi + c="$branch_color$c" + + z="$c_clear$z" + if [ "$w" = "*" ]; then + w="$bad_color$w" + fi + if [ -n "$i" ]; then + i="$ok_color$i" + fi + if [ -n "$s" ]; then + s="$flags_color$s" + fi + if [ -n "$u" ]; then + u="$bad_color$u" + fi + r="$c_clear$r" +} + +__git_eread () +{ + f="$1" + shift + test -r "$f" && read "$@" <"$f" +} + +# __git_ps1 accepts 0 or 1 arguments (i.e., format string) +# when called from PS1 using command substitution +# in this mode it prints text to add to bash PS1 prompt (includes branch name) +# +# __git_ps1 requires 2 or 3 arguments when called from PROMPT_COMMAND (pc) +# in that case it _sets_ PS1. The arguments are parts of a PS1 string. +# when two arguments are given, the first is prepended and the second appended +# to the state string when assigned to PS1. +# The optional third parameter will be used as printf format string to further +# customize the output of the git-status string. +# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true +__git_ps1 () +{ + local pcmode=no + local detached=no + local ps1pc_start='\u@\h:\w ' + local ps1pc_end='\$ ' + local printf_format=' (%s)' + + case "$#" in + 2|3) pcmode=yes + ps1pc_start="$1" + ps1pc_end="$2" + printf_format="${3:-$printf_format}" + ;; + 0|1) printf_format="${1:-$printf_format}" + ;; + *) return + ;; + esac + + local repo_info rev_parse_exit_code + repo_info="$(git rev-parse --git-dir --is-inside-git-dir \ + --is-bare-repository --is-inside-work-tree \ + --short HEAD 2>/dev/null)" + rev_parse_exit_code="$?" + + if [ -z "$repo_info" ]; then + if [ $pcmode = yes ]; then + #In PC mode PS1 always needs to be set + PS1="$ps1pc_start$ps1pc_end" + fi + return + fi + + local short_sha + if [ "$rev_parse_exit_code" = "0" ]; then + short_sha="${repo_info##*$'\n'}" + repo_info="${repo_info%$'\n'*}" + fi + local inside_worktree="${repo_info##*$'\n'}" + repo_info="${repo_info%$'\n'*}" + local bare_repo="${repo_info##*$'\n'}" + repo_info="${repo_info%$'\n'*}" + local inside_gitdir="${repo_info##*$'\n'}" + local g="${repo_info%$'\n'*}" + + local r="" + local b="" + local step="" + local total="" + if [ -d "$g/rebase-merge" ]; then + __git_eread "$g/rebase-merge/head-name" b + __git_eread "$g/rebase-merge/msgnum" step + __git_eread "$g/rebase-merge/end" total + if [ -f "$g/rebase-merge/interactive" ]; then + r="|REBASE-i" + else + r="|REBASE-m" + fi + else + if [ -d "$g/rebase-apply" ]; then + __git_eread "$g/rebase-apply/next" step + __git_eread "$g/rebase-apply/last" total + if [ -f "$g/rebase-apply/rebasing" ]; then + __git_eread "$g/rebase-apply/head-name" b + r="|REBASE" + elif [ -f "$g/rebase-apply/applying" ]; then + r="|AM" + else + r="|AM/REBASE" + fi + elif [ -f "$g/MERGE_HEAD" ]; then + r="|MERGING" + elif [ -f "$g/CHERRY_PICK_HEAD" ]; then + r="|CHERRY-PICKING" + elif [ -f "$g/REVERT_HEAD" ]; then + r="|REVERTING" + elif [ -f "$g/BISECT_LOG" ]; then + r="|BISECTING" + fi + + if [ -n "$b" ]; then + : + elif [ -h "$g/HEAD" ]; then + # symlink symbolic ref + b="$(git symbolic-ref HEAD 2>/dev/null)" + else + local head="" + if ! __git_eread "$g/HEAD" head; then + if [ $pcmode = yes ]; then + PS1="$ps1pc_start$ps1pc_end" + fi + return + fi + # is it a symbolic ref? + b="${head#ref: }" + if [ "$head" = "$b" ]; then + detached=yes + b="$( + case "${GIT_PS1_DESCRIBE_STYLE-}" in + (contains) + git describe --contains HEAD ;; + (branch) + git describe --contains --all HEAD ;; + (describe) + git describe HEAD ;; + (* | default) + git describe --tags --exact-match HEAD ;; + esac 2>/dev/null)" || + + b="$short_sha..." + b="($b)" + fi + fi + fi + + if [ -n "$step" ] && [ -n "$total" ]; then + r="$r $step/$total" + fi + + local w="" + local i="" + local s="" + local u="" + local c="" + local p="" + + if [ "true" = "$inside_gitdir" ]; then + if [ "true" = "$bare_repo" ]; then + c="BARE:" + else + b="GIT_DIR!" + fi + elif [ "true" = "$inside_worktree" ]; then + if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] && + [ "$(git config --bool bash.showDirtyState)" != "false" ] + then + git diff --no-ext-diff --quiet --exit-code || w="*" + if [ -n "$short_sha" ]; then + git diff-index --cached --quiet HEAD -- || i="+" + else + i="#" + fi + fi + if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] && + [ -r "$g/refs/stash" ]; then + s="$" + fi + + if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] && + [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] && + git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null + then + u="%${ZSH_VERSION+%}" + fi + + if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then + __git_ps1_show_upstream + fi + fi + + local z="${GIT_PS1_STATESEPARATOR-" "}" + + # NO color option unless in PROMPT_COMMAND mode + if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then + __git_ps1_colorize_gitstring + fi + + b=${b##refs/heads/} + if [ $pcmode = yes ]; then + # In pcmode (and only pcmode) the contents of + # $gitstring are subject to expansion by the shell. + # Avoid putting the raw ref name in the prompt to + # protect the user from arbitrary code execution via + # specially crafted ref names (e.g., a ref named + # '$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' would execute + # 'sudo rm -rf /' when the prompt is drawn). Instead, + # put the ref name in a new global variable (in the + # __git_ps1_* namespace to avoid colliding with the + # user's environment) and reference that variable from + # PS1. + __git_ps1_branch_name=$b + # note that the $ is escaped -- the variable will be + # expanded later (when it's time to draw the prompt) + b="\${__git_ps1_branch_name}" + fi + + local f="$w$i$s$u" + local gitstring="$c$b${f:+$z$f}$r$p" + + if [ $pcmode = yes ]; then + if [ "${__git_printf_supports_v-}" != yes ]; then + gitstring=$(printf -- "$printf_format" "$gitstring") + else + printf -v gitstring -- "$printf_format" "$gitstring" + fi + PS1="$ps1pc_start$gitstring$ps1pc_end" + else + printf -- "$printf_format" "$gitstring" + fi +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/files/dot/.vimrc b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/dot/.vimrc new file mode 100644 index 0000000000..2ff1aa6080 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/dot/.vimrc @@ -0,0 +1,414 @@ +set rtp+=$GOROOT/misc/vim + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Maintainer: +" Amir Salihefendic +" http://amix.dk - amix@amix.dk +" +" Version: +" 5.0 - 29/05/12 15:43:36 +" +" Blog_post: +" http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github +" +" Awesome_version: +" Get this config, nice color schemes and lots of plugins! +" +" Install the awesome version from: +" +" https://github.com/amix/vimrc +" +" Syntax_highlighted: +" http://amix.dk/vim/vimrc.html +" +" Raw_version: +" http://amix.dk/vim/vimrc.txt +" +" Sections: +" -> General +" -> VIM user interface +" -> Colors and Fonts +" -> Files and backups +" -> Text, tab and indent related +" -> Visual mode related +" -> Moving around, tabs and buffers +" -> Status line +" -> Editing mappings +" -> vimgrep searching and cope displaying +" -> Spell checking +" -> Misc +" -> Helper functions +" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => General +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Sets how many lines of history VIM has to remember +set history=700 + +" Enable filetype plugins +filetype plugin on +filetype indent on + +" Set to auto read when a file is changed from the outside +set autoread + +" With a map leader it's possible to do extra key combinations +" like w saves the current file +let mapleader = "," +let g:mapleader = "," + +" Fast saving +nmap w :w! + +" :W sudo saves the file +" (useful for handling the permission-denied error) +command W w !sudo tee % > /dev/null + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => VIM user interface +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Set 7 lines to the cursor - when moving vertically using j/k +set so=7 + +" Turn on the WiLd menu +set wildmenu + +" Ignore compiled files +set wildignore=*.o,*~,*.pyc +if has("win16") || has("win32") + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store +else + set wildignore+=.git\*,.hg\*,.svn\* +endif + +"Always show current position +set ruler + +" Height of the command bar +set cmdheight=2 + +" A buffer becomes hidden when it is abandoned +set hid + +" Configure backspace so it acts as it should act +set backspace=eol,start,indent +set whichwrap+=<,>,h,l + +" Ignore case when searching +set ignorecase + +" When searching try to be smart about cases +set smartcase + +" Highlight search results +set hlsearch + +" Makes search act like search in modern browsers +set incsearch + +" Don't redraw while executing macros (good performance config) +set lazyredraw + +" For regular expressions turn magic on +set magic + +" Show matching brackets when text indicator is over them +set showmatch +" How many tenths of a second to blink when matching brackets +set mat=2 + +" No annoying sound on errors +set noerrorbells +set novisualbell +set t_vb= +set tm=500 + +" Add a bit extra margin to the left +set foldcolumn=1 + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Colors and Fonts +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Enable syntax highlighting +syntax enable + +try + colorscheme desert +catch +endtry + +set background=dark + +" Set extra options when running in GUI mode +if has("gui_running") + set guioptions-=T + set guioptions-=e + set t_Co=256 + set guitablabel=%M\ %t +endif + +" Set utf8 as standard encoding and en_US as the standard language +set encoding=utf8 + +" Use Unix as the standard file type +set ffs=unix,dos,mac + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Files, backups and undo +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Turn backup off, since most stuff is in SVN, git et.c anyway... +set nobackup +set nowb +set noswapfile + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Text, tab and indent related +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Use spaces instead of tabs +set expandtab + +" Be smart when using tabs ;) +set smarttab + +" 1 tab == 4 spaces +set shiftwidth=4 +set tabstop=4 + +" Linebreak on 500 characters +set lbr +set tw=500 + +set ai "Auto indent +set si "Smart indent +set wrap "Wrap lines + + +"""""""""""""""""""""""""""""" +" => Visual mode related +"""""""""""""""""""""""""""""" +" Visual mode pressing * or # searches for the current selection +" Super useful! From an idea by Michael Naumann +vnoremap * :call VisualSelection('f', '') +vnoremap # :call VisualSelection('b', '') + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Moving around, tabs, windows and buffers +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Treat long lines as break lines (useful when moving around in them) +map j gj +map k gk + +" Map to / (search) and Ctrl- to ? (backwards search) +map / +map ? + +" Disable highlight when is pressed +map :noh + +" Smart way to move between windows +map j +map k +map h +map l + +" Close the current buffer +map bd :Bclose + +" Close all the buffers +map ba :1,1000 bd! + +" Useful mappings for managing tabs +map tn :tabnew +map to :tabonly +map tc :tabclose +map tm :tabmove +map t :tabnext + +" Opens a new tab with the current buffer's path +" Super useful when editing files in the same directory +map te :tabedit =expand("%:p:h")/ + +" Switch CWD to the directory of the open buffer +map cd :cd %:p:h:pwd + +" Specify the behavior when switching between buffers +try + set switchbuf=useopen,usetab,newtab + set stal=2 +catch +endtry + +" Return to last edit position when opening files (You want this!) +autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif +" Remember info about open buffers on close +set viminfo^=% + + +"""""""""""""""""""""""""""""" +" => Status line +"""""""""""""""""""""""""""""" +" Always show the status line +set laststatus=2 + +" Format the status line +set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Editing mappings +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Remap VIM 0 to first non-blank character +map 0 ^ + +" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac +nmap mz:m+`z +nmap mz:m-2`z +vmap :m'>+`mzgv`yo`z +vmap :m'<-2`>my` + nmap + vmap + vmap +endif + +" Delete trailing white space on save, useful for Python and CoffeeScript ;) +func! DeleteTrailingWS() + exe "normal mz" + %s/\s\+$//ge + exe "normal `z" +endfunc +autocmd BufWrite *.py :call DeleteTrailingWS() +autocmd BufWrite *.coffee :call DeleteTrailingWS() + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => vimgrep searching and cope displaying +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" When you press gv you vimgrep after the selected text +vnoremap gv :call VisualSelection('gv', '') + +" Open vimgrep and put the cursor in the right position +map g :vimgrep // **/*. + +" Vimgreps in the current file +map :vimgrep // % + +" When you press r you can search and replace the selected text +vnoremap r :call VisualSelection('replace', '') + +" Do :help cope if you are unsure what cope is. It's super useful! +" +" When you search with vimgrep, display your results in cope by doing: +" cc +" +" To go to the next search result do: +" n +" +" To go to the previous search results do: +" p +" +map cc :botright cope +map co ggVGy:tabnew:set syntax=qfpgg +map n :cn +map p :cp + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Spell checking +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Pressing ,ss will toggle and untoggle spell checking +map ss :setlocal spell! + +" Shortcuts using +map sn ]s +map sp [s +map sa zg +map s? z= + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Misc +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Remove the Windows ^M - when the encodings gets messed up +noremap m mmHmt:%s///ge'tzt'm + +" Quickly open a buffer for scripbble +map q :e ~/buffer + +" Toggle paste mode on and off +map pp :setlocal paste! + + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Helper functions +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +function! CmdLine(str) + exe "menu Foo.Bar :" . a:str + emenu Foo.Bar + unmenu Foo +endfunction + +function! VisualSelection(direction, extra_filter) range + let l:saved_reg = @" + execute "normal! vgvy" + + let l:pattern = escape(@", '\\/.*$^~[]') + let l:pattern = substitute(l:pattern, "\n$", "", "") + + if a:direction == 'b' + execute "normal ?" . l:pattern . "^M" + elseif a:direction == 'gv' + call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.' . a:extra_filter) + elseif a:direction == 'replace' + call CmdLine("%s" . '/'. l:pattern . '/') + elseif a:direction == 'f' + execute "normal /" . l:pattern . "^M" + endif + + let @/ = l:pattern + let @" = l:saved_reg +endfunction + + +" Returns true if paste mode is enabled +function! HasPaste() + if &paste + return 'PASTE MODE ' + en + return '' +endfunction + +" Don't close window, when deleting a buffer +command! Bclose call BufcloseCloseIt() +function! BufcloseCloseIt() + let l:currentBufNum = bufnr("%") + let l:alternateBufNum = bufnr("#") + + if buflisted(l:alternateBufNum) + buffer # + else + bnext + endif + + if bufnr("%") == l:currentBufNum + new + endif + + if buflisted(l:currentBufNum) + execute("bdelete! ".l:currentBufNum) + endif +endfunction diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/files/dot/ssh/insecure_private_key b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/dot/ssh/insecure_private_key new file mode 100644 index 0000000000..7d6a083909 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/dot/ssh/insecure_private_key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI +w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP +kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2 +hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO +Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW +yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd +ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1 +Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf +TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK +iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0tyEXNDYBLEF4A +sClaWuSJ2kjq7KhrrYXzagqhnSei9ODYFShJu8UWVec3Ihb5ZXlzO6vdNQ1J9Xsf +4m+2ywKBgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/orApiHmHDsURs5rUKDx0f9iP +cXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsMkE4CUSiJcYrMANtx54cGH7Rk +EjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTGyAK+OLD3M2QdCQKBgQDtx8pN +CAxR7yhHbIWT1AH66+XWN8bXq7l3RO/ukeaci98JfkbkxURZhtxV/HHuvUhnPLdX +3TwygPBYZFNo4pzVEhzWoTtnEtrFueKxyc3+LjZpuo+mBlQ6ORtfgkr9gBVphXZG +YEzkCD3lVdl8L4cw9BVpKrJCs1c5taGjDgdInQKBgHm/fVvv96bJxc9x1tffXAcj +3OVdUN0UgXNCSaf/3A/phbeBQe9xS+3mpc4r6qvx+iy69mNBeNZ0xOitIjpjBo2+ +dBEjSBwLk5q5tJqHmy/jKMJL4n9ROlx93XS+njxgibTvU6Fp9w+NOFD/HvxB3Tcz +6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC +P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF +llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ +kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH ++vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ +NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= +-----END RSA PRIVATE KEY----- diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-always/.gitkeep b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-always/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-always/setup b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-always/setup new file mode 100755 index 0000000000..00ba60e2b3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-always/setup @@ -0,0 +1,10 @@ +#! /bin/bash + +# open rabbitmq ports +sudo iptables -I INPUT -p tcp --dport 15672 -j ACCEPT + +# open elastic search ports +sudo iptables -I INPUT -p tcp --dport 9200 -j ACCEPT + +# open mysql ports +sudo iptables -I INPUT -p tcp --dport 3306 -j ACCEPT \ No newline at end of file diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/.gitkeep b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/setup b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/setup new file mode 100644 index 0000000000..fd4654ed33 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/exec-once/setup @@ -0,0 +1,111 @@ +#!/bin/bash + +# timezone +sudo sh -c 'echo "Europe/Paris" > /etc/timezone' +sudo dpkg-reconfigure -f noninteractive tzdata + +# locales + +export LANGUAGE=fr_FR.UTF-8 +export LANG=fr_FR.UTF-8 +export LC_ALL=fr_FR.UTF-8 +sudo sh -c 'echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen' +sudo sh -c 'echo "de_DE.UTF-8 UTF-8" >> /etc/locale.gen' +sudo sh -c 'echo "es_ES.UTF-8 UTF-8" >> /etc/locale.gen' +sudo sh -c 'echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen' +sudo sh -c 'echo "nl_NL.UTF-8 UTF-8" >> /etc/locale.gen' +sudo locale-gen en_US en_US.UTF-8 en_GB en_GB.UTF-8 fr_FR fr_FR.UTF-8 de_DE de_DE.UTF-8 nl_NL nl_NL.UTF-8 +sudo dpkg-reconfigure -f noninteractive locales + +# node + npm +cd /tmp +wget –quiet "http://nodejs.org/dist/v0.10.29/node-v0.10.29-linux-x64.tar.gz" +tar -zxvf node-v0.10.29-linux-x64.tar.gz +cd node-v0.10.29-linux-x64 +find . -maxdepth 1 -type f -exec rm {} \; +sudo cp -rf * /usr/local/ + +# npm binaries +sudo npm install -g recess +sudo npm install -g grunt-cli +sudo npm install -g bower + +# python tools + +sudo easy_install -U taschenmesser scour boto + +# closure compiler +cd /tmp +wget –quiet http://dl.google.com/closure-compiler/compiler-latest.zip +unzip compiler-latest.zip -d closure +mv closure $HOME +echo 'export JS_COMPILER=$HOME/closure/compiler.jar' >> ~/.bashrc +source ~/.bashrc + +# java +echo 'export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre/' >> ~/.bashrc +source ~/.bashrc + +#twig +cd /tmp +git clone https://github.com/fabpot/Twig.git +cd Twig/ext/twig +phpize +./configure +make +sudo make install +sudo sh -c 'echo "extension=twig.so" > /etc/php5/cli/conf.d/twig.ini' +sudo sh -c 'echo "extension=twig.so" > /etc/php5/fpm/conf.d/twig.ini' + +# phraseanet-extension +cd /tmp +git clone git://github.com/alchemy-fr/Phraseanet-Extension.git +cd Phraseanet-Extension +phpize +./configure +make +sudo make install +if [ $? -eq 0 ]; then + sudo sh -c 'echo "extension=phrasea2.so" > /etc/php5/cli/conf.d/phrasea.ini' + sudo sh -c 'echo "extension=phrasea2.so" > /etc/php5/fpm/conf.d/phrasea.ini' +fi + +# phraseanet-indexer +cd /tmp +git clone git://github.com/alchemy-fr/Phraseanet-Indexer.git +cd Phraseanet-Indexer +autoreconf --force --install +./configure +make +sudo make install + +# swftools +cd /tmp +wget –quiet http://www.swftools.org/swftools-0.9.2.tar.gz +tar -xzvf swftools-0.9.2.tar.gz +cd swftools-0.9.2 +./configure +make +sudo make install + +# zmq php extension +yes | sudo pecl install zmq-beta +if [ $? -eq 0 ]; then + sudo sh -c 'echo "extension=zmq.so" > /etc/php5/cli/conf.d/zmq.ini' + sudo sh -c 'echo "extension=zmq.so" > /etc/php5/fpm/conf.d/zmq.ini' +fi + +# libevent php extension +sudo apt-get autoremove --yes --purge libevent-dev +sudo apt-get install --yes libevent-dev +yes | sudo pecl install libevent-beta +if [ $? -eq 0 ]; then + sudo sh -c 'echo ";extension=libevent.so" > /etc/php5/cli/conf.d/libevent.ini' + sudo sh -c 'echo ";extension=libevent.so" > /etc/php5/fpm/conf.d/libevent.ini' +fi + +# copy www.conf +sudo sh -c "cat /vagrant/vagrant/config/nginx/php5-fpm-www.conf > /etc/php5/fpm/pool.d/www.conf" + +# restart mysql to get new date system +sudo service mysql restart diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/files/startup-always/.gitkeep b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/startup-always/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/files/startup-once/.gitkeep b/vagrant/vms/phraseanet-php54-nginx/puphpet/files/startup-once/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/Puppetfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/Puppetfile new file mode 100644 index 0000000000..c34cffec26 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/Puppetfile @@ -0,0 +1,27 @@ +forge "http://forge.puppetlabs.com" +mod 'stdlib', :git => 'https://github.com/puphpet/puppetlabs-stdlib.git' +mod 'concat', :git => 'https://github.com/puphpet/puppetlabs-concat.git' +mod 'apt', :git => 'https://github.com/puphpet/puppetlabs-apt.git' +mod 'yum', :git => 'https://github.com/puphpet/puppet-yum.git' +mod 'vcsrepo', :git => 'https://github.com/puphpet/puppetlabs-vcsrepo.git' +mod 'ntp', :git => 'https://github.com/puphpet/puppetlabs-ntp.git' +mod 'firewall', :git => 'https://github.com/puppetlabs/puppetlabs-firewall.git' +mod 'git', :git => 'https://github.com/puphpet/puppetlabs-git.git' +mod 'mailcatcher', :git => 'https://github.com/puphpet/puppet-mailcatcher.git' +mod 'supervisord', :git => 'https://github.com/puphpet/puppet-supervisord.git' +mod 'apache', :git => 'https://github.com/puphpet/puppetlabs-apache.git' +mod 'nginx', :git => 'https://github.com/puphpet/puppet-nginx.git' +mod 'php', :git => 'https://github.com/puphpet/puppet-php.git' +mod 'composer', :git => 'https://github.com/puphpet/puppet-composer.git' +mod 'puphpet', :git => 'https://github.com/puphpet/puppet-puphpet.git' +mod 'puppi', :git => 'https://github.com/puphpet/puppi.git' +mod 'drush', :git => 'https://github.com/puphpet/puppet-drush.git' +mod 'mysql', :git => 'https://github.com/puphpet/puppetlabs-mysql.git' +mod 'postgresql', :git => 'https://github.com/puphpet/puppetlabs-postgresql.git' +mod 'sqlite', :git => 'https://github.com/puppetlabs/puppetlabs-sqlite.git' +mod 'mongodb', :git => 'https://github.com/puphpet/puppetlabs-mongodb.git' +mod 'redis', :git => 'https://github.com/puphpet/puppet-redis.git' +mod 'beanstalkd', :git => 'https://github.com/puphpet/puppet-beanstalkd.git' +mod 'rabbitmq', :git => 'https://github.com/puphpet/puppetlabs-rabbitmq.git' +mod 'staging', :git => 'https://github.com/puphpet/puppet-staging.git' +mod 'elasticsearch', :git => 'https://github.com/puphpet/puppet-elasticsearch.git' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/hiera.yaml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/hiera.yaml new file mode 100644 index 0000000000..98358aa6ea --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/hiera.yaml @@ -0,0 +1,7 @@ +--- +:backends: yaml +:yaml: + :datadir: '/vagrant/vagrant/vms/phraseanet-php54-nginx/puphpet' +:hierarchy: + - config +:logger: console diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/manifest.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/manifest.pp new file mode 100644 index 0000000000..9b15bc3bb8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/manifest.pp @@ -0,0 +1,1808 @@ +## Begin Server manifest + +if $server_values == undef { + $server_values = hiera('server', false) +} if $vm_values == undef { + $vm_values = hiera($::vm_target_key, false) +} +# Ensure the time is accurate, reducing the possibilities of apt repositories +# failing for invalid certificates +class { 'ntp': } + +include 'puphpet' +include 'puphpet::params' + +Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] } +group { 'puppet': ensure => present } +group { 'www-data': ensure => present } +group { 'www-user': ensure => present } + +user { $::ssh_username: + shell => '/bin/bash', + home => "/home/${::ssh_username}", + ensure => present, + groups => ['www-data', 'www-user'], + require => [Group['www-data'], Group['www-user']] +} + +user { ['apache', 'nginx', 'httpd', 'www-data']: + shell => '/bin/bash', + ensure => present, + groups => 'www-data', + require => Group['www-data'] +} + +file { "/home/${::ssh_username}": + ensure => directory, + owner => $::ssh_username, +} + +# copy dot files to ssh user's home directory +exec { 'dotfiles': + cwd => "/home/${::ssh_username}", + command => "cp -r /vagrant/vagrant/vms/phraseanet-php54-nginx/puphpet/files/dot/.[a-zA-Z0-9]* /home/${::ssh_username}/ \ + && chown -R ${::ssh_username} /home/${::ssh_username}/.[a-zA-Z0-9]* \ + && cp -r /vagrant/vagrant/vms/phraseanet-php54-nginx/puphpet/files/dot/.[a-zA-Z0-9]* /root/", + onlyif => 'test -d /vagrant/vagrant/vms/phraseanet-php54-nginx/puphpet/files/dot', + returns => [0, 1], + require => User[$::ssh_username] +} + +case $::osfamily { + # debian, ubuntu + 'debian': { + class { 'apt': } + + Class['::apt::update'] -> Package <| + title != 'python-software-properties' + and title != 'software-properties-common' + |> + + if ! defined(Package['augeas-tools']) { + package { 'augeas-tools': + ensure => present, + } + } + } + # redhat, centos + 'redhat': { + class { 'yum': extrarepo => ['epel'] } + + class { 'yum::repo::rpmforge': } + class { 'yum::repo::repoforgeextras': } + + Class['::yum'] -> Yum::Managed_yumrepo <| |> -> Package <| |> + + if ! defined(Package['git']) { + package { 'git': + ensure => latest, + require => Class['yum::repo::repoforgeextras'] + } + } + + file_line { 'link ~/.bash_git': + ensure => present, + line => 'if [ -f ~/.bash_git ] ; then source ~/.bash_git; fi', + path => "/home/${::ssh_username}/.bash_profile", + require => Exec['dotfiles'], + } + + file_line { 'link ~/.bash_git for root': + ensure => present, + line => 'if [ -f ~/.bash_git ] ; then source ~/.bash_git; fi', + path => '/root/.bashrc', + require => Exec['dotfiles'], + } + + file_line { 'link ~/.bash_aliases': + ensure => present, + line => 'if [ -f ~/.bash_aliases ] ; then source ~/.bash_aliases; fi', + path => "/home/${::ssh_username}/.bash_profile", + require => Exec['dotfiles'], + } + + file_line { 'link ~/.bash_aliases for root': + ensure => present, + line => 'if [ -f ~/.bash_aliases ] ; then source ~/.bash_aliases; fi', + path => '/root/.bashrc', + require => Exec['dotfiles'], + } + + ensure_packages( ['augeas'] ) + } +} + +if $php_values == undef { + $php_values = hiera('php', false) +} + +case $::operatingsystem { + 'debian': { + include apt::backports + + add_dotdeb { 'packages.dotdeb.org': release => $lsbdistcodename } + + if hash_key_equals($php_values, 'install', 1) { + # Debian Squeeze 6.0 can do PHP 5.3 (default) and 5.4 + if $lsbdistcodename == 'squeeze' and $php_values['version'] == '54' { + add_dotdeb { 'packages.dotdeb.org-php54': release => 'squeeze-php54' } + } + # Debian Wheezy 7.0 can do PHP 5.4 (default) and 5.5 + elsif $lsbdistcodename == 'wheezy' and $php_values['version'] == '55' { + add_dotdeb { 'packages.dotdeb.org-php55': release => 'wheezy-php55' } + } + } + + $server_lsbdistcodename = downcase($lsbdistcodename) + + apt::force { 'git': + release => "${server_lsbdistcodename}-backports", + timeout => 60 + } + } + 'ubuntu': { + apt::key { '4F4EA0AAE5267A6C': + key_server => 'hkp://keyserver.ubuntu.com:80' + } + apt::key { '4CBEDD5A': + key_server => 'hkp://keyserver.ubuntu.com:80' + } + + if $lsbdistcodename in ['lucid', 'precise'] { + apt::ppa { 'ppa:pdoes/ppa': require => Apt::Key['4CBEDD5A'], options => '' } + } else { + apt::ppa { 'ppa:pdoes/ppa': require => Apt::Key['4CBEDD5A'] } + } + + if hash_key_equals($php_values, 'install', 1) { + # Ubuntu Lucid 10.04, Precise 12.04, Quantal 12.10 and Raring 13.04 can do PHP 5.3 (default <= 12.10) and 5.4 (default <= 13.04) + if $lsbdistcodename in ['lucid', 'precise', 'quantal', 'raring', 'trusty'] and $php_values['version'] == '54' { + if $lsbdistcodename == 'lucid' { + apt::ppa { 'ppa:ondrej/php5-oldstable': require => Apt::Key['4F4EA0AAE5267A6C'], options => '' } + } else { + apt::ppa { 'ppa:ondrej/php5-oldstable': require => Apt::Key['4F4EA0AAE5267A6C'] } + } + } + # Ubuntu 12.04/10, 13.04/10, 14.04 can do PHP 5.5 + elsif $lsbdistcodename in ['precise', 'quantal', 'raring', 'saucy', 'trusty'] and $php_values['version'] == '55' { + apt::ppa { 'ppa:ondrej/php5': require => Apt::Key['4F4EA0AAE5267A6C'] } + } + elsif $lsbdistcodename in ['lucid'] and $php_values['version'] == '55' { + err('You have chosen to install PHP 5.5 on Ubuntu 10.04 Lucid. This will probably not work!') + } + } + } + 'redhat', 'centos': { + if hash_key_equals($php_values, 'install', 1) { + if $php_values['version'] == '54' { + class { 'yum::repo::remi': } + } + # remi_php55 requires the remi repo as well + elsif $php_values['version'] == '55' { + class { 'yum::repo::remi': } + class { 'yum::repo::remi_php55': } + } + } + } +} + +if is_array($server_values['packages']) and count($server_values['packages']) > 0 { + each( $server_values['packages'] ) |$package| { + if ! defined(Package[$package]) { + package { $package: + ensure => present, + } + } + } +} + +define add_dotdeb ($release){ + apt::source { "${name}-repo.puphpet": + location => 'http://repo.puphpet.com/dotdeb/', + release => $release, + repos => 'all', + required_packages => 'debian-keyring debian-archive-keyring', + key => '89DF5277', + key_server => 'keys.gnupg.net', + include_src => true + } +} + +# Begin open ports for iptables +if has_key($vm_values, 'vm') + and has_key($vm_values['vm'], 'network') + and has_key($vm_values['vm']['network'], 'forwarded_port') +{ + create_resources( iptables_port, $vm_values['vm']['network']['forwarded_port'] ) +} + +if has_key($vm_values, 'ssh') and has_key($vm_values['ssh'], 'port') { + $vm_values_ssh_port = $vm_values['ssh']['port'] ? { + '' => 22, + undef => 22, + 0 => 22, + default => $vm_values['ssh']['port'] + } + + if ! defined(Firewall["100 tcp/${vm_values_ssh_port}"]) { + firewall { "100 tcp/${vm_values_ssh_port}": + port => $vm_values_ssh_port, + proto => tcp, + action => 'accept', + before => Class['my_fw::post'] + } + } +} + +define iptables_port ( + $host, + $guest, +) { + if ! defined(Firewall["100 tcp/${guest}"]) { + firewall { "100 tcp/${guest}": + port => $guest, + proto => tcp, + action => 'accept', + } + } +} + +## Begin MailCatcher manifest + +if $mailcatcher_values == undef { + $mailcatcher_values = hiera('mailcatcher', false) +} + +if hash_key_equals($mailcatcher_values, 'install', 1) { + if ! defined(Package['tilt']) { + package { 'tilt': + ensure => '1.3', + provider => 'gem', + before => Class['mailcatcher'] + } + } + + if $::operatingsystem == 'ubuntu' and $lsbdistcodename == 'trusty' { + package { 'rubygems': + ensure => absent, + } + } + + create_resources('class', { 'mailcatcher' => $mailcatcher_values['settings'] }) + + if ! defined(Firewall["100 tcp/${mailcatcher_values['settings']['smtp_port']}, ${mailcatcher_values['settings']['http_port']}"]) { + firewall { "100 tcp/${mailcatcher_values['settings']['smtp_port']}, ${mailcatcher_values['settings']['http_port']}": + port => [$mailcatcher_values['settings']['smtp_port'], $mailcatcher_values['settings']['http_port']], + proto => tcp, + action => 'accept', + } + } + + if ! defined(Class['supervisord']) { + class{ 'puphpet::python::pip': } + + class { 'supervisord': + install_pip => false, + require => [ + Class['my_fw::post'], + Class['Puphpet::Python::Pip'], + ], + } + } + + $supervisord_mailcatcher_options = sort(join_keys_to_values({ + ' --smtp-ip' => $mailcatcher_values['settings']['smtp_ip'], + ' --smtp-port' => $mailcatcher_values['settings']['smtp_port'], + ' --http-ip' => $mailcatcher_values['settings']['http_ip'], + ' --http-port' => $mailcatcher_values['settings']['http_port'] + }, ' ')) + + $supervisord_mailcatcher_cmd = "mailcatcher ${supervisord_mailcatcher_options} -f >> ${mailcatcher_values['settings']['log']}" + + supervisord::program { 'mailcatcher': + command => $supervisord_mailcatcher_cmd, + priority => '100', + user => 'mailcatcher', + autostart => true, + autorestart => 'true', + environment => { + 'PATH' => "/bin:/sbin:/usr/bin:/usr/sbin:${mailcatcher_values['settings']['path']}" + }, + require => Package['mailcatcher'] + } +} + +## Begin Firewall manifest + +if $firewall_values == undef { + $firewall_values = hiera('firewall', false) +} + +Firewall { + before => Class['my_fw::post'], + require => Class['my_fw::pre'], +} + +class { ['my_fw::pre', 'my_fw::post']: } + +class { 'firewall': } + +class my_fw::pre { + Firewall { + require => undef, + } + + # Default firewall rules + firewall { '000 accept all icmp': + proto => 'icmp', + action => 'accept', + }-> + firewall { '001 accept all to lo interface': + proto => 'all', + iniface => 'lo', + action => 'accept', + }-> + firewall { '002 accept related established rules': + proto => 'all', + state => ['RELATED', 'ESTABLISHED'], + action => 'accept', + } +} + +class my_fw::post { + firewall { '999 drop all': + proto => 'all', + action => 'drop', + before => undef, + } +} + +if is_hash($firewall_values['rules']) and count($firewall_values['rules']) > 0 { + each( $firewall_values['rules'] ) |$key, $rule| { + if ! defined(Firewall["${rule['priority']} ${rule['proto']}/${rule['port']}"]) { + firewall { "${rule['priority']} ${rule['proto']}/${rule['port']}": + port => $rule['port'], + proto => $rule['proto'], + action => $rule['action'], + } + } + } +} + +## Begin Apache manifest + +if $yaml_values == undef { + $yaml_values = loadyaml('/vagrant/vagrant/vms/phraseanet-php54-nginx/puphpet/config.yaml') +} if $apache_values == undef { + $apache_values = $yaml_values['apache'] +} if $php_values == undef { + $php_values = hiera('php', false) +} if $hhvm_values == undef { + $hhvm_values = hiera('hhvm', false) +} + +if hash_key_equals($apache_values, 'install', 1) { + include puphpet::params + include apache::params + + $webroot_location = $puphpet::params::apache_webroot_location + $apache_provider_types = ['virtualbox', 'vmware_fusion', 'vmware_desktop', 'parallels'] + + exec { "exec mkdir -p ${webroot_location}": + command => "mkdir -p ${webroot_location}", + creates => $webroot_location, + } + + if (downcase($::provisioner_type) in $apache_provider_types) and ! defined(File[$webroot_location]) { + file { $webroot_location: + ensure => directory, + mode => 0775, + require => [ + Exec["exec mkdir -p ${webroot_location}"], + Group['www-data'] + ] + } + } elsif ! (downcase($::provisioner_type) in $apache_provider_types) and ! defined(File[$webroot_location]) { + file { $webroot_location: + ensure => directory, + group => 'www-data', + mode => 0775, + require => [ + Exec["exec mkdir -p ${webroot_location}"], + Group['www-data'] + ] + } + } + + if hash_key_equals($hhvm_values, 'install', 1) { + $mpm_module = 'worker' + $disallowed_modules = ['php'] + $apache_conf_template = 'puphpet/apache/hhvm-httpd.conf.erb' + $apache_php_package = 'hhvm' + } elsif hash_key_equals($php_values, 'install', 1) { + $mpm_module = 'prefork' + $disallowed_modules = [] + $apache_conf_template = $apache::params::conf_template + $apache_php_package = 'php' + } else { + $mpm_module = 'prefork' + $disallowed_modules = [] + $apache_conf_template = $apache::params::conf_template + $apache_php_package = '' + } + + if $::operatingsystem == 'ubuntu' + and hash_key_equals($php_values, 'install', 1) + and hash_key_equals($php_values, 'version', 55) + { + $apache_version = '2.4' + } else { + $apache_version = $apache::version::default + } + + $apache_settings = merge($apache_values['settings'], { + 'default_vhost' => false, + 'mpm_module' => $mpm_module, + 'conf_template' => $apache_conf_template, + 'sendfile' => $apache_values['settings']['sendfile'] ? { 1 => 'On', default => 'Off' }, + 'apache_version' => $apache_version + }) + + create_resources('class', { 'apache' => $apache_settings }) + + if hash_key_equals($apache_values, 'mod_pagespeed', 1) { + class { 'puphpet::apache::modpagespeed': } + } + + if hash_key_equals($apache_values, 'mod_spdy', 1) { + class { 'puphpet::apache::modspdy': + php_package => $apache_php_package + } + } + + if $apache_values['settings']['default_vhost'] == true { + $apache_vhosts = merge($apache_values['vhosts'], { + 'default_vhost_80' => { + 'servername' => 'default', + 'docroot' => '/var/www/default', + 'port' => 80, + 'default_vhost' => true, + }, + 'default_vhost_443' => { + 'servername' => 'default', + 'docroot' => '/var/www/default', + 'port' => 443, + 'default_vhost' => true, + 'ssl' => 1, + }, + }) + } else { + $apache_vhosts = $apache_values['vhosts'] + } + + if count($apache_vhosts) > 0 { + each( $apache_vhosts ) |$key, $vhost| { + exec { "exec mkdir -p ${vhost['docroot']} @ key ${key}": + command => "mkdir -p ${vhost['docroot']}", + creates => $vhost['docroot'], + } + + if (downcase($::provisioner_type) in $apache_provider_types) + and ! defined(File[$vhost['docroot']]) + { + file { $vhost['docroot']: + ensure => directory, + mode => 0765, + require => Exec["exec mkdir -p ${vhost['docroot']} @ key ${key}"] + } + } elsif !(downcase($::provisioner_type) in $apache_provider_types) + and ! defined(File[$vhost['docroot']]) + { + file { $vhost['docroot']: + ensure => directory, + group => 'www-user', + mode => 0765, + require => [ + Exec["exec mkdir -p ${vhost['docroot']} @ key ${key}"], + Group['www-user'] + ] + } + } + + create_resources(apache::vhost, { "${key}" => merge($vhost, { + 'custom_fragment' => template('puphpet/apache/custom_fragment.erb'), + 'ssl' => 'ssl' in $vhost and str2bool($vhost['ssl']) ? { true => true, default => false }, + 'ssl_cert' => hash_key_true($vhost, 'ssl_cert') ? { true => $vhost['ssl_cert'], default => undef }, + 'ssl_key' => hash_key_true($vhost, 'ssl_key') ? { true => $vhost['ssl_key'], default => undef }, + 'ssl_chain' => hash_key_true($vhost, 'ssl_chain') ? { true => $vhost['ssl_chain'], default => undef }, + 'ssl_certs_dir' => hash_key_true($vhost, 'ssl_certs_dir') ? { true => $vhost['ssl_certs_dir'], default => undef } + }) + }) + + if ! defined(Firewall["100 tcp/${vhost['port']}"]) { + firewall { "100 tcp/${vhost['port']}": + port => $vhost['port'], + proto => tcp, + action => 'accept', + } + } + } + } + + if ! defined(Firewall['100 tcp/443']) { + firewall { '100 tcp/443': + port => 443, + proto => tcp, + action => 'accept', + } + } + + if count($apache_values['modules']) > 0 { + apache_mod { $apache_values['modules']: } + } +} + +define apache_mod { + if ! defined(Class["apache::mod::${name}"]) and !($name in $disallowed_modules) { + class { "apache::mod::${name}": } + } +} + +## Begin Nginx manifest + +if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} if $php_values == undef { + $php_values = hiera('php', false) +} if $hhvm_values == undef { + $hhvm_values = hiera('hhvm', false) +} + +if hash_key_equals($nginx_values, 'install', 1) { + include nginx::params + include puphpet::params + + Class['puphpet::ssl_cert'] -> Nginx::Resource::Vhost <| |> + + class { 'puphpet::ssl_cert': } + + if $lsbdistcodename == 'lucid' and hash_key_equals($php_values, 'version', '53') { + apt::key { '67E15F46': key_server => 'hkp://keyserver.ubuntu.com:80' } + apt::ppa { 'ppa:l-mierzwa/lucid-php5': + options => '', + require => Apt::Key['67E15F46'] + } + } + + $webroot_location = $puphpet::params::nginx_webroot_location + $nginx_provider_types = ['virtualbox', 'vmware_fusion', 'vmware_desktop', 'parallels'] + + exec { "exec mkdir -p ${webroot_location}": + command => "mkdir -p ${webroot_location}", + creates => $webroot_location, + } + + if (downcase($::provisioner_type) in $nginx_provider_types) and ! defined(File[$webroot_location]) { + file { $webroot_location: + ensure => directory, + mode => 0775, + require => Exec["exec mkdir -p ${webroot_location}"], + } + } elsif ! (downcase($::provisioner_type) in $nginx_provider_types) and ! defined(File[$webroot_location]) { + file { $webroot_location: + ensure => directory, + mode => 0775, + group => 'www-data', + require => [ + Exec["exec mkdir -p ${webroot_location}"], + Group['www-data'] + ] + } + } + + if $::osfamily == 'redhat' { + file { '/usr/share/nginx': + ensure => directory, + mode => 0775, + owner => 'www-data', + group => 'www-data', + require => Group['www-data'], + before => Package['nginx'] + } + } + + if hash_key_equals($php_values, 'install', 1) { + $php5_fpm_sock = '/var/run/php5-fpm.sock' + + $fastcgi_pass = $php_values['version'] ? { + '53' => '127.0.0.1:9000', + undef => null, + default => "unix:${php5_fpm_sock}" + } + + if $::osfamily == 'redhat' and $fastcgi_pass == "unix:${php5_fpm_sock}" { + exec { "create ${php5_fpm_sock} file": + command => "touch ${php5_fpm_sock}", + onlyif => ["test ! -f ${php5_fpm_sock}", "test ! -f ${php5_fpm_sock}="], + require => Package['nginx'], + } + + exec { "'listen = 127.0.0.1:9000' => 'listen = ${php5_fpm_sock}'": + command => "perl -p -i -e 's#listen = 127.0.0.1:9000#listen = ${php5_fpm_sock}#gi' /etc/php-fpm.d/www.conf", + unless => "grep -c 'listen = 127.0.0.1:9000' '${php5_fpm_sock}'", + notify => [ + Class['nginx::service'], + Service['php-fpm'] + ], + require => Exec["create ${php5_fpm_sock} file"] + } + + set_nginx_php5_fpm_sock_group_and_user { 'php_rhel': + require => Exec["create ${php5_fpm_sock} file"], + } + } else { + set_nginx_php5_fpm_sock_group_and_user { 'php': + require => Package['nginx'], + subscribe => Service['php5-fpm'], + } + } + } elsif hash_key_equals($hhvm_values, 'install', 1) { + $fastcgi_pass = '127.0.0.1:9000' + } else { + $fastcgi_pass = null + } + + class { 'nginx': } + + if hash_key_equals($nginx_values['settings'], 'default_vhost', 1) { + $nginx_vhosts = merge($nginx_values['vhosts'], { + 'default' => { + 'server_name' => '_', + 'server_aliases' => [], + 'www_root' => '/var/www/html', + 'listen_port' => 80, + 'index_files' => ['index', 'index.html', 'index.htm', 'index.php'], + 'envvars' => [], + 'ssl' => '0', + 'ssl_cert' => '', + 'ssl_key' => '', + }, + }) + + if ! defined(File[$puphpet::params::nginx_default_conf_location]) { + file { $puphpet::params::nginx_default_conf_location: + ensure => absent, + require => Package['nginx'], + notify => Class['nginx::service'], + } + } + } else { + $nginx_vhosts = $nginx_values['vhosts'] + } + + if count($nginx_vhosts) > 0 { + each( $nginx_vhosts ) |$key, $vhost| { + exec { "exec mkdir -p ${vhost['www_root']} @ key ${key}": + command => "mkdir -p ${vhost['www_root']}", + creates => $vhost['www_root'], + } + + if ! defined(File[$vhost['www_root']]) { + file { $vhost['www_root']: + ensure => directory, + require => Exec["exec mkdir -p ${vhost['www_root']} @ key ${key}"] + } + } + + if ! defined(Firewall["100 tcp/${vhost['listen_port']}"]) { + firewall { "100 tcp/${vhost['listen_port']}": + port => $vhost['listen_port'], + proto => tcp, + action => 'accept', + } + } + } + + create_resources(nginx_vhost, $nginx_vhosts) + } + + if ! defined(Firewall['100 tcp/443']) { + firewall { '100 tcp/443': + port => 443, + proto => tcp, + action => 'accept', + } + } +} + +define nginx_vhost ( + $server_name, + $server_aliases = [], + $www_root, + $listen_port, + $index_files, + $envvars = [], + $ssl = false, + $ssl_cert = $puphpet::params::ssl_cert_location, + $ssl_key = $puphpet::params::ssl_key_location, + $ssl_port = '443', + $rewrite_to_https = false, + $spdy = $nginx::params::nx_spdy, +){ + $merged_server_name = concat([$server_name], $server_aliases) + + if is_array($index_files) and count($index_files) > 0 { + $try_files = $index_files[count($index_files) - 1] + } else { + $try_files = 'index.php' + } + + if hash_key_equals($php_values, 'install', 1) { + $fastcgi_param_parts = [ + 'PATH_INFO $fastcgi_path_info', + 'PATH_TRANSLATED $document_root$fastcgi_path_info', + 'SCRIPT_FILENAME $document_root$fastcgi_script_name' + ] + } elsif hash_key_equals($hhvm_values, 'install', 1) { + $fastcgi_param_parts = [ + 'SCRIPT_FILENAME $document_root$fastcgi_script_name' + ] + } else { + $fastcgi_param_parts = [] + } + + $ssl_set = value_true($ssl) ? { true => true, default => false, } + $ssl_cert_set = value_true($ssl_cert) ? { true => $ssl_cert, default => $puphpet::params::ssl_cert_location, } + $ssl_key_set = value_true($ssl_key) ? { true => $ssl_key, default => $puphpet::params::ssl_key_location, } + $ssl_port_set = value_true($ssl_port) ? { true => $ssl_port, default => '443', } + $rewrite_to_https_set = value_true($rewrite_to_https) ? { true => true, default => false, } + $spdy_set = value_true($spdy) ? { true => on, default => off, } + + nginx::resource::vhost { $server_name: + server_name => $merged_server_name, + www_root => $www_root, + listen_port => $listen_port, + index_files => $index_files, + try_files => ['$uri', '$uri/','@rewriteapp'], + ssl => $ssl_set, + ssl_cert => $ssl_cert_set, + ssl_key => $ssl_key_set, + ssl_port => $ssl_port_set, + rewrite_to_https => $rewrite_to_https_set, + spdy => $spdy_set, + vhost_cfg_append => { + sendfile => 'off' + } + } + + $fastcgi_param = concat($fastcgi_param_parts, $envvars) + + $fastcgi_pass_hash = fastcgi_pass ? { + null => {}, + '' => {}, + default => {'fastcgi_pass' => $fastcgi_pass}, + } + + $location_cfg_append = merge({ + 'fastcgi_index' => 'index.php', + 'fastcgi_param' => $fastcgi_param, + 'include' => 'fastcgi_params' + }, $fastcgi_pass_hash) + + nginx::resource::location { "${server_name}-php": + ensure => present, + location => '@rewriteapp', + vhost => $server_name, + www_root => $www_root, + location_cfg_append => { + rewrite => '^(.*)$ /index.php/$1 last' + } + } + + nginx::resource::location { "${server_name}-php1": + ensure => present, + location => '/api', + vhost => $server_name, + www_root => $www_root, + location_cfg_append => { + rewrite => '^(.*)$ /index.php/$1 last' + } + } + + nginx::resource::location { "${server_name}-php2": + ensure => present, + location => '~ ^/(index|index_dev|api)\.php(/|$)', + vhost => $server_name, + www_root => $www_root, + location_cfg_append => $location_cfg_append, + notify => Class['nginx::service'], + } +} + +define set_nginx_php5_fpm_sock_group_and_user () { + exec { 'set php5_fpm_sock group and user': + command => "chmod 660 ${php5_fpm_sock} && \ + chown www-data ${php5_fpm_sock} && \ + chgrp www-data ${php5_fpm_sock} && \ + touch /.puphpet-stuff/php5_fpm_sock", + creates => '/.puphpet-stuff/php5_fpm_sock', + } +} + +## Begin PHP manifest + +if $php_values == undef { + $php_values = hiera('php', false) +} if $apache_values == undef { + $apache_values = hiera('apache', false) +} if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} if $mailcatcher_values == undef { + $mailcatcher_values = hiera('mailcatcher', false) +} + +if hash_key_equals($php_values, 'install', 1) { + Class['Php'] -> Class['Php::Devel'] -> Php::Module <| |> -> Php::Pear::Module <| |> -> Php::Pecl::Module <| |> + + if $php_prefix == undef { + $php_prefix = $::operatingsystem ? { + /(?i:Ubuntu|Debian|Mint|SLES|OpenSuSE)/ => 'php5-', + default => 'php-', + } + } + + if $php_fpm_ini == undef { + $php_fpm_ini = $::operatingsystem ? { + /(?i:Ubuntu|Debian|Mint|SLES|OpenSuSE)/ => '/etc/php5/fpm/php.ini', + default => '/etc/php.ini', + } + } + + if hash_key_equals($apache_values, 'install', 1) { + include apache::params + + if has_key($apache_values, 'mod_spdy') and $apache_values['mod_spdy'] == 1 { + $php_webserver_service_ini = 'cgi' + } else { + $php_webserver_service_ini = 'httpd' + } + + $php_webserver_service = 'httpd' + $php_webserver_user = $apache::params::user + $php_webserver_restart = true + + class { 'php': + service => $php_webserver_service + } + } elsif hash_key_equals($nginx_values, 'install', 1) { + include nginx::params + + $php_webserver_service = "${php_prefix}fpm" + $php_webserver_service_ini = $php_webserver_service + $php_webserver_user = $nginx::params::nx_daemon_user + $php_webserver_restart = true + + class { 'php': + package => $php_webserver_service, + service => $php_webserver_service, + service_autorestart => false, + config_file => $php_fpm_ini, + } + + service { $php_webserver_service: + ensure => running, + enable => true, + hasrestart => true, + hasstatus => true, + require => Package[$php_webserver_service] + } + } else { + $php_webserver_service = undef + $php_webserver_service_ini = undef + $php_webserver_restart = false + + class { 'php': + package => "${php_prefix}cli", + service => $php_webserver_service, + service_autorestart => false, + } + } + + class { 'php::devel': } + + if count($php_values['modules']['php']) > 0 { + php_mod { $php_values['modules']['php']:; } + } + if count($php_values['modules']['pear']) > 0 { + php_pear_mod { $php_values['modules']['pear']:; } + } + if count($php_values['modules']['pecl']) > 0 { + php_pecl_mod { $php_values['modules']['pecl']:; } + } + if count($php_values['ini']) > 0 { + each( $php_values['ini'] ) |$key, $value| { + if is_array($value) { + each( $php_values['ini'][$key] ) |$innerkey, $innervalue| { + puphpet::ini { "${key}_${innerkey}": + entry => "CUSTOM_${innerkey}/${key}", + value => $innervalue, + php_version => $php_values['version'], + webserver => $php_webserver_service_ini + } + } + } else { + puphpet::ini { $key: + entry => "CUSTOM/${key}", + value => $value, + php_version => $php_values['version'], + webserver => $php_webserver_service_ini + } + } + } + + if $php_values['ini']['session.save_path'] != undef { + $php_sess_save_path = $php_values['ini']['session.save_path'] + + exec {"mkdir -p ${php_sess_save_path}": + onlyif => "test ! -d ${php_sess_save_path}", + before => Class['php'] + } + exec {"chmod 775 ${php_sess_save_path} && chown www-data ${php_sess_save_path} && chgrp www-data ${php_sess_save_path}": + require => Class['php'] + } + } + } + + puphpet::ini { $key: + entry => 'CUSTOM/date.timezone', + value => $php_values['timezone'], + php_version => $php_values['version'], + webserver => $php_webserver_service_ini + } + + if hash_key_equals($php_values, 'composer', 1) { + $php_composer_home = $php_values['composer_home'] ? { + false => false, + undef => false, + '' => false, + default => $php_values['composer_home'], + } + + if $php_composer_home { + file { $php_composer_home: + ensure => directory, + owner => 'www-data', + group => 'www-data', + mode => 0775, + require => [Group['www-data'], Group['www-user']] + } + + file_line { "COMPOSER_HOME=${php_composer_home}": + path => '/etc/environment', + line => "COMPOSER_HOME=${php_composer_home}", + } + } + + class { 'composer': + target_dir => '/usr/local/bin', + composer_file => 'composer', + download_method => 'curl', + logoutput => false, + tmp_path => '/tmp', + php_package => "${php::params::module_prefix}cli", + curl_package => 'curl', + suhosin_enabled => false, + } + } + + # Usually this would go within the library that needs in (Mailcatcher) + # but the values required are sufficiently complex that it's easier to + # add here + if hash_key_equals($mailcatcher_values, 'install', 1) + and ! defined(Puphpet::Ini['sendmail_path']) + { + puphpet::ini { 'sendmail_path': + entry => 'CUSTOM/sendmail_path', + value => '/usr/bin/env catchmail', + php_version => $php_values['version'], + webserver => $php_webserver_service_ini + } + } +} + +define php_mod { + if ! defined(Puphpet::Php::Module[$name]) { + puphpet::php::module { $name: + service_autorestart => $php_webserver_restart, + } + } +} +define php_pear_mod { + if ! defined(Puphpet::Php::Pear[$name]) { + puphpet::php::pear { $name: + service_autorestart => $php_webserver_restart, + } + } +} +define php_pecl_mod { + if ! defined(Puphpet::Php::Extra_repos[$name]) { + puphpet::php::extra_repos { $name: + before => Puphpet::Php::Pecl[$name], + } + } + + if ! defined(Puphpet::Php::Pecl[$name]) { + puphpet::php::pecl { $name: + service_autorestart => $php_webserver_restart, + } + } +} + +## Begin Xdebug manifest + +if $xdebug_values == undef { + $xdebug_values = hiera('xdebug', false) +} if $php_values == undef { + $php_values = hiera('php', false) +} if $apache_values == undef { + $apache_values = hiera('apache', false) +} if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if hash_key_equals($apache_values, 'install', 1) { + $xdebug_webserver_service = 'httpd' +} elsif hash_key_equals($nginx_values, 'install', 1) { + $xdebug_webserver_service = 'nginx' +} else { + $xdebug_webserver_service = undef +} + +if hash_key_equals($xdebug_values, 'install', 1) + and hash_key_equals($php_values, 'install', 1) +{ + class { 'puphpet::xdebug': + webserver => $xdebug_webserver_service + } + + if is_hash($xdebug_values['settings']) and count($xdebug_values['settings']) > 0 { + each( $xdebug_values['settings'] ) |$key, $value| { + puphpet::ini { $key: + entry => "XDEBUG/${key}", + value => $value, + php_version => $php_values['version'], + webserver => $xdebug_webserver_service + } + } + } +} + +## Begin Drush manifest + +if $drush_values == undef { + $drush_values = hiera('drush', false) +} + +if hash_key_equals($drush_values, 'install', 1) { + if ($drush_values['settings']['drush.tag_branch'] != undef) { + $drush_tag_branch = $drush_values['settings']['drush.tag_branch'] + } else { + $drush_tag_branch = '' + } + + include drush::git::drush +} + +## Begin MySQL manifest + +if $mysql_values == undef { + $mysql_values = hiera('mysql', false) +} if $php_values == undef { + $php_values = hiera('php', false) +} if $apache_values == undef { + $apache_values = hiera('apache', false) +} if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +include 'mysql::params' + +if hash_key_equals($mysql_values, 'install', 1) { + if hash_key_equals($apache_values, 'install', 1) or hash_key_equals($nginx_values, 'install', 1) { + $mysql_webserver_restart = true + } else { + $mysql_webserver_restart = false + } + + if $::osfamily == 'redhat' { + exec { 'mysql-community-repo': + command => 'yum -y --nogpgcheck install "http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm" && touch /.puphpet-stuff/mysql-community-release', + creates => '/.puphpet-stuff/mysql-community-release' + } + + $mysql_server_require = Exec['mysql-community-repo'] + $mysql_server_server_package_name = 'mysql-community-server' + $mysql_server_client_package_name = 'mysql-community-client' + } else { + $mysql_server_require = [] + $mysql_server_server_package_name = $mysql::params::server_package_name + $mysql_server_client_package_name = $mysql::params::client_package_name + } + + if hash_key_equals($php_values, 'install', 1) { + $mysql_php_installed = true + $mysql_php_package = 'php' + } elsif hash_key_equals($hhvm_values, 'install', 1) { + $mysql_php_installed = true + $mysql_php_package = 'hhvm' + } else { + $mysql_php_installed = false + } + + if $mysql_values['root_password'] { + class { 'mysql::server': + package_name => $mysql_server_server_package_name, + root_password => $mysql_values['root_password'], + require => $mysql_server_require + } + + class { 'mysql::client': + package_name => $mysql_server_client_package_name, + require => $mysql_server_require + } + + if is_hash($mysql_values['databases']) and count($mysql_values['databases']) > 0 { + create_resources(mysql_db, $mysql_values['databases']) + } + + if $mysql_php_installed and $mysql_php_package == 'php' { + if $::osfamily == 'redhat' and $php_values['version'] == '53' { + $mysql_php_module = 'mysql' + } elsif $lsbdistcodename == 'lucid' or $lsbdistcodename == 'squeeze' { + $mysql_php_module = 'mysql' + } else { + $mysql_php_module = 'mysqlnd' + } + + if ! defined(Php::Module[$mysql_php_module]) { + php::module { $mysql_php_module: + service_autorestart => $mysql_webserver_restart, + } + } + } + } + + if hash_key_equals($mysql_values, 'adminer', 1) and $mysql_php_installed { + if hash_key_equals($apache_values, 'install', 1) { + $mysql_adminer_webroot_location = '/var/www/default' + } elsif hash_key_equals($nginx_values, 'install', 1) { + $mysql_adminer_webroot_location = $puphpet::params::nginx_webroot_location + } else { + $mysql_adminer_webroot_location = '/var/www/default' + } + + class { 'puphpet::adminer': + location => "${mysql_adminer_webroot_location}/adminer", + owner => 'www-data', + php_package => $mysql_php_package + } + } +} + +define mysql_db ( + $user, + $password, + $host, + $grant = [], + $sql_file = false +) { + if $name == '' or $password == '' or $host == '' { + fail( 'MySQL DB requires that name, password and host be set. Please check your settings!' ) + } + + mysql::db { $name: + user => $user, + password => $password, + host => $host, + grant => $grant, + sql => $sql_file, + } +} + +# @todo update this +define mysql_nginx_default_conf ( + $webroot +) { + if $php5_fpm_sock == undef { + $php5_fpm_sock = '/var/run/php5-fpm.sock' + } + + if $fastcgi_pass == undef { + $fastcgi_pass = $php_values['version'] ? { + undef => null, + '53' => '127.0.0.1:9000', + default => "unix:${php5_fpm_sock}" + } + } + + class { 'puphpet::nginx': + fastcgi_pass => $fastcgi_pass, + notify => Class['nginx::service'], + } +} + +## Begin PostgreSQL manifest + +if $postgresql_values == undef { + $postgresql_values = hiera('postgresql', false) +} if $php_values == undef { + $php_values = hiera('php', false) +} if $hhvm_values == undef { + $hhvm_values = hiera('hhvm', false) +} + +if hash_key_equals($postgresql_values, 'install', 1) { + if hash_key_equals($apache_values, 'install', 1) or hash_key_equals($nginx_values, 'install', 1) { + $postgresql_webserver_restart = true + } else { + $postgresql_webserver_restart = false + } + + if hash_key_equals($php_values, 'install', 1) { + $postgresql_php_installed = true + $postgresql_php_package = 'php' + } elsif hash_key_equals($hhvm_values, 'install', 1) { + $postgresql_php_installed = true + $postgresql_php_package = 'hhvm' + } else { + $postgresql_php_installed = false + } + + if $postgresql_values['settings']['root_password'] { + group { $postgresql_values['settings']['user_group']: + ensure => present + } + + class { 'postgresql::globals': + manage_package_repo => true, + encoding => $postgresql_values['settings']['encoding'], + version => $postgresql_values['settings']['version'] + }-> + class { 'postgresql::server': + postgres_password => $postgresql_values['settings']['root_password'], + version => $postgresql_values['settings']['version'], + require => Group[$postgresql_values['settings']['user_group']] + } + + if is_hash($postgresql_values['databases']) and count($postgresql_values['databases']) > 0 { + create_resources(postgresql_db, $postgresql_values['databases']) + } + + if $postgresql_php_installed and $postgresql_php_package == 'php' and ! defined(Php::Module['pgsql']) { + php::module { 'pgsql': + service_autorestart => $postgresql_webserver_restart, + } + } + } + + if hash_key_equals($postgresql_values, 'adminer', 1) and $postgresql_php_installed { + if hash_key_equals($apache_values, 'install', 1) { + $postgresql_adminer_webroot_location = '/var/www/default' + } elsif hash_key_equals($nginx_values, 'install', 1) { + $postgresql_adminer_webroot_location = $puphpet::params::nginx_webroot_location + } else { + $postgresql_adminer_webroot_location = '/var/www/default' + } + + class { 'puphpet::adminer': + location => "${postgresql_adminer_webroot_location}/adminer", + owner => 'www-data', + php_package => $postgresql_php_package + } + } +} + +define postgresql_db ( + $user, + $password, + $grant, + $sql_file = false +) { + if $name == '' or $user == '' or $password == '' or $grant == '' { + fail( 'PostgreSQL DB requires that name, user, password and grant be set. Please check your settings!' ) + } + + postgresql::server::db { $name: + user => $user, + password => $password, + grant => $grant + } + + if $sql_file { + $table = "${name}.*" + + exec{ "${name}-import": + command => "sudo -u postgres psql ${name} < ${sql_file}", + logoutput => true, + refreshonly => $refresh, + require => Postgresql::Server::Db[$name], + onlyif => "test -f ${sql_file}" + } + } +} + +## Begin MariaDb manifest + +if $mariadb_values == undef { + $mariadb_values = hiera('mariadb', false) +} if $php_values == undef { + $php_values = hiera('php', false) +} if $hhvm_values == undef { + $hhvm_values = hiera('hhvm', false) +} if $apache_values == undef { + $apache_values = hiera('apache', false) +} if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if hash_key_equals($mariadb_values, 'install', 1) { + if hash_key_equals($apache_values, 'install', 1) or hash_key_equals($nginx_values, 'install', 1) { + $mariadb_webserver_restart = true + } else { + $mariadb_webserver_restart = false + } + + if hash_key_equals($php_values, 'install', 1) { + $mariadb_php_installed = true + $mariadb_php_package = 'php' + } elsif hash_key_equals($hhvm_values, 'install', 1) { + $mariadb_php_installed = true + $mariadb_php_package = 'hhvm' + } else { + $mariadb_php_installed = false + } + + if has_key($mariadb_values, 'root_password') and $mariadb_values['root_password'] { + include 'mysql::params' + + if (! defined(File[$mysql::params::datadir])) { + file { $mysql::params::datadir : + ensure => directory, + group => $mysql::params::root_group, + before => Class['mysql::server'] + } + } + + if ! defined(Group['mysql']) { + group { 'mysql': + ensure => present + } + } + + if ! defined(User['mysql']) { + user { 'mysql': + ensure => present, + } + } + + if (! defined(File['/var/run/mysqld'])) { + file { '/var/run/mysqld' : + ensure => directory, + group => 'mysql', + owner => 'mysql', + before => Class['mysql::server'], + require => [User['mysql'], Group['mysql']], + notify => Service['mysql'], + } + } + + if ! defined(File[$mysql::params::socket]) { + file { $mysql::params::socket : + ensure => file, + group => $mysql::params::root_group, + before => Class['mysql::server'], + require => File[$mysql::params::datadir] + } + } + + if ! defined(Package['mysql-libs']) { + package { 'mysql-libs': + ensure => purged, + before => Class['mysql::server'], + } + } + + class { 'puphpet::mariadb': + version => $mariadb_values['version'] + } + + class { 'mysql::server': + package_name => $puphpet::params::mariadb_package_server_name, + root_password => $mariadb_values['root_password'], + service_name => 'mysql', + } + + class { 'mysql::client': + package_name => $puphpet::params::mariadb_package_client_name + } + + if is_hash($mariadb_values['databases']) and count($mariadb_values['databases']) > 0 { + create_resources(mariadb_db, $mariadb_values['databases']) + } + + if $mariadb_php_installed and $mariadb_php_package == 'php' { + if $::osfamily == 'redhat' and $php_values['version'] == '53' { + $mariadb_php_module = 'mysql' + } elsif $lsbdistcodename == 'lucid' or $lsbdistcodename == 'squeeze' { + $mariadb_php_module = 'mysql' + } else { + $mariadb_php_module = 'mysqlnd' + } + + if ! defined(Php::Module[$mariadb_php_module]) { + php::module { $mariadb_php_module: + service_autorestart => $mariadb_webserver_restart, + } + } + } + } + + if hash_key_equals($mariadb_values, 'adminer', 1) and $mariadb_php_installed { + if hash_key_equals($apache_values, 'install', 1) { + $mariadb_adminer_webroot_location = '/var/www/default' + } elsif hash_key_equals($nginx_values, 'install', 1) { + $mariadb_adminer_webroot_location = $puphpet::params::nginx_webroot_location + } else { + $mariadb_adminer_webroot_location = '/var/www/default' + } + + class { 'puphpet::adminer': + location => "${mariadb_adminer_webroot_location}/adminer", + owner => 'www-data', + php_package => $mariadb_php_package + } + } +} + +define mariadb_db ( + $user, + $password, + $host, + $grant = [], + $sql_file = false +) { + if $name == '' or $password == '' or $host == '' { + fail( 'MariaDB requires that name, password and host be set. Please check your settings!' ) + } + + mysql::db { $name: + user => $user, + password => $password, + host => $host, + grant => $grant, + sql => $sql_file, + } +} + +# @todo update this! +define mariadb_nginx_default_conf ( + $webroot +) { + if $php5_fpm_sock == undef { + $php5_fpm_sock = '/var/run/php5-fpm.sock' + } + + if $fastcgi_pass == undef { + $fastcgi_pass = $php_values['version'] ? { + undef => null, + '53' => '127.0.0.1:9000', + default => "unix:${php5_fpm_sock}" + } + } + + class { 'puphpet::nginx': + fastcgi_pass => $fastcgi_pass, + notify => Class['nginx::service'], + } +} + +## Begin SQLite manifest + +if $sqlite_values == undef { + $sqlite_values = hiera('sqlite', false) +} if $php_values == undef { + $php_values = hiera('php', false) +} if $apache_values == undef { + $apache_values = hiera('apache', false) +} if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} if $mailcatcher_values == undef { + $mailcatcher_values = hiera('mailcatcher', false) +} + +if hash_key_equals($sqlite_values, 'install', 1) { + if hash_key_equals($php_values, 'install', 1) { + $sqlite_php_installed = true + $sqlite_php_package = 'php' + } elsif hash_key_equals($hhvm_values, 'install', 1) { + $sqlite_php_installed = true + $sqlite_php_package = 'hhvm' + } else { + $sqlite_php_installed = false + } + + # puppet manifests for mailcatcher and sqlite are not compatible. + if hash_key_equals($mailcatcher_values, 'install', 0) { + class { 'sqlite': } + } + + if is_hash($sqlite_values['databases']) and count($sqlite_values['databases']) > 0 { + create_resources(sqlite_db, $sqlite_values['databases']) + } + + if $sqlite_php_installed and $sqlite_php_package == 'php' and ! defined(Php::Module['sqlite']) { + php::module { 'sqlite': + service_autorestart => true, + } + } +} + +define sqlite_db ( + $name, + $owner, + $group = 0, + $mode = 0775, + $sql_file = false +) { + if $name == '' or $owner == '' or $mode == '' { + fail( 'SQLite requires that name, owner, group, and mode be set. Please check your settings!' ) + } + + # ensure user and directory created + user { $owner: + ensure => present, + groups => $owner + }-> + file { '/var/lib/sqlite': + ensure => directory, + owner => $owner, + group => $group, + mode => 0775 + }-> + sqlite::db { $name: + owner => $owner, + group => $group, + mode => $mode + } + + if $sql_file { + exec{ "${name}-import": + command => "cat ${sql_file} | sudo sqlite3 /var/lib/sqlite/${name}.db", + logoutput => true, + refreshonly => $refresh, + require => Sqlite::Db[$name], + onlyif => "test -f ${sql_file}" + } + } +} + +## Begin MongoDb manifest + +if $mongodb_values == undef { + $mongodb_values = hiera('mongodb', false) +} if $php_values == undef { + $php_values = hiera('php', false) +} if $apache_values == undef { + $apache_values = hiera('apache', false) +} if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if hash_key_equals($apache_values, 'install', 1) + or hash_key_equals($nginx_values, 'install', 1) +{ + $mongodb_webserver_restart = true +} else { + $mongodb_webserver_restart = false +} + +if hash_key_equals($mongodb_values, 'install', 1) { + file { ['/data', '/data/db']: + ensure => directory, + mode => 0775, + before => Class['Mongodb::Globals'], + } + + Class['Mongodb::Globals'] -> Class['Mongodb::Server'] + + class { 'mongodb::globals': + manage_package_repo => true, + } + + create_resources('class', { 'mongodb::server' => $mongodb_values['settings'] }) + + if $::osfamily == 'redhat' { + class { '::mongodb::client': + require => Class['::Mongodb::Server'] + } + } + + if is_hash($mongodb_values['databases']) and count($mongodb_values['databases']) > 0 { + create_resources(mongodb_db, $mongodb_values['databases']) + } + + if hash_key_equals($php_values, 'install', 1) and ! defined(Puphpet::Php::Pecl['mongo']) { + puphpet::php::pecl { 'mongo': + service_autorestart => $mongodb_webserver_restart, + require => Class['mongodb::server'] + } + } +} + +define mongodb_db ( + $user, + $password +) { + if $name == '' or $password == '' { + fail( 'MongoDB requires that name and password be set. Please check your settings!' ) + } + + mongodb::db { $name: + user => $user, + password => $password + } +} + +# Begin redis + +if $redis_values == undef { + $redis_values = hiera('redis', false) +} if $php_values == undef { + $php_values = hiera('php', false) +} if $apache_values == undef { + $apache_values = hiera('apache', false) +} if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if hash_key_equals($apache_values, 'install', 1) + or hash_key_equals($nginx_values, 'install', 1) +{ + $redis_webserver_restart = true +} else { + $redis_webserver_restart = false +} + +if hash_key_equals($redis_values, 'install', 1) { + create_resources('class', { 'redis' => $redis_values['settings'] }) + + if hash_key_equals($php_values, 'install', 1) and ! defined(Php::Pecl::Module['redis']) { + php::pecl::module { 'redis': + use_package => false, + service_autorestart => $redis_webserver_restart, + require => Class['redis'] + } + } +} + +# Begin beanstalkd + +if $beanstalkd_values == undef { + $beanstalkd_values = hiera('beanstalkd', false) +} if $php_values == undef { + $php_values = hiera('php', false) +} if $hhvm_values == undef { + $hhvm_values = hiera('hhvm', false) +} if $apache_values == undef { + $apache_values = hiera('apache', false) +} if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if hash_key_equals($apache_values, 'install', 1) { + $beanstalk_console_webroot_location = '/var/www/default/beanstalk_console' +} elsif hash_key_equals($nginx_values, 'install', 1) { + $beanstalk_console_webroot_location = "${puphpet::params::nginx_webroot_location}/beanstalk_console" +} else { + $beanstalk_console_webroot_location = undef +} + +if hash_key_equals($php_values, 'install', 1) or hash_key_equals($hhvm_values, 'install', 1) { + $beanstalkd_php_installed = true +} else { + $beanstalkd_php_installed = false +} + +if hash_key_equals($beanstalkd_values, 'install', 1) { + create_resources(beanstalkd::config, { 'beanstalkd' => $beanstalkd_values['settings'] }) + + if hash_key_equals($beanstalkd_values, 'beanstalk_console', 1) + and $beanstalk_console_webroot_location != undef + and $beanstalkd_php_installed + { + exec { 'delete-beanstalk_console-path-if-not-git-repo': + command => "rm -rf ${beanstalk_console_webroot_location}", + onlyif => "test ! -d ${beanstalk_console_webroot_location}/.git" + } + + vcsrepo { $beanstalk_console_webroot_location: + ensure => present, + provider => git, + source => 'https://github.com/ptrofimov/beanstalk_console.git', + require => Exec['delete-beanstalk_console-path-if-not-git-repo'] + } + + file { "${beanstalk_console_webroot_location}/storage.json": + ensure => present, + group => 'www-data', + mode => 0775, + require => Vcsrepo[$beanstalk_console_webroot_location] + } + } +} + +# Begin rabbitmq + +if $rabbitmq_values == undef { + $rabbitmq_values = hiera('rabbitmq', false) +} if $php_values == undef { + $php_values = hiera('php', false) +} if $apache_values == undef { + $apache_values = hiera('apache', false) +} if $nginx_values == undef { + $nginx_values = hiera('nginx', false) +} + +if hash_key_equals($apache_values, 'install', 1) + or hash_key_equals($nginx_values, 'install', 1) +{ + $rabbitmq_webserver_restart = true +} else { + $rabbitmq_webserver_restart = false +} + +if hash_key_equals($rabbitmq_values, 'install', 1) { + if $::osfamily == 'redhat' { + Class['erlang'] -> Class['rabbitmq'] + include 'erlang' + } + + create_resources('class', { 'rabbitmq' => $rabbitmq_values['settings'] }) + + if hash_key_equals($php_values, 'install', 1) and ! defined(Php::Pecl::Module['amqp']) { + php::pecl::module { 'amqp': + use_package => false, + service_autorestart => $rabbitmq_webserver_restart, + require => Class['rabbitmq'] + } + } + + if ! defined(Firewall['100 tcp/15672']) { + firewall { '100 tcp/15672': + port => 15672, + proto => tcp, + action => 'accept', + } + } +} + +# Begin elastic search + +if $elasticsearch_values == undef { + $elasticsearch_values = hiera('elastic_search', false) +} + +if hash_key_equals($elasticsearch_values, 'install', 1) { + case $::osfamily { + 'debian': { $elasticsearch_package_url = 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.1.deb' } + 'redhat': { $elasticsearch_package_url = 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.1.noarch.rpm' } + default: { fail('Unrecognized operating system for Elastic Search') } + } + + $elasticsearch_settings = merge($elasticsearch_values['settings'], { + 'package_url' => $elasticsearch_package_url, + require => Class['my_fw::post'], + }) + + create_resources('class', { 'elasticsearch' => $elasticsearch_settings }) +} \ No newline at end of file diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.fixtures.yml new file mode 100644 index 0000000000..b5f76c03ac --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.fixtures.yml @@ -0,0 +1,6 @@ +fixtures: + repositories: + stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git" + concat: "git://github.com/puppetlabs/puppetlabs-concat.git" + symlinks: + apache: "#{source_dir}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.nodeset.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.nodeset.yml new file mode 100644 index 0000000000..767f9cd2f6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.nodeset.yml @@ -0,0 +1,31 @@ +--- +default_set: 'centos-64-x64' +sets: + 'centos-59-x64': + nodes: + "main.foo.vm": + prefab: 'centos-59-x64' + 'centos-64-x64': + nodes: + "main.foo.vm": + prefab: 'centos-64-x64' + 'fedora-18-x64': + nodes: + "main.foo.vm": + prefab: 'fedora-18-x64' + 'debian-607-x64': + nodes: + "main.foo.vm": + prefab: 'debian-607-x64' + 'debian-70rc1-x64': + nodes: + "main.foo.vm": + prefab: 'debian-70rc1-x64' + 'ubuntu-server-10044-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-10044-x64' + 'ubuntu-server-12042-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-12042-x64' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.puppet-lint.rc b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.puppet-lint.rc new file mode 100644 index 0000000000..df733ca811 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.puppet-lint.rc @@ -0,0 +1,5 @@ +--no-single_quote_string_with_variables-check +--no-80chars-check +--no-class_inherits_from_params_class-check +--no-class_parameter_defaults-check +--no-documentation-check diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.travis.yml new file mode 100644 index 0000000000..1d00b8eb04 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/.travis.yml @@ -0,0 +1,32 @@ +--- +branches: + only: + - master +language: ruby +bundler_args: --without development +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 +env: + matrix: + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - PUPPET_GEM_VERSION="~> 3.0" + - PUPPET_GEM_VERSION="~> 3.5.0" STRICT_VARIABLES="yes" +matrix: + fast_finish: true + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 3.2.0" +notifications: + email: false diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/CHANGELOG.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/CHANGELOG.md new file mode 100644 index 0000000000..26e8d75d4d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/CHANGELOG.md @@ -0,0 +1,246 @@ +## 2014-03-04 Supported Release 1.0.1 +###Summary + +This is a supported release. This release removes a testing symlink that can +cause trouble on systems where /var is on a seperate filesystem from the +modulepath. + +####Features +####Bugfixes +####Known Bugs +* By default, the version of Apache that ships with Ubuntu 10.04 does not work with `wsgi_import_script`. +* SLES is unsupported. + +## 2014-03-04 Supported Release 1.0.0 +###Summary + +This is a supported release. This release introduces Apache 2.4 support for +Debian and RHEL based osfamilies. + +####Features + +- Add apache24 support +- Add rewrite_base functionality to rewrites +- Updated README documentation +- Add WSGIApplicationGroup and WSGIImportScript directives + +####Bugfixes + +- Replace mutating hashes with merge() for Puppet 3.5 +- Fix WSGI import_script and mod_ssl issues on Lucid + +####Known Bugs +* By default, the version of Apache that ships with Ubuntu 10.04 does not work with `wsgi_import_script`. +* SLES is unsupported. + +--- + +## 2014-01-31 Release 0.11.0 +### Summary: + +This release adds preliminary support for Windows compatibility and multiple rewrite support. + +#### Backwards-incompatible Changes: + +- The rewrite_rule parameter is deprecated in favor of the new rewrite parameter + and will be removed in a future release. + +#### Features: + +- add Match directive +- quote paths for windows compatibility +- add auth_group_file option to README.md +- allow AuthGroupFile directive for vhosts +- Support Header directives in vhost context +- Don't purge mods-available dir when separate enable dir is used +- Fix the servername used in log file name +- Added support for mod_include +- Remove index parameters. +- Support environment variable control for CustomLog +- added redirectmatch support +- Setting up the ability to do multiple rewrites and conditions. +- Convert spec tests to beaker. +- Support php_admin_(flag|value)s + +#### Bugfixes: + +- directories are either a Hash or an Array of Hashes +- Configure Passenger in separate .conf file on RH so PassengerRoot isn't lost +- (docs) Update list of `apache::mod::[name]` classes +- (docs) Fix apache::namevirtualhost example call style +- Fix $ports_file reference in apache::listen. +- Fix $ports_file reference in Namevirtualhost. + + +## 2013-12-05 Release 0.10.0 +### Summary: + +This release adds FreeBSD osfamily support and various other improvements to some mods. + +#### Features: + +- Add suPHP_UserGroup directive to directory context +- Add support for ScriptAliasMatch directives +- Set SSLOptions StdEnvVars in server context +- No implicit entry for ScriptAlias path +- Add support for overriding ErrorDocument +- Add support for AliasMatch directives +- Disable default "allow from all" in vhost-directories +- Add WSGIPythonPath as an optional parameter to mod_wsgi. +- Add mod_rpaf support +- Add directives: IndexOptions, IndexOrderDefault +- Add ability to include additional external configurations in vhost +- need to use the provider variable not the provider key value from the directory hash for matches +- Support for FreeBSD and few other features +- Add new params to apache::mod::mime class +- Allow apache::mod to specify module id and path +- added $server_root parameter +- Add Allow and ExtendedStatus support to mod_status +- Expand vhost/_directories.pp directive support +- Add initial support for nss module (no directives in vhost template yet) +- added peruser and event mpms +- added $service_name parameter +- add parameter for TraceEnable +- Make LogLevel configurable for server and vhost +- Add documentation about $ip +- Add ability to pass ip (instead of wildcard) in default vhost files + +#### Bugfixes: + +- Don't listen on port or set NameVirtualHost for non-existent vhost +- only apply Directory defaults when provider is a directory +- Working mod_authnz_ldap support on Debian/Ubuntu + +## 2013-09-06 Release 0.9.0 +### Summary: +This release adds more parameters to the base apache class and apache defined +resource to make the module more flexible. It also adds or enhances SuPHP, +WSGI, and Passenger mod support, and support for the ITK mpm module. + +#### Backwards-incompatible Changes: +- Remove many default mods that are not normally needed. +- Remove `rewrite_base` `apache::vhost` parameter; did not work anyway. +- Specify dependencies on stdlib >=2.4.0 (this was already the case, but +making explicit) +- Deprecate `a2mod` in favor of the `apache::mod::*` classes and `apache::mod` +defined resource. + +#### Features: +- `apache` class + - Add `httpd_dir` parameter to change the location of the configuration + files. + - Add `logroot` parameter to change the logroot + - Add `ports_file` parameter to changes the `ports.conf` file location + - Add `keepalive` parameter to enable persistent connections + - Add `keepalive_timeout` parameter to change the timeout + - Update `default_mods` to be able to take an array of mods to enable. +- `apache::vhost` + - Add `wsgi_daemon_process`, `wsgi_daemon_process_options`, + `wsgi_process_group`, and `wsgi_script_aliases` parameters for per-vhost + WSGI configuration. + - Add `access_log_syslog` parameter to enable syslogging. + - Add `error_log_syslog` parameter to enable syslogging of errors. + - Add `directories` hash parameter. Please see README for documentation. + - Add `sslproxyengine` parameter to enable SSLProxyEngine + - Add `suphp_addhandler`, `suphp_engine`, and `suphp_configpath` for + configuring SuPHP. + - Add `custom_fragment` parameter to allow for arbitrary apache + configuration injection. (Feature pull requests are prefered over using + this, but it is available in a pinch.) +- Add `apache::mod::suphp` class for configuring SuPHP. +- Add `apache::mod::itk` class for configuring ITK mpm module. +- Update `apache::mod::wsgi` class for global WSGI configuration with +`wsgi_socket_prefix` and `wsgi_python_home` parameters. +- Add README.passenger.md to document the `apache::mod::passenger` usage. +Added `passenger_high_performance`, `passenger_pool_idle_time`, +`passenger_max_requests`, `passenger_stat_throttle_rate`, `rack_autodetect`, +and `rails_autodetect` parameters. +- Separate the httpd service resource into a new `apache::service` class for +dependency chaining of `Class['apache'] -> ~> +Class['apache::service']` +- Added `apache::mod::proxy_balancer` class for `apache::balancer` + +#### Bugfixes: +- Change dependency to puppetlabs-concat +- Fix ruby 1.9 bug for `a2mod` +- Change servername to be `$::hostname` if there is no `$::fqdn` +- Make `/etc/ssl/certs` the default ssl certs directory for RedHat non-5. +- Make `php` the default php package for RedHat non-5. +- Made `aliases` able to take a single alias hash instead of requiring an +array. + +## 2013-07-26 Release 0.8.1 +#### Bugfixes: +- Update `apache::mpm_module` detection for worker/prefork +- Update `apache::mod::cgi` and `apache::mod::cgid` detection for +worker/prefork + +## 2013-07-16 Release 0.8.0 +#### Features: +- Add `servername` parameter to `apache` class +- Add `proxy_set` parameter to `apache::balancer` define + +#### Bugfixes: +- Fix ordering for multiple `apache::balancer` clusters +- Fix symlinking for sites-available on Debian-based OSs +- Fix dependency ordering for recursive confdir management +- Fix `apache::mod::*` to notify the service on config change +- Documentation updates + +## 2013-07-09 Release 0.7.0 +#### Changes: +- Essentially rewrite the module -- too many to list +- `apache::vhost` has many abilities -- see README.md for details +- `apache::mod::*` classes provide httpd mod-loading capabilities +- `apache` base class is much more configurable + +#### Bugfixes: +- Many. And many more to come + +## 2013-03-2 Release 0.6.0 +- update travis tests (add more supported versions) +- add access log_parameter +- make purging of vhost dir configurable + +## 2012-08-24 Release 0.4.0 +#### Changes: +- `include apache` is now required when using `apache::mod::*` + +#### Bugfixes: +- Fix syntax for validate_re +- Fix formatting in vhost template +- Fix spec tests such that they pass + +##2012-05-08 Puppet Labs - 0.0.4 +* e62e362 Fix broken tests for ssl, vhost, vhost::* +* 42c6363 Changes to match style guide and pass puppet-lint without error +* 42bc8ba changed name => path for file resources in order to name namevar by it's name +* 72e13de One end too much +* 0739641 style guide fixes: 'true' <> true, $operatingsystem needs to be $::operatingsystem, etc. +* 273f94d fix tests +* a35ede5 (#13860) Make a2enmod/a2dismo commands optional +* 98d774e (#13860) Autorequire Package['httpd'] +* 05fcec5 (#13073) Add missing puppet spec tests +* 541afda (#6899) Remove virtual a2mod definition +* 976cb69 (#13072) Move mod python and wsgi package names to params +* 323915a (#13060) Add .gitignore to repo +* fdf40af (#13060) Remove pkg directory from source tree +* fd90015 Add LICENSE file and update the ModuleFile +* d3d0d23 Re-enable local php class +* d7516c7 Make management of firewalls configurable for vhosts +* 60f83ba Explicitly lookup scope of apache_name in templates. +* f4d287f (#12581) Add explicit ordering for vdir directory +* 88a2ac6 (#11706) puppetlabs-apache depends on puppetlabs-firewall +* a776a8b (#11071) Fix to work with latest firewall module +* 2b79e8b (#11070) Add support for Scientific Linux +* 405b3e9 Fix for a2mod +* 57b9048 Commit apache::vhost::redirect Manifest +* 8862d01 Commit apache::vhost::proxy Manifest +* d5c1fd0 Commit apache::mod::wsgi Manifest +* a825ac7 Commit apache::mod::python Manifest +* b77062f Commit Templates +* 9a51b4a Vhost File Declarations +* 6cf7312 Defaults for Parameters +* 6a5b11a Ensure installed +* f672e46 a2mod fix +* 8a56ee9 add pthon support to apache diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/CONTRIBUTING.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/CONTRIBUTING.md new file mode 100644 index 0000000000..e1288478a2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/CONTRIBUTING.md @@ -0,0 +1,234 @@ +Checklist (and a short version for the impatient) +================================================= + + * Commits: + + - Make commits of logical units. + + - Check for unnecessary whitespace with "git diff --check" before + committing. + + - Commit using Unix line endings (check the settings around "crlf" in + git-config(1)). + + - Do not check in commented out code or unneeded files. + + - The first line of the commit message should be a short + description (50 characters is the soft limit, excluding ticket + number(s)), and should skip the full stop. + + - Associate the issue in the message. The first line should include + the issue number in the form "(#XXXX) Rest of message". + + - The body should provide a meaningful commit message, which: + + - uses the imperative, present tense: "change", not "changed" or + "changes". + + - includes motivation for the change, and contrasts its + implementation with the previous behavior. + + - Make sure that you have tests for the bug you are fixing, or + feature you are adding. + + - Make sure the test suites passes after your commit: + `bundle exec rspec spec/acceptance` More information on [testing](#Testing) below + + - When introducing a new feature, make sure it is properly + documented in the README.md + + * Submission: + + * Pre-requisites: + + - Sign the [Contributor License Agreement](https://cla.puppetlabs.com/) + + - Make sure you have a [GitHub account](https://github.com/join) + + - [Create a ticket](http://projects.puppetlabs.com/projects/modules/issues/new), or [watch the ticket](http://projects.puppetlabs.com/projects/modules/issues) you are patching for. + + * Preferred method: + + - Fork the repository on GitHub. + + - Push your changes to a topic branch in your fork of the + repository. (the format ticket/1234-short_description_of_change is + usually preferred for this project). + + - Submit a pull request to the repository in the puppetlabs + organization. + +The long version +================ + + 1. Make separate commits for logically separate changes. + + Please break your commits down into logically consistent units + which include new or changed tests relevant to the rest of the + change. The goal of doing this is to make the diff easier to + read for whoever is reviewing your code. In general, the easier + your diff is to read, the more likely someone will be happy to + review it and get it into the code base. + + If you are going to refactor a piece of code, please do so as a + separate commit from your feature or bug fix changes. + + We also really appreciate changes that include tests to make + sure the bug is not re-introduced, and that the feature is not + accidentally broken. + + Describe the technical detail of the change(s). If your + description starts to get too long, that is a good sign that you + probably need to split up your commit into more finely grained + pieces. + + Commits which plainly describe the things which help + reviewers check the patch and future developers understand the + code are much more likely to be merged in with a minimum of + bike-shedding or requested changes. Ideally, the commit message + would include information, and be in a form suitable for + inclusion in the release notes for the version of Puppet that + includes them. + + Please also check that you are not introducing any trailing + whitespace or other "whitespace errors". You can do this by + running "git diff --check" on your changes before you commit. + + 2. Sign the Contributor License Agreement + + Before we can accept your changes, we do need a signed Puppet + Labs Contributor License Agreement (CLA). + + You can access the CLA via the [Contributor License Agreement link](https://cla.puppetlabs.com/) + + If you have any questions about the CLA, please feel free to + contact Puppet Labs via email at cla-submissions@puppetlabs.com. + + 3. Sending your patches + + To submit your changes via a GitHub pull request, we _highly_ + recommend that you have them on a topic branch, instead of + directly on "master". + It makes things much easier to keep track of, especially if + you decide to work on another thing before your first change + is merged in. + + GitHub has some pretty good + [general documentation](http://help.github.com/) on using + their site. They also have documentation on + [creating pull requests](http://help.github.com/send-pull-requests/). + + In general, after pushing your topic branch up to your + repository on GitHub, you can switch to the branch in the + GitHub UI and click "Pull Request" towards the top of the page + in order to open a pull request. + + + 4. Update the related GitHub issue. + + If there is a GitHub issue associated with the change you + submitted, then you should update the ticket to include the + location of your branch, along with any other commentary you + may wish to make. + +Testing +======= + +Getting Started +--------------- + +Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby +package manager such as [bundler](http://bundler.io/) what Ruby packages, +or Gems, are required to build, develop, and test this software. + +Please make sure you have [bundler installed](http://bundler.io/#getting-started) +on your system, then use it to install all dependencies needed for this project, +by running + +```shell +% bundle install +Fetching gem metadata from https://rubygems.org/........ +Fetching gem metadata from https://rubygems.org/.. +Using rake (10.1.0) +Using builder (3.2.2) +-- 8><-- many more --><8 -- +Using rspec-system-puppet (2.2.0) +Using serverspec (0.6.3) +Using rspec-system-serverspec (1.0.0) +Using bundler (1.3.5) +Your bundle is complete! +Use `bundle show [gemname]` to see where a bundled gem is installed. +``` + +NOTE some systems may require you to run this command with sudo. + +If you already have those gems installed, make sure they are up-to-date: + +```shell +% bundle update +``` + +With all dependencies in place and up-to-date we can now run the tests: + +```shell +% rake spec +``` + +This will execute all the [rspec tests](http://rspec-puppet.com/) tests +under [spec/defines](./spec/defines), [spec/classes](./spec/classes), +and so on. rspec tests may have the same kind of dependencies as the +module they are testing. While the module defines in its [Modulefile](./Modulefile), +rspec tests define them in [.fixtures.yml](./fixtures.yml). + +Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) +tests. These tests spin up a virtual machine under +[VirtualBox](https://www.virtualbox.org/)) with, controlling it with +[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test +scenarios. In order to run these, you will need both of those tools +installed on your system. + +You can run them by issuing the following command + +```shell +% rake spec_clean +% rspec spec/acceptance +``` + +This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), +install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) +and then run all the tests under [spec/acceptance](./spec/acceptance). + +Writing Tests +------------- + +XXX getting started writing tests. + +If you have commit access to the repository +=========================================== + +Even if you have commit access to the repository, you will still need to +go through the process above, and have someone else review and merge +in your changes. The rule is that all changes must be reviewed by a +developer on the project (that did not write the code) to ensure that +all changes go through a code review process. + +Having someone other than the author of the topic branch recorded as +performing the merge is the record that they performed the code +review. + + +Additional Resources +==================== + +* [Getting additional help](http://projects.puppetlabs.com/projects/puppet/wiki/Getting_Help) + +* [Writing tests](http://projects.puppetlabs.com/projects/puppet/wiki/Development_Writing_Tests) + +* [Patchwork](https://patchwork.puppetlabs.com) + +* [Contributor License Agreement](https://projects.puppetlabs.com/contributor_licenses/sign) + +* [General GitHub documentation](http://help.github.com/) + +* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/Gemfile new file mode 100644 index 0000000000..fc45295a10 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/Gemfile @@ -0,0 +1,26 @@ +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +group :development, :test do + gem 'rake', '10.1.1', :require => false + gem 'rspec-puppet', '>=1.0.0', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'serverspec', :require => false + gem 'puppet-lint', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false + gem 'rspec', '~> 2.11', :require => false +end + +if facterversion = ENV['FACTER_GEM_VERSION'] + gem 'facter', facterversion, :require => false +else + gem 'facter', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/LICENSE new file mode 100644 index 0000000000..8961ce8a6d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/LICENSE @@ -0,0 +1,15 @@ +Copyright (C) 2012 Puppet Labs Inc + +Puppet Labs can be contacted at: info@puppetlabs.com + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/Modulefile new file mode 100644 index 0000000000..227947cbba --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/Modulefile @@ -0,0 +1,12 @@ +name 'puppetlabs-apache' +version '1.0.1' +source 'git://github.com/puppetlabs/puppetlabs-apache.git' +author 'puppetlabs' +license 'Apache 2.0' +summary 'Puppet module for Apache' +description 'Module for Apache configuration' +project_page 'https://github.com/puppetlabs/puppetlabs-apache' + +## Add dependencies, if any: +dependency 'puppetlabs/stdlib', '>= 2.4.0' +dependency 'puppetlabs/concat', '>= 1.0.0' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/README.md new file mode 100644 index 0000000000..385130df31 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/README.md @@ -0,0 +1,1958 @@ +#apache + +[](https://travis-ci.org/puppetlabs/puppetlabs-apache) + +####Table of Contents + +1. [Overview - What is the apache module?](#overview) +2. [Module Description - What does the module do?](#module-description) +3. [Setup - The basics of getting started with apache](#setup) + * [Beginning with apache - Installation](#beginning-with-apache) + * [Configure a virtual host - Basic options for getting started](#configure-a-virtual-host) +4. [Usage - The classes and defined types available for configuration](#usage) + * [Classes and Defined Types](#classes-and-defined-types) + * [Class: apache](#class-apache) + * [Class: apache::default_mods](#class-apachedefault_mods) + * [Defined Type: apache::mod](#defined-type-apachemod) + * [Classes: apache::mod::*](#classes-apachemodname) + * [Class: apache::mod::pagespeed](#class-apachemodpagespeed) + * [Class: apache::mod::php](#class-apachemodphp) + * [Class: apache::mod::ssl](#class-apachemodssl) + * [Class: apache::mod::wsgi](#class-apachemodwsgi) + * [Class: apache::mod::fcgid](#class-apachemodfcgid) + * [Defined Type: apache::vhost](#defined-type-apachevhost) + * [Parameter: `directories` for apache::vhost](#parameter-directories-for-apachevhost) + * [SSL parameters for apache::vhost](#ssl-parameters-for-apachevhost) + * [Virtual Host Examples - Demonstrations of some configuration options](#virtual-host-examples) + * [Load Balancing](#load-balancing) + * [Defined Type: apache::balancer](#defined-type-apachebalancer) + * [Defined Type: apache::balancermember](#defined-type-apachebalancermember) + * [Examples - Load balancing with exported and non-exported resources](#examples) +5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) + * [Classes](#classes) + * [Public Classes](#public-classes) + * [Private Classes](#private-classes) + * [Defined Types](#defined-types) + * [Public Defined Types](#public-defined-types) + * [Private Defined Types](#private-defined-types) + * [Templates](#templates) +6. [Limitations - OS compatibility, etc.](#limitations) +7. [Development - Guide for contributing to the module](#development) + * [Contributing to the apache module](#contributing) + * [Running tests - A quick guide](#running-tests) + +##Overview + +The apache module allows you to set up virtual hosts and manage web services with minimal effort. + +##Module Description + +Apache is a widely-used web server, and this module provides a simplified way of creating configurations to manage your infrastructure. This includes the ability to configure and manage a range of different virtual host setups, as well as a streamlined way to install and configure Apache modules. + +##Setup + +**What apache affects:** + +* configuration files and directories (created and written to) + * **WARNING**: Configurations that are *not* managed by Puppet will be purged. +* package/service/configuration files for Apache +* Apache modules +* virtual hosts +* listened-to ports +* `/etc/make.conf` on FreeBSD + +###Beginning with Apache + +To install Apache with the default parameters + +```puppet + class { 'apache': } +``` + +The defaults are determined by your operating system (e.g. Debian systems have one set of defaults, and RedHat systems have another, as do FreeBSD systems). These defaults will work well in a testing environment, but are not suggested for production. To establish customized parameters + +```puppet + class { 'apache': + default_mods => false, + default_confd_files => false, + } +``` + +###Configure a virtual host + +Declaring the `apache` class will create a default virtual host by setting up a vhost on port 80, listening on all interfaces and serving `$apache::docroot`. + +```puppet + class { 'apache': } +``` + +To configure a very basic, name-based virtual host + +```puppet + apache::vhost { 'first.example.com': + port => '80', + docroot => '/var/www/first', + } +``` + +*Note:* The default priority is 15. If nothing matches this priority, the alphabetically first name-based vhost will be used. This is also true if you pass a higher priority and no names match anything else. + +A slightly more complicated example, changes the docroot owner/group from the default 'root' + +```puppet + apache::vhost { 'second.example.com': + port => '80', + docroot => '/var/www/second', + docroot_owner => 'third', + docroot_group => 'third', + } +``` + +To set up a virtual host with SSL and default SSL certificates + +```puppet + apache::vhost { 'ssl.example.com': + port => '443', + docroot => '/var/www/ssl', + ssl => true, + } +``` + +To set up a virtual host with SSL and specific SSL certificates + +```puppet + apache::vhost { 'fourth.example.com': + port => '443', + docroot => '/var/www/fourth', + ssl => true, + ssl_cert => '/etc/ssl/fourth.example.com.cert', + ssl_key => '/etc/ssl/fourth.example.com.key', + } +``` + +Virtual hosts listen on '*' by default. To listen on a specific IP address + +```puppet + apache::vhost { 'subdomain.example.com': + ip => '127.0.0.1', + port => '80', + docroot => '/var/www/subdomain', + } +``` + +To set up a virtual host with a wildcard alias for the subdomain mapped to a same-named directory, for example: `http://example.com.loc` to `/var/www/example.com` + +```puppet + apache::vhost { 'subdomain.loc': + vhost_name => '*', + port => '80', + virtual_docroot' => '/var/www/%-2+', + docroot => '/var/www', + serveraliases => ['*.loc',], + } +``` + +To set up a virtual host with suPHP + +```puppet + apache::vhost { 'suphp.example.com': + port => '80', + docroot => '/home/appuser/myphpapp', + suphp_addhandler => 'x-httpd-php', + suphp_engine => 'on', + suphp_configpath => '/etc/php5/apache2', + directories => { path => '/home/appuser/myphpapp', + 'suphp' => { user => 'myappuser', group => 'myappgroup' }, + } + } +``` + +To set up a virtual host with WSGI + +```puppet + apache::vhost { 'wsgi.example.com': + port => '80', + docroot => '/var/www/pythonapp', + wsgi_application_group => '%{GLOBAL}', + wsgi_daemon_process => 'wsgi', + wsgi_daemon_process_options => { + processes => '2', + threads => '15', + display-name => '%{GROUP}', + }, + wsgi_import_script => '/var/www/demo.wsgi', + wsgi_import_script_options => + { process-group => 'wsgi', application-group => '%{GLOBAL}' }, + wsgi_process_group => 'wsgi', + wsgi_script_aliases => { '/' => '/var/www/demo.wsgi' }, + } +``` + +Starting in Apache 2.2.16, HTTPD supports [FallbackResource](https://httpd.apache.org/docs/current/mod/mod_dir.html#fallbackresource), a simple replacement for common RewriteRules. + +```puppet + apache::vhost { 'wordpress.example.com': + port => '80', + docroot => '/var/www/wordpress', + fallbackresource => '/index.php', + } +``` + +Please note that the 'disabled' argument to FallbackResource is only supported since Apache 2.2.24. + +See a list of all [virtual host parameters](#defined-type-apachevhost). See an extensive list of [virtual host examples](#virtual-host-examples). + +##Usage + +###Classes and Defined Types + +This module modifies Apache configuration files and directories, and will purge any configuration not managed by Puppet. Configuration of Apache should be managed by Puppet, as non-Puppet configuration files can cause unexpected failures. + +It is possible to temporarily disable full Puppet management by setting the [`purge_configs`](#purge_configs) parameter within the base `apache` class to 'false'. This option should only be used as a temporary means of saving and relocating customized configurations. See the [`purge_configs` parameter](#purge_configs) for more information. + +####Class: `apache` + +The apache module's primary class, `apache`, guides the basic setup of Apache on your system. + +You may establish a default vhost in this class, the `vhost` class, or both. You may add additional vhost configurations for specific virtual hosts using a declaration of the `vhost` type. + +**Parameters within `apache`:** + +#####`apache_version` + +Configures the behavior of the module templates, package names, and default mods by setting the Apache version. Default is determined by the class `apache::version` using the OS family and release. It should not be configured manually without special reason. + +#####`confd_dir` + +Changes the location of the configuration directory your custom configuration files are placed in. Defaults to '/etc/httpd/conf' on RedHat, '/etc/apache2' on Debian, and '/usr/local/etc/apache22' on FreeBSD. + +#####`conf_template` + +Overrides the template used for the main apache configuration file. Defaults to 'apache/httpd.conf.erb'. + +*Note:* Using this parameter is potentially risky, as the module has been built for a minimal configuration file with the configuration primarily coming from conf.d/ entries. + +#####`default_confd_files` + +Generates default set of include-able Apache configuration files under `${apache::confd_dir}` directory. These configuration files correspond to what is usually installed with the Apache package on a given platform. + +#####`default_mods` + +Sets up Apache with default settings based on your OS. Valid values are 'true', 'false', or an array of mod names. + +Defaults to 'true', which will include the default [HTTPD mods](https://github.com/puppetlabs/puppetlabs-apache/blob/master/manifests/default_mods.pp). + +If false, it will only include the mods required to make HTTPD work, and any other mods can be declared on their own. + +If an array, the apache module will include the array of mods listed. + +#####`default_ssl_ca` + +The default certificate authority, which is automatically set to 'undef'. This default will work out of the box but must be updated with your specific certificate information before being used in production. + +#####`default_ssl_cert` + +The default SSL certification, which is automatically set based on your operating system ('/etc/pki/tls/certs/localhost.crt' for RedHat, '/etc/ssl/certs/ssl-cert-snakeoil.pem' for Debian, and '/usr/local/etc/apache22/server.crt' for FreeBSD). This default will work out of the box but must be updated with your specific certificate information before being used in production. + +#####`default_ssl_chain` + +The default SSL chain, which is automatically set to 'undef'. This default will work out of the box but must be updated with your specific certificate information before being used in production. + +#####`default_ssl_crl` + +The default certificate revocation list to use, which is automatically set to 'undef'. This default will work out of the box but must be updated with your specific certificate information before being used in production. + +#####`default_ssl_crl_path` + +The default certificate revocation list path, which is automatically set to 'undef'. This default will work out of the box but must be updated with your specific certificate information before being used in production. + +#####`default_ssl_key` + +The default SSL key, which is automatically set based on your operating system ('/etc/pki/tls/private/localhost.key' for RedHat, '/etc/ssl/private/ssl-cert-snakeoil.key' for Debian, and '/usr/local/etc/apache22/server.key' for FreeBSD). This default will work out of the box but must be updated with your specific certificate information before being used in production. + +#####`default_ssl_vhost` + +Sets up a default SSL virtual host. Defaults to 'false'. If set to 'true', will set up the following vhost: + +```puppet + apache::vhost { 'default-ssl': + port => 443, + ssl => true, + docroot => $docroot, + scriptalias => $scriptalias, + serveradmin => $serveradmin, + access_log_file => "ssl_${access_log_file}", + } +``` + +SSL vhosts only respond to HTTPS queries. + +#####`default_vhost` + +Sets up a default virtual host. Defaults to 'true', set to 'false' to set up [customized virtual hosts](#configure-a-virtual-host). + +#####`error_documents` + +Enables custom error documents. Defaults to 'false'. + +#####`httpd_dir` + +Changes the base location of the configuration directories used for the apache service. This is useful for specially repackaged HTTPD builds, but may have unintended consequences when used in combination with the default distribution packages. Defaults to '/etc/httpd' on RedHat, '/etc/apache2' on Debian, and '/usr/local/etc/apache22' on FreeBSD. + +#####`keepalive` + +Enables persistent connections. + +#####`keepalive_timeout` + +Sets the amount of time the server will wait for subsequent requests on a persistent connection. Defaults to '15'. + +#####`max_keepalive_requests` + +Sets the limit of the number of requests allowed per connection when KeepAlive is on. Defaults to '100'. + +#####`loadfile_name` + +Sets the file name for the module loadfile. Should be in the format *.load. This can be used to set the module load order. + +#####`log_level` + +Changes the verbosity level of the error log. Defaults to 'warn'. Valid values are 'emerg', 'alert', 'crit', 'error', 'warn', 'notice', 'info', or 'debug'. + +#####`log_formats` + +Define additional [LogFormats](https://httpd.apache.org/docs/current/mod/mod_log_config.html#logformat). This is done in a Hash: + +```puppet + $log_formats = { vhost_common => '%v %h %l %u %t \"%r\" %>s %b' } +``` + +#####`logroot` + +Changes the directory where Apache log files for the virtual host are placed. Defaults to '/var/log/httpd' on RedHat, '/var/log/apache2' on Debian, and '/var/log/apache22' on FreeBSD. + +#####`manage_group` + +Setting this to 'false' will stop the group resource from being created. This is for when you have a group, created from another Puppet module, you want to use to run Apache. Without this parameter, attempting to use a previously established group would result in a duplicate resource error. + +#####`manage_user` + +Setting this to 'false' will stop the user resource from being created. This is for instances when you have a user, created from another Puppet module, you want to use to run Apache. Without this parameter, attempting to use a previously established user would result in a duplicate resource error. + +#####`mod_dir` + +Changes the location of the configuration directory your Apache modules configuration files are placed in. Defaults to '/etc/httpd/conf.d' for RedHat, '/etc/apache2/mods-available' for Debian, and '/usr/local/etc/apache22/Modules' for FreeBSD. + +#####`mpm_module` + +Determines which MPM is loaded and configured for the HTTPD process. Valid values are 'event', 'itk', 'peruser', 'prefork', 'worker', or 'false'. Defaults to 'prefork' on RedHat and FreeBSD, and 'worker' on Debian. Must be set to 'false' to explicitly declare the following classes with custom parameters: + +* `apache::mod::event` +* `apache::mod::itk` +* `apache::mod::peruser` +* `apache::mod::prefork` +* `apache::mod::worker` + +*Note:* Switching between different MPMs on FreeBSD is possible but quite difficult. Before changing `$mpm_module` you must uninstall all packages that depend on your currently-installed Apache. + +#####`package_ensure` + +Allows control over the package ensure attribute. Can be 'present','absent', or a version string. + +#####`ports_file` + +Changes the name of the file containing Apache ports configuration. Default is `${conf_dir}/ports.conf`. + +#####`purge_configs` + +Removes all other Apache configs and vhosts, defaults to 'true'. Setting this to 'false' is a stopgap measure to allow the apache module to coexist with existing or otherwise-managed configuration. It is recommended that you move your configuration entirely to resources within this module. + +#####`sendfile` + +Makes Apache use the Linux kernel sendfile to serve static files. Defaults to 'On'. + +#####`serveradmin` + +Sets the server administrator. Defaults to 'root@localhost'. + +#####`servername` + +Sets the server name. Defaults to `fqdn` provided by Facter. + +#####`server_root` + +Sets the root directory in which the server resides. Defaults to '/etc/httpd' on RedHat, '/etc/apache2' on Debian, and '/usr/local' on FreeBSD. + +#####`server_signature` + +Configures a trailing footer line under server-generated documents. More information about [ServerSignature](http://httpd.apache.org/docs/current/mod/core.html#serversignature). Defaults to 'On'. + +#####`server_tokens` + +Controls how much information Apache sends to the browser about itself and the operating system. More information about [ServerTokens](http://httpd.apache.org/docs/current/mod/core.html#servertokens). Defaults to 'OS'. + +#####`service_enable` + +Determines whether the HTTPD service is enabled when the machine is booted. Defaults to 'true'. + +#####`service_ensure` + +Determines whether the service should be running. Valid values are true, false, 'running' or 'stopped' when Puppet should manage the service. Any other value will set ensure to false for the Apache service, which is useful when you want to let the service be managed by some other application like Pacemaker. Defaults to 'running'. + +#####`service_name` + +Name of the Apache service to run. Defaults to: 'httpd' on RedHat, 'apache2' on Debian, and 'apache22' on FreeBSD. + +#####`trace_enable` + +Controls how TRACE requests per RFC 2616 are handled. More information about [TraceEnable](http://httpd.apache.org/docs/current/mod/core.html#traceenable). Defaults to 'On'. + +#####`vhost_dir` + +Changes the location of the configuration directory your virtual host configuration files are placed in. Defaults to 'etc/httpd/conf.d' on RedHat, '/etc/apache2/sites-available' on Debian, and '/usr/local/etc/apache22/Vhosts' on FreeBSD. + +####Class: `apache::default_mods` + +Installs default Apache modules based on what OS you are running. + +```puppet + class { 'apache::default_mods': } +``` + +####Defined Type: `apache::mod` + +Used to enable arbitrary Apache HTTPD modules for which there is no specific `apache::mod::[name]` class. The `apache::mod` defined type will also install the required packages to enable the module, if any. + +```puppet + apache::mod { 'rewrite': } + apache::mod { 'ldap': } +``` + +####Classes: `apache::mod::[name]` + +There are many `apache::mod::[name]` classes within this module that can be declared using `include`: + +* `actions` +* `alias` +* `auth_basic` +* `auth_kerb` +* `authnz_ldap`* +* `autoindex` +* `cache` +* `cgi` +* `cgid` +* `dav` +* `dav_fs` +* `dav_svn`* +* `deflate` +* `dev` +* `dir`* +* `disk_cache` +* `event` +* `expires` +* `fastcgi` +* `fcgid` +* `headers` +* `include` +* `info` +* `itk` +* `ldap` +* `mime` +* `mime_magic`* +* `negotiation` +* `nss`* +* `pagespeed` (see [`apache::mod::pagespeed`](#class-apachemodpagespeed) below) +* `passenger`* +* `perl` +* `peruser` +* `php` (requires [`mpm_module`](#mpm_module) set to `prefork`) +* `prefork`* +* `proxy`* +* `proxy_ajp` +* `proxy_balancer` +* `proxy_html` +* `proxy_http` +* `python` +* `reqtimeout` +* `rewrite` +* `rpaf`* +* `setenvif` +* `speling` +* `ssl`* (see [`apache::mod::ssl`](#class-apachemodssl) below) +* `status`* +* `suphp` +* `userdir`* +* `vhost_alias` +* `worker`* +* `wsgi` (see [`apache::mod::wsgi`](#class-apachemodwsgi) below) +* `xsendfile` + +Modules noted with a * indicate that the module has settings and, thus, a template that includes parameters. These parameters control the module's configuration. Most of the time, these parameters will not require any configuration or attention. + +The modules mentioned above, and other Apache modules that have templates, will cause template files to be dropped along with the mod install and the module will not work without the template. Any module without a template will install the package but drop no files. + +####Class: `apache::mod::pagespeed` + +Installs and manages mod_pagespeed, which is a Google module that rewrites web pages to reduce latency and bandwidth. + +This module does *not* manage the software repositories needed to automatically install the +mod-pagespeed-stable package. The module does however require that the package be installed, +or be installable using the system's default package provider. You should ensure that this +pre-requisite is met or declaring `apache::mod::pagespeed` will cause the puppet run to fail. + +These are the defaults: + +```puppet + class { 'apache::mod::pagespeed': + inherit_vhost_config => 'on', + filter_xhtml => false, + cache_path => '/var/cache/mod_pagespeed/', + log_dir => '/var/log/pagespeed', + memache_servers => [], + rewrite_level => 'CoreFilters', + disable_filters => [], + enable_filters => [], + forbid_filters => [], + rewrite_deadline_per_flush_ms => 10, + additional_domains => undef, + file_cache_size_kb => 102400, + file_cache_clean_interval_ms => 3600000, + lru_cache_per_process => 1024, + lru_cache_byte_limit => 16384, + css_flatten_max_bytes => 2048, + css_inline_max_bytes => 2048, + css_image_inline_max_bytes => 2048, + image_inline_max_bytes => 2048, + js_inline_max_bytes => 2048, + css_outline_min_bytes => 3000, + js_outline_min_bytes => 3000, + inode_limit => 500000, + image_max_rewrites_at_once => 8, + num_rewrite_threads => 4, + num_expensive_rewrite_threads => 4, + collect_statistics => 'on', + statistics_logging => 'on', + allow_view_stats => [], + allow_pagespeed_console => [], + allow_pagespeed_message => [], + message_buffer_size => 100000, + additional_configuration => { } + } +``` + +Full documentation for mod_pagespeed is available from [Google](http://modpagespeed.com). + +####Class: `apache::mod::php` + +Installs and configures mod_php. The defaults are OS-dependant. + +Overriding the package name: +``` + class {'::apache::mod::php': + package_name => "php54-php", + path => "${::apache::params::lib_path}/libphp54-php5.so", + } +``` + +Overriding the default configuartion: +```puppet + class {'::apache::mod::php': + source => 'puppet:///modules/apache/my_php.conf', + } +``` + +or +```puppet + class {'::apache::mod::php': + template => 'apache/php.conf.erb', + } +``` + +or + +```puppet + class {'::apache::mod::php': + content => ' +AddHandler php5-script .php +AddType text/html .php', + } +``` +####Class: `apache::mod::ssl` + +Installs Apache SSL capabilities and uses the ssl.conf.erb template. These are the defaults: + +```puppet + class { 'apache::mod::ssl': + ssl_compression => false, + ssl_options => [ 'StdEnvVars' ], + } +``` + +To *use* SSL with a virtual host, you must either set the`default_ssl_vhost` parameter in `::apache` to 'true' or set the `ssl` parameter in `apache::vhost` to 'true'. + +####Class: `apache::mod::wsgi` + +Enables Python support in the WSGI module. To use, simply `include 'apache::mod::wsgi'`. + +For customized parameters, which tell Apache how Python is currently configured on the operating system, + +```puppet + class { 'apache::mod::wsgi': + wsgi_socket_prefix => "\${APACHE_RUN_DIR}WSGI", + wsgi_python_home => '/path/to/venv', + wsgi_python_path => '/path/to/venv/site-packages', + } +``` + +More information about [WSGI](http://modwsgi.readthedocs.org/en/latest/). + +####Class: `apache::mod::fcgid` + +Installs and configures mod_fcgid. + +The class makes no effort to list all available options, but rather uses an options hash to allow for ultimate flexibility: + +```puppet + class { 'apache::mod::fcgid': + options => { + 'FcgidIPCDir' => '/var/run/fcgidsock', + 'SharememPath' => '/var/run/fcgid_shm', + 'AddHandler' => 'fcgid-script .fcgi', + }, + } +``` + +For a full list op options, see the [official mod_fcgid documentation](https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html). + +It is also possible to set the FcgidWrapper per directory per vhost. You must ensure the fcgid module is loaded because there is no auto loading. + +```puppet + include apache::mod::fcgid + apache::vhost { 'example.org': + docroot => '/var/www/html', + directories => { + path => '/var/www/html', + fcgiwrapper => { + command => '/usr/local/bin/fcgiwrapper', + } + }, + } +``` + +See [FcgidWrapper documentation](https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidwrapper) for more information. + +####Defined Type: `apache::vhost` + +The Apache module allows a lot of flexibility in the setup and configuration of virtual hosts. This flexibility is due, in part, to `vhost`'s being a defined resource type, which allows it to be evaluated multiple times with different parameters. + +The `vhost` defined type allows you to have specialized configurations for virtual hosts that have requirements outside the defaults. You can set up a default vhost within the base `::apache` class, as well as set a customized vhost as default. Your customized vhost (priority 10) will be privileged over the base class vhost (15). + +If you have a series of specific configurations and do not want a base `::apache` class default vhost, make sure to set the base class `default_vhost` to 'false'. + +```puppet + class { 'apache': + default_vhost => false, + } +``` + +**Parameters within `apache::vhost`:** + +#####`access_log` + +Specifies whether `*_access.log` directives (`*_file`,`*_pipe`, or `*_syslog`) should be configured. Setting the value to 'false' will choose none. Defaults to 'true'. + +#####`access_log_file` + +Sets the `*_access.log` filename that is placed in `$logroot`. Given a vhost, example.com, it defaults to 'example.com_ssl.log' for SSL vhosts and 'example.com_access.log' for non-SSL vhosts. + +#####`access_log_pipe` + +Specifies a pipe to send access log messages to. Defaults to 'undef'. + +#####`access_log_syslog` + +Sends all access log messages to syslog. Defaults to 'undef'. + +#####`access_log_format` + +Specifies the use of either a LogFormat nickname or a custom format string for the access log. Defaults to 'combined'. See [these examples](http://httpd.apache.org/docs/current/mod/mod_log_config.html). + +#####`access_log_env_var` + +Specifies that only requests with particular environment variables be logged. Defaults to 'undef'. + +#####`add_listen` + +Determines whether the vhost creates a Listen statement. The default value is 'true'. + +Setting `add_listen` to 'false' stops the vhost from creating a Listen statement, and this is important when you combine vhosts that are not passed an `ip` parameter with vhosts that *are* passed the `ip` parameter. + +#####`additional_includes` + +Specifies paths to additional static, vhost-specific Apache configuration files. Useful for implementing a unique, custom configuration not supported by this module. Can be an array. Defaults to '[]'. + +#####`aliases` + +Passes a list of hashes to the vhost to create Alias or AliasMatch directives as per the [mod_alias documentation](http://httpd.apache.org/docs/current/mod/mod_alias.html). These hashes are formatted as follows: + +```puppet +aliases => [ + { aliasmatch => '^/image/(.*)\.jpg$', + path => '/files/jpg.images/$1.jpg', + } + { alias => '/image', + path => '/ftp/pub/image', + }, +], +``` + +For `alias` and `aliasmatch` to work, each will need a corresponding context, such as '< Directory /path/to/directory>' or ''. The Alias and AliasMatch directives are created in the order specified in the `aliases` parameter. As described in the [`mod_alias` documentation](http://httpd.apache.org/docs/current/mod/mod_alias.html), more specific `alias` or `aliasmatch` parameters should come before the more general ones to avoid shadowing. + +*Note:* If `apache::mod::passenger` is loaded and `PassengerHighPerformance => true` is set, then Alias may have issues honoring the `PassengerEnabled => off` statement. See [this article](http://www.conandalton.net/2010/06/passengerenabled-off-not-working.html) for details. + +#####`block` + +Specifies the list of things Apache will block access to. The default is an empty set, '[]'. Currently, the only option is 'scm', which blocks web access to .svn, .git and .bzr directories. + +#####`custom_fragment` + +Passes a string of custom configuration directives to be placed at the end of the vhost configuration. Defaults to 'undef'. + +#####`default_vhost` + +Sets a given `apache::vhost` as the default to serve requests that do not match any other `apache::vhost` definitions. The default value is 'false'. + +#####`directories` + +See the [`directories` section](#parameter-directories-for-apachevhost). + +#####`directoryindex` + +Sets the list of resources to look for when a client requests an index of the directory by specifying a '/' at the end of the directory name. [DirectoryIndex](http://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex) has more information. Defaults to 'undef'. + +#####`docroot` + +Provides the [DocumentRoot](http://httpd.apache.org/docs/current/mod/core.html#documentroot) directive, which identifies the directory Apache serves files from. Required. + +#####`docroot_group` + +Sets group access to the docroot directory. Defaults to 'root'. + +#####`docroot_owner` + +Sets individual user access to the docroot directory. Defaults to 'root'. + +#####`docroot_mode` + +Sets access permissions of the docroot directory. Defaults to 'undef'. + +#####`error_log` + +Specifies whether `*_error.log` directives should be configured. Defaults to 'true'. + +#####`error_log_file` + +Points to the `*_error.log` file. Given a vhost, example.com, it defaults to 'example.com_ssl_error.log' for SSL vhosts and 'example.com_access_error.log' for non-SSL vhosts. + +#####`error_log_pipe` + +Specifies a pipe to send error log messages to. Defaults to 'undef'. + +#####`error_log_syslog` + +Sends all error log messages to syslog. Defaults to 'undef'. + +#####`error_documents` + +A list of hashes which can be used to override the [ErrorDocument](https://httpd.apache.org/docs/current/mod/core.html#errordocument) settings for this vhost. Defaults to '[]'. Example: + +```puppet + apache::vhost { 'sample.example.net': + error_documents => [ + { 'error_code' => '503', 'document' => '/service-unavail' }, + { 'error_code' => '407', 'document' => 'https://example.com/proxy/login' }, + ], + } +``` + +#####`ensure` + +Specifies if the vhost file is present or absent. Defaults to 'present'. + +#####`fallbackresource` + +Sets the [FallbackResource](http://httpd.apache.org/docs/current/mod/mod_dir.html#fallbackresource) directive, which specifies an action to take for any URL that doesn't map to anything in your filesystem and would otherwise return 'HTTP 404 (Not Found)'. Valid values must either begin with a / or be 'disabled'. Defaults to 'undef'. + +#####`headers` + +Adds lines to replace, merge, or remove response headers. See [Header](http://httpd.apache.org/docs/current/mod/mod_headers.html#header) for more information. Can be an array. Defaults to 'undef'. + +#####`ip` + +Sets the IP address the vhost listens on. Defaults to listen on all IPs. + +#####`ip_based` + +Enables an [IP-based](http://httpd.apache.org/docs/current/vhosts/ip-based.html) vhost. This parameter inhibits the creation of a NameVirtualHost directive, since those are used to funnel requests to name-based vhosts. Defaults to 'false'. + +#####`itk` + +Configures [ITK](http://mpm-itk.sesse.net/) in a hash. Keys may be: + +* user + group +* `assignuseridexpr` +* `assigngroupidexpr` +* `maxclientvhost` +* `nice` +* `limituidrange` (Linux 3.5.0 or newer) +* `limitgidrange` (Linux 3.5.0 or newer) + +Usage will typically look like: + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + itk => { + user => 'someuser', + group => 'somegroup', + }, + } +``` + +#####`logroot` + +Specifies the location of the virtual host's logfiles. Defaults to '/var/log//'. + +#####`log_level` + +Specifies the verbosity of the error log. Defaults to 'warn' for the global server configuration and can be overridden on a per-vhost basis. Valid values are 'emerg', 'alert', 'crit', 'error', 'warn', 'notice', 'info' or 'debug'. + +#####`no_proxy_uris` + +Specifies URLs you do not want to proxy. This parameter is meant to be used in combination with [`proxy_dest`](#proxy_dest). + +#####`proxy_preserve_host` + +Sets the [ProxyPreserveHost Directive](http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypreservehost). true Enables the Host: line from an incoming request to be proxied to the host instead of hostname . false sets this option to off (default). + +#####`options` + +Sets the [Options](http://httpd.apache.org/docs/current/mod/core.html#options) for the specified virtual host. Defaults to '['Indexes','FollowSymLinks','MultiViews']', as demonstrated below: + +```puppet + apache::vhost { 'site.name.fdqn': + … + options => ['Indexes','FollowSymLinks','MultiViews'], + } +``` + +*Note:* If you use [`directories`](#parameter-directories-for-apachevhost), 'Options', 'Override', and 'DirectoryIndex' are ignored because they are parameters within `directories`. + +#####`override` + +Sets the overrides for the specified virtual host. Accepts an array of [AllowOverride](http://httpd.apache.org/docs/current/mod/core.html#allowoverride) arguments. Defaults to '[none]'. + +#####`php_admin_flags & values` + +Allows per-vhost setting [`php_admin_value`s or `php_admin_flag`s](http://php.net/manual/en/configuration.changes.php). These flags or values cannot be overwritten by a user or an application. Defaults to '[]'. + +#####`port` + +Sets the port the host is configured on. The module's defaults ensure the host listens on port 80 for non-SSL vhosts and port 443 for SSL vhosts. The host will only listen on the port set in this parameter. + +#####`priority` + +Sets the relative load-order for Apache HTTPD VirtualHost configuration files. Defaults to '25'. + +If nothing matches the priority, the first name-based vhost will be used. Likewise, passing a higher priority will cause the alphabetically first name-based vhost to be used if no other names match. + +*Note:* You should not need to use this parameter. However, if you do use it, be aware that the `default_vhost` parameter for `apache::vhost` passes a priority of '15'. + +#####`proxy_dest` + +Specifies the destination address of a [ProxyPass](http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass) configuration. Defaults to 'undef'. + +#####`proxy_pass` + +Specifies an array of `path => URI` for a [ProxyPass](http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypass) configuration. Defaults to 'undef'. + +```puppet +apache::vhost { 'site.name.fdqn': + … + proxy_pass => [ + { 'path' => '/a', 'url' => 'http://backend-a/' }, + { 'path' => '/b', 'url' => 'http://backend-b/' }, + { 'path' => '/c', 'url' => 'http://backend-a/c' }, + ], +} +``` + +#####`rack_base_uris` + +Specifies the resource identifiers for a rack configuration. The file paths specified will be listed as rack application roots for [Phusion Passenger](http://www.modrails.com/documentation/Users%20guide%20Apache.html#_railsbaseuri_and_rackbaseuri) in the _rack.erb template. Defaults to 'undef'. + +#####`redirect_dest` + +Specifies the address to redirect to. Defaults to 'undef'. + +#####`redirect_source` + +Specifies the source URIs that will redirect to the destination specified in `redirect_dest`. If more than one item for redirect is supplied, the source and destination must be the same length and the items will be order-dependent. + +```puppet + apache::vhost { 'site.name.fdqn': + … + redirect_source => ['/images','/downloads'], + redirect_dest => ['http://img.example.com/','http://downloads.example.com/'], + } +``` + +#####`redirect_status` + +Specifies the status to append to the redirect. Defaults to 'undef'. + +```puppet + apache::vhost { 'site.name.fdqn': + … + redirect_status => ['temp','permanent'], + } +``` + +#####`redirectmatch_regexp` & `redirectmatch_status` + +Determines which server status should be raised for a given regular expression. Entered as an array. Defaults to 'undef'. + +```puppet + apache::vhost { 'site.name.fdqn': + … + redirectmatch_status => ['404','404'], + redirectmatch_regexp => ['\.git(/.*|$)/','\.svn(/.*|$)'], + } +``` + +#####`request_headers` + +Modifies collected [request headers](http://httpd.apache.org/docs/current/mod/mod_headers.html#requestheader) in various ways, including adding additional request headers, removing request headers, etc. Defaults to 'undef'. + +```puppet + apache::vhost { 'site.name.fdqn': + … + request_headers => [ + 'append MirrorID "mirror 12"', + 'unset MirrorID', + ], + } +``` + +#####`rewrites` + +Creates URL rewrite rules. Expects an array of hashes, and the hash keys can be any of 'comment', 'rewrite_base', 'rewrite_cond', or 'rewrite_rule'. Defaults to 'undef'. + +For example, you can specify that anyone trying to access index.html will be served welcome.html + +```puppet + apache::vhost { 'site.name.fdqn': + … + rewrites => [ { rewrite_rule => ['^index\.html$ welcome.html'] } ] + } +``` + +The parameter allows rewrite conditions that, when true, will execute the associated rule. For instance, if you wanted to rewrite URLs only if the visitor is using IE + +```puppet + apache::vhost { 'site.name.fdqn': + … + rewrites => [ + { + comment => 'redirect IE', + rewrite_cond => ['%{HTTP_USER_AGENT} ^MSIE'], + rewrite_rule => ['^index\.html$ welcome.html'], + }, + ], + } +``` + +You can also apply multiple conditions. For instance, rewrite index.html to welcome.html only when the browser is Lynx or Mozilla (version 1 or 2) + +```puppet + apache::vhost { 'site.name.fdqn': + … + rewrites => [ + { + comment => 'Lynx or Mozilla v1/2', + rewrite_cond => ['%{HTTP_USER_AGENT} ^Lynx/ [OR]', '%{HTTP_USER_AGENT} ^Mozilla/[12]'], + rewrite_rule => ['^index\.html$ welcome.html'], + }, + ], + } +``` + +Multiple rewrites and conditions are also possible + +```puppet + apache::vhost { 'site.name.fdqn': + … + rewrites => [ + { + comment => 'Lynx or Mozilla v1/2', + rewrite_cond => ['%{HTTP_USER_AGENT} ^Lynx/ [OR]', '%{HTTP_USER_AGENT} ^Mozilla/[12]'], + rewrite_rule => ['^index\.html$ welcome.html'], + }, + { + comment => 'Internet Explorer', + rewrite_cond => ['%{HTTP_USER_AGENT} ^MSIE'], + rewrite_rule => ['^index\.html$ /index.IE.html [L]'], + }, + { + rewrite_base => /apps/, + rewrite_rule => ['^index\.cgi$ index.php', '^index\.html$ index.php', '^index\.asp$ index.html'], + }, + ], + } +``` + +Refer to the [`mod_rewrite` documentation](http://httpd.apache.org/docs/current/mod/mod_rewrite.html) for more details on what is possible with rewrite rules and conditions. + +#####`scriptalias` + +Defines a directory of CGI scripts to be aliased to the path '/cgi-bin', for example: '/usr/scripts'. Defaults to 'undef'. + +#####`scriptaliases` + +Passes an array of hashes to the vhost to create either ScriptAlias or ScriptAliasMatch statements as per the [`mod_alias` documentation](http://httpd.apache.org/docs/current/mod/mod_alias.html). These hashes are formatted as follows: + +```puppet + scriptaliases => [ + { + alias => '/myscript', + path => '/usr/share/myscript', + }, + { + aliasmatch => '^/foo(.*)', + path => '/usr/share/fooscripts$1', + }, + { + aliasmatch => '^/bar/(.*)', + path => '/usr/share/bar/wrapper.sh/$1', + }, + { + alias => '/neatscript', + path => '/usr/share/neatscript', + }, + ] +``` + +The ScriptAlias and ScriptAliasMatch directives are created in the order specified. As with [Alias and AliasMatch](#aliases) directives, more specific aliases should come before more general ones to avoid shadowing. + +#####`serveradmin` + +Specifies the email address Apache will display when it renders one of its error pages. Defaults to 'undef'. + +#####`serveraliases` + +Sets the [ServerAliases](http://httpd.apache.org/docs/current/mod/core.html#serveralias) of the site. Defaults to '[]'. + +#####`servername` + +Sets the servername corresponding to the hostname you connect to the virtual host at. Defaults to the title of the resource. + +#####`setenv` + +Used by HTTPD to set environment variables for vhosts. Defaults to '[]'. + +#####`setenvif` + +Used by HTTPD to conditionally set environment variables for vhosts. Defaults to '[]'. + +#####`suphp_addhandler`, `suphp_configpath`, & `suphp_engine` + +Set up a virtual host with [suPHP](http://suphp.org/DocumentationView.html?file=apache/CONFIG). + +`suphp_addhandler` defaults to 'php5-script' on RedHat and FreeBSD, and 'x-httpd-php' on Debian. + +`suphp_configpath` defaults to 'undef' on RedHat and FreeBSD, and '/etc/php5/apache2' on Debian. + +`suphp_engine` allows values 'on' or 'off'. Defaults to 'off' + +To set up a virtual host with suPHP + +```puppet + apache::vhost { 'suphp.example.com': + port => '80', + docroot => '/home/appuser/myphpapp', + suphp_addhandler => 'x-httpd-php', + suphp_engine => 'on', + suphp_configpath => '/etc/php5/apache2', + directories => { path => '/home/appuser/myphpapp', + 'suphp' => { user => 'myappuser', group => 'myappgroup' }, + } + } +``` + +#####`vhost_name` + +Enables name-based virtual hosting. If no IP is passed to the virtual host but the vhost is assigned a port, then the vhost name will be 'vhost_name:port'. If the virtual host has no assigned IP or port, the vhost name will be set to the title of the resource. Defaults to '*'. + +#####`virtual_docroot` + +Sets up a virtual host with a wildcard alias subdomain mapped to a directory with the same name. For example, 'http://example.com' would map to '/var/www/example.com'. Defaults to 'false'. + +```puppet + apache::vhost { 'subdomain.loc': + vhost_name => '*', + port => '80', + virtual_docroot' => '/var/www/%-2+', + docroot => '/var/www', + serveraliases => ['*.loc',], + } +``` + +#####`wsgi_daemon_process`, `wsgi_daemon_process_options`, `wsgi_process_group`, `wsgi_script_aliases`, & `wsgi_pass_authorization` + +Set up a virtual host with [WSGI](https://code.google.com/p/modwsgi/). + +`wsgi_daemon_process` sets the name of the WSGI daemon. It is a hash, accepting [these keys](http://modwsgi.readthedocs.org/en/latest/configuration-directives/WSGIDaemonProcess.html), and it defaults to 'undef'. + +`wsgi_daemon_process_options` is optional and defaults to 'undef'. + +`wsgi_process_group` sets the group ID the virtual host will run under. Defaults to 'undef'. + +`wsgi_script_aliases` requires a hash of web paths to filesystem .wsgi paths. Defaults to 'undef'. + +`wsgi_pass_authorization` the WSGI application handles authorisation instead of Apache when set to 'On'. For more information see [here] (http://modwsgi.readthedocs.org/en/latest/configuration-directives/WSGIPassAuthorization.html). Defaults to 'undef' where apache will set the defaults setting to 'Off'. + +To set up a virtual host with WSGI + +```puppet + apache::vhost { 'wsgi.example.com': + port => '80', + docroot => '/var/www/pythonapp', + wsgi_daemon_process => 'wsgi', + wsgi_daemon_process_options => + { processes => '2', + threads => '15', + display-name => '%{GROUP}', + }, + wsgi_process_group => 'wsgi', + wsgi_script_aliases => { '/' => '/var/www/demo.wsgi' }, + } +``` + +####Parameter `directories` for `apache::vhost` + +The `directories` parameter within the `apache::vhost` class passes an array of hashes to the vhost to create [Directory](http://httpd.apache.org/docs/current/mod/core.html#directory), [File](http://httpd.apache.org/docs/current/mod/core.html#files), and [Location](http://httpd.apache.org/docs/current/mod/core.html#location) directive blocks. These blocks take the form, '< Directory /path/to/directory>...< /Directory>'. + +Each hash passed to `directories` must contain `path` as one of the keys. You may also pass in `provider` which, if missing, defaults to 'directory'. (A full list of acceptable keys is below.) General usage will look something like + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', => }, + { path => '/path/to/another/directory', => }, + ], + } +``` + +*Note:* At least one directory should match the `docroot` parameter. Once you start declaring directories, `apache::vhost` assumes that all required Directory blocks will be declared. If not defined, a single default Directory block will be created that matches the `docroot` parameter. + +The `provider` key can be set to 'directory', 'files', or 'location'. If the path starts with a [~](https://httpd.apache.org/docs/current/mod/core.html#files), HTTPD will interpret this as the equivalent of DirectoryMatch, FilesMatch, or LocationMatch. + +```puppet + apache::vhost { 'files.example.net': + docroot => '/var/www/files', + directories => [ + { 'path' => '/var/www/files', + 'provider' => 'files', + 'deny' => 'from all' + }, + ], + } +``` + +Available handlers, represented as keys, should be placed within the `directory`,`'files`, or `location` hashes. This looks like + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ { path => '/path/to/directory', handler => value } ], +} +``` + +Any handlers you do not set in these hashes will be considered 'undefined' within Puppet and will not be added to the virtual host, resulting in the module using their default values. Currently this is the list of supported handlers: + +######`addhandlers` + +Sets [AddHandler](http://httpd.apache.org/docs/current/mod/mod_mime.html#addhandler) directives, which map filename extensions to the specified handler. Accepts a list of hashes, with `extensions` serving to list the extensions being managed by the handler, and takes the form: `{ handler => 'handler-name', extensions => ['extension']}`. + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + addhandlers => [{ handler => 'cgi-script', extensions => ['.cgi']}], + }, + ], + } +``` + +######`allow` + +Sets an [Allow](http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#allow) directive, which groups authorizations based on hostnames or IPs. **Deprecated:** This parameter is being deprecated due to a change in Apache. It will only work with Apache 2.2 and lower. You can use it as a single string for one rule or as an array for more than one. + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + allow => 'from example.org', + }, + ], + } +``` + +######`allow_override` + +Sets the types of directives allowed in [.htaccess](http://httpd.apache.org/docs/current/mod/core.html#allowoverride) files. Accepts an array. + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + allow_override => ['AuthConfig', 'Indexes'], + }, + ], + } +``` + +######`auth_basic_authoritative` + +Sets the value for [AuthBasicAuthoritative](https://httpd.apache.org/docs/current/mod/mod_auth_basic.html#authbasicauthoritative), which determines whether authorization and authentication are passed to lower level Apache modules. + +######`auth_basic_fake` + +Sets the value for [AuthBasicFake](http://httpd.apache.org/docs/current/mod/mod_auth_basic.html#authbasicfake), which statically configures authorization credentials for a given directive block. + +######`auth_basic_provider` + +Sets the value for [AuthBasicProvider] (http://httpd.apache.org/docs/current/mod/mod_auth_basic.html#authbasicprovider), which sets the authentication provider for a given location. + +######`auth_digest_algorithm` + +Sets the value for [AuthDigestAlgorithm](http://httpd.apache.org/docs/current/mod/mod_auth_digest.html#authdigestalgorithm), which selects the algorithm used to calculate the challenge and response hashes. + +######`auth_digest_domain` + +Sets the value for [AuthDigestDomain](http://httpd.apache.org/docs/current/mod/mod_auth_digest.html#authdigestdomain), which allows you to specify one or more URIs in the same protection space for digest authentication. + +######`auth_digest_nonce_lifetime` + +Sets the value for [AuthDigestNonceLifetime](http://httpd.apache.org/docs/current/mod/mod_auth_digest.html#authdigestnoncelifetime), which controls how long the server nonce is valid. + +######`auth_digest_provider` + +Sets the value for [AuthDigestProvider](http://httpd.apache.org/docs/current/mod/mod_auth_digest.html#authdigestprovider), which sets the authentication provider for a given location. + +######`auth_digest_qop` + +Sets the value for [AuthDigestQop](http://httpd.apache.org/docs/current/mod/mod_auth_digest.html#authdigestqop), which determines the quality-of-protection to use in digest authentication. + +######`auth_digest_shmem_size` + +Sets the value for [AuthAuthDigestShmemSize](http://httpd.apache.org/docs/current/mod/mod_auth_digest.html#authdigestshmemsize), which defines the amount of shared memory allocated to the server for keeping track of clients. + +######`auth_group_file` + +Sets the value for [AuthGroupFile](https://httpd.apache.org/docs/current/mod/mod_authz_groupfile.html#authgroupfile), which sets the name of the text file containing the list of user groups for authorization. + +######`auth_name` + +Sets the value for [AuthName](http://httpd.apache.org/docs/current/mod/mod_authn_core.html#authname), which sets the name of the authorization realm. + +######`auth_require` + +Sets the entity name you're requiring to allow access. Read more about [Require](http://httpd.apache.org/docs/current/mod/mod_authz_host.html#requiredirectives). + +######`auth_type` + +Sets the value for [AuthType](http://httpd.apache.org/docs/current/mod/mod_authn_core.html#authtype), which guides the type of user authentication. + +######`auth_user_file` + +Sets the value for [AuthUserFile](http://httpd.apache.org/docs/current/mod/mod_authn_file.html#authuserfile), which sets the name of the text file containing the users/passwords for authentication. + +######`custom_fragment` + +Pass a string of custom configuration directives to be placed at the end of the directory configuration. + +```puppet + apache::vhost { 'monitor': + … + custom_fragment => ' + + SetHandler balancer-manager + Order allow,deny + Allow from all + + + SetHandler server-status + Order allow,deny + Allow from all + + ProxyStatus On', +} +``` + +######`deny` + +Sets a [Deny](http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#deny) directive, specifying which hosts are denied access to the server. **Deprecated:** This parameter is being deprecated due to a change in Apache. It will only work with Apache 2.2 and lower. + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + deny => 'from example.org', + }, + ], + } +``` + +######`error_documents` + +An array of hashes used to override the [ErrorDocument](https://httpd.apache.org/docs/current/mod/core.html#errordocument) settings for the directory. + +```puppet + apache::vhost { 'sample.example.net': + directories => [ + { path => '/srv/www', + error_documents => [ + { 'error_code' => '503', + 'document' => '/service-unavail', + }, + ], + }, + ], + } +``` + +######`headers` + +Adds lines for [Header](http://httpd.apache.org/docs/current/mod/mod_headers.html#header) directives. + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => { + path => '/path/to/directory', + headers => 'Set X-Robots-Tag "noindex, noarchive, nosnippet"', + }, + } +``` + +######`index_options` + +Allows configuration settings for [directory indexing](http://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexoptions). + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + options => ['Indexes','FollowSymLinks','MultiViews'], + index_options => ['IgnoreCase', 'FancyIndexing', 'FoldersFirst', 'NameWidth=*', 'DescriptionWidth=*', 'SuppressHTMLPreamble'], + }, + ], + } +``` + +######`index_order_default` + +Sets the [default ordering](http://httpd.apache.org/docs/current/mod/mod_autoindex.html#indexorderdefault) of the directory index. + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + order => 'Allow,Deny', + index_order_default => ['Descending', 'Date'], + }, + ], + } +``` + +######`options` + +Lists the [Options](http://httpd.apache.org/docs/current/mod/core.html#options) for the given Directory block. + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + options => ['Indexes','FollowSymLinks','MultiViews'], + }, + ], + } +``` + +######`order` + +Sets the order of processing Allow and Deny statements as per [Apache core documentation](httpd.apache.org/docs/2.2/mod/mod_authz_host.html#order). **Deprecated:** This parameter is being deprecated due to a change in Apache. It will only work with Apache 2.2 and lower. + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + order => 'Allow,Deny', + }, + ], + } +``` + +######`sethandler` + +Sets a `SetHandler` directive as per the [Apache Core documentation](http://httpd.apache.org/docs/2.2/mod/core.html#sethandler). An example: + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + sethandler => 'None', + } + ], + } +``` + +######`passenger_enabled` + +Sets the value for the [PassengerEnabled](http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerEnabled) directory to 'on' or 'off'. Requires `apache::mod::passenger` to be included. + +```puppet + apache::vhost { 'sample.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + passenger_enabled => 'on', + }, + ], + } +``` + +*Note:* Be aware that there is an [issue](http://www.conandalton.net/2010/06/passengerenabled-off-not-working.html) using the PassengerEnabled directive with the PassengerHighPerformance directive. + +######`php_admin_value` and `php_admin_flag` + +`php_admin_value` sets the value of the directory, and `php_admin_flag` uses a boolean to configure the directory. Further information can be found [here](http://php.net/manual/en/configuration.changes.php). + +######`ssl_options` + +String or list of [SSLOptions](https://httpd.apache.org/docs/current/mod/mod_ssl.html#ssloptions), which configure SSL engine run-time options. This handler takes precedence over SSLOptions set in the parent block of the vhost. + +```puppet + apache::vhost { 'secure.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + ssl_options => '+ExportCertData', + }, + { path => '/path/to/different/dir', + ssl_options => [ '-StdEnvVars', '+ExportCertData'], + }, + ], + } +``` + +######`suphp` + +A hash containing the 'user' and 'group' keys for the [suPHP_UserGroup](http://www.suphp.org/DocumentationView.html?file=apache/CONFIG) setting. It must be used with `suphp_engine => on` in the vhost declaration, and may only be passed within `directories`. + +```puppet + apache::vhost { 'secure.example.net': + docroot => '/path/to/directory', + directories => [ + { path => '/path/to/directory', + suphp => + { user => 'myappuser', + group => 'myappgroup', + }, + }, + ], + } +``` + +####SSL parameters for `apache::vhost` + +All of the SSL parameters for `::vhost` will default to whatever is set in the base `apache` class. Use the below parameters to tweak individual SSL settings for specific vhosts. + +#####`ssl` + +Enables SSL for the virtual host. SSL vhosts only respond to HTTPS queries. Valid values are 'true' or 'false'. Defaults to 'false'. + +#####`ssl_ca` + +Specifies the SSL certificate authority. Defaults to 'undef'. + +#####`ssl_cert` + +Specifies the SSL certification. Defaults are based on your OS: '/etc/pki/tls/certs/localhost.crt' for RedHat, '/etc/ssl/certs/ssl-cert-snakeoil.pem' for Debian, and '/usr/local/etc/apache22/server.crt' for FreeBSD. + +#####`ssl_protocol` + +Specifies [SSLProtocol](http://httpd.apache.org/docs/current/mod/mod_ssl.html#sslprotocol). Defaults to 'undef'. + +If you do not use this parameter, it will use the HTTPD default from ssl.conf.erb, 'all -SSLv2'. + +#####`ssl_cipher` + +Specifies [SSLCipherSuite](http://httpd.apache.org/docs/current/mod/mod_ssl.html#sslciphersuite). Defaults to 'undef'. + +If you do not use this parameter, it will use the HTTPD default from ssl.conf.erb, 'HIGH:MEDIUM:!aNULL:!MD5'. + +#####`ssl_honorcipherorder` + +Sets [SSLHonorCipherOrder](http://httpd.apache.org/docs/current/mod/mod_ssl.html#sslhonorcipherorder), which is used to prefer the server's cipher preference order. Defaults to 'On' in the base `apache` config. + +#####`ssl_certs_dir` + +Specifies the location of the SSL certification directory. Defaults to '/etc/ssl/certs' on Debian, '/etc/pki/tls/certs' on RedHat, and '/usr/local/etc/apache22' on FreeBSD. + +#####`ssl_chain` + +Specifies the SSL chain. Defaults to 'undef'. (This default will work out of the box but must be updated in the base `apache` class with your specific certificate information before being used in production.) + +#####`ssl_crl` + +Specifies the certificate revocation list to use. Defaults to 'undef'. (This default will work out of the box but must be updated in the base `apache` class with your specific certificate information before being used in production.) + +#####`ssl_crl_path` + +Specifies the location of the certificate revocation list. Defaults to 'undef'. (This default will work out of the box but must be updated in the base `apache` class with your specific certificate information before being used in production.) + +#####`ssl_key` + +Specifies the SSL key. Defaults are based on your operating system: '/etc/pki/tls/private/localhost.key' for RedHat, '/etc/ssl/private/ssl-cert-snakeoil.key' for Debian, and '/usr/local/etc/apache22/server.key' for FreeBSD. (This default will work out of the box but must be updated in the base `apache` class with your specific certificate information before being used in production.) + +#####`ssl_verify_client` + +Sets the [SSLVerifyClient](http://httpd.apache.org/docs/current/mod/mod_ssl.html#sslverifyclient) directive, which sets the certificate verification level for client authentication. Valid values are: 'none', 'optional', 'require', and 'optional_no_ca'. Defaults to 'undef'. + +```puppet + apache::vhost { 'sample.example.net': + … + ssl_verify_client => 'optional', + } +``` + +#####`ssl_verify_depth` + +Sets the [SSLVerifyDepth](http://httpd.apache.org/docs/current/mod/mod_ssl.html#sslverifydepth) directive, which specifies the maximum depth of CA certificates in client certificate verification. Defaults to 'undef'. + +```puppet + apache::vhost { 'sample.example.net': + … + ssl_verify_depth => 1, + } +``` + +#####`ssl_options` + +Sets the [SSLOptions](http://httpd.apache.org/docs/current/mod/mod_ssl.html#ssloptions) directive, which configures various SSL engine run-time options. This is the global setting for the given vhost and can be a string or an array. Defaults to 'undef'. + +A string: + +```puppet + apache::vhost { 'sample.example.net': + … + ssl_options => '+ExportCertData', + } +``` + +An array: + +```puppet + apache::vhost { 'sample.example.net': + … + ssl_options => [ '+StrictRequire', '+ExportCertData' ], + } +``` + +#####`ssl_proxyengine` + +Specifies whether or not to use [SSLProxyEngine](http://httpd.apache.org/docs/current/mod/mod_ssl.html#sslproxyengine). Valid values are 'true' and 'false'. Defaults to 'false'. + + +###Virtual Host Examples + +The apache module allows you to set up pretty much any configuration of virtual host you might need. This section will address some common configurations, but look at the [Tests section](https://github.com/puppetlabs/puppetlabs-apache/tree/master/tests) for even more examples. + +Configure a vhost with a server administrator + +```puppet + apache::vhost { 'third.example.com': + port => '80', + docroot => '/var/www/third', + serveradmin => 'admin@example.com', + } +``` + +- - - + +Set up a vhost with aliased servers + +```puppet + apache::vhost { 'sixth.example.com': + serveraliases => [ + 'sixth.example.org', + 'sixth.example.net', + ], + port => '80', + docroot => '/var/www/fifth', + } +``` + +- - - + +Configure a vhost with a cgi-bin + +```puppet + apache::vhost { 'eleventh.example.com': + port => '80', + docroot => '/var/www/eleventh', + scriptalias => '/usr/lib/cgi-bin', + } +``` + +- - - + +Set up a vhost with a rack configuration + +```puppet + apache::vhost { 'fifteenth.example.com': + port => '80', + docroot => '/var/www/fifteenth', + rack_base_uris => ['/rackapp1', '/rackapp2'], + } +``` + +- - - + +Set up a mix of SSL and non-SSL vhosts at the same domain + +```puppet + #The non-ssl vhost + apache::vhost { 'first.example.com non-ssl': + servername => 'first.example.com', + port => '80', + docroot => '/var/www/first', + } + + #The SSL vhost at the same domain + apache::vhost { 'first.example.com ssl': + servername => 'first.example.com', + port => '443', + docroot => '/var/www/first', + ssl => true, + } +``` + +- - - + +Configure a vhost to redirect non-SSL connections to SSL + +```puppet + apache::vhost { 'sixteenth.example.com non-ssl': + servername => 'sixteenth.example.com', + port => '80', + docroot => '/var/www/sixteenth', + redirect_status => 'permanent', + redirect_dest => 'https://sixteenth.example.com/' + } + apache::vhost { 'sixteenth.example.com ssl': + servername => 'sixteenth.example.com', + port => '443', + docroot => '/var/www/sixteenth', + ssl => true, + } +``` + +- - - + +Set up IP-based vhosts on any listen port and have them respond to requests on specific IP addresses. In this example, we will set listening on ports 80 and 81. This is required because the example vhosts are not declared with a port parameter. + +```puppet + apache::listen { '80': } + apache::listen { '81': } +``` + +Then we will set up the IP-based vhosts + +```puppet + apache::vhost { 'first.example.com': + ip => '10.0.0.10', + docroot => '/var/www/first', + ip_based => true, + } + apache::vhost { 'second.example.com': + ip => '10.0.0.11', + docroot => '/var/www/second', + ip_based => true, + } +``` + +- - - + +Configure a mix of name-based and IP-based vhosts. First, we will add two IP-based vhosts on 10.0.0.10, one SSL and one non-SSL + +```puppet + apache::vhost { 'The first IP-based vhost, non-ssl': + servername => 'first.example.com', + ip => '10.0.0.10', + port => '80', + ip_based => true, + docroot => '/var/www/first', + } + apache::vhost { 'The first IP-based vhost, ssl': + servername => 'first.example.com', + ip => '10.0.0.10', + port => '443', + ip_based => true, + docroot => '/var/www/first-ssl', + ssl => true, + } +``` + +Then, we will add two name-based vhosts listening on 10.0.0.20 + +```puppet + apache::vhost { 'second.example.com': + ip => '10.0.0.20', + port => '80', + docroot => '/var/www/second', + } + apache::vhost { 'third.example.com': + ip => '10.0.0.20', + port => '80', + docroot => '/var/www/third', + } +``` + +If you want to add two name-based vhosts so that they will answer on either 10.0.0.10 or 10.0.0.20, you **MUST** declare `add_listen => 'false'` to disable the otherwise automatic 'Listen 80', as it will conflict with the preceding IP-based vhosts. + +```puppet + apache::vhost { 'fourth.example.com': + port => '80', + docroot => '/var/www/fourth', + add_listen => false, + } + apache::vhost { 'fifth.example.com': + port => '80', + docroot => '/var/www/fifth', + add_listen => false, + } +``` + +###Load Balancing + +####Defined Type: `apache::balancer` + +`apache::balancer` creates an Apache balancer cluster. Each balancer cluster needs one or more balancer members, which are declared with [`apache::balancermember`](#defined-type-apachebalancermember). + +One `apache::balancer` defined resource should be defined for each Apache load balanced set of servers. The `apache::balancermember` resources for all balancer members can be exported and collected on a single Apache load balancer server using exported resources. + +**Parameters within `apache::balancer`:** + +#####`name` + +Sets the balancer cluster's title. This parameter will also set the title of the conf.d file. + +#####`proxy_set` + +Configures key-value pairs as [ProxySet](http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxyset) lines. Accepts a hash, and defaults to '{}'. + +#####`collect_exported` + +Determines whether or not to use exported resources. Valid values 'true' and 'false', defaults to 'true'. + +If you statically declare all of your backend servers, you should set this to 'false' to rely on existing declared balancer member resources. Also make sure to use `apache::balancermember` with array arguments. + +If you wish to dynamically declare your backend servers via [exported resources](http://docs.puppetlabs.com/guides/exported_resources.html) collected on a central node, you must set this parameter to 'true' in order to collect the exported balancer member resources that were exported by the balancer member nodes. + +If you choose not to use exported resources, all balancer members will be configured in a single puppet run. If you are using exported resources, Puppet has to run on the balanced nodes, then run on the balancer. + +####Defined Type: `apache::balancermember` + +Defines members of [mod_proxy_balancer](http://httpd.apache.org/docs/current/mod/mod_proxy_balancer.html), which will set up a balancer member inside a listening service configuration block in etc/apache/apache.cfg on the load balancer. + +**Parameters within `apache::balancermember`:** + +#####`name` + +Sets the title of the resource. This name will also set the name of the concat fragment. + +#####`balancer_cluster` + +Sets the Apache service's instance name. This must match the name of a declared `apache::balancer` resource. Required. + +#####`url` + +Specifies the URL used to contact the balancer member server. Defaults to 'http://${::fqdn}/'. + +#####`options` + +An array of [options](http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#balancermember) to be specified after the URL. Accepts any key-value pairs available to [ProxyPass](http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass). + +####Examples + +To load balance with exported resources, export the `balancermember` from the balancer member + +```puppet + @@apache::balancermember { "${::fqdn}-puppet00": + balancer_cluster => 'puppet00', + url => "ajp://${::fqdn}:8009" + options => ['ping=5', 'disablereuse=on', 'retry=5', 'ttl=120'], + } +``` + +Then, on the proxy server, create the balancer cluster + +```puppet + apache::balancer { 'puppet00': } +``` + +To load balance without exported resources, declare the following on the proxy + +```puppet + apache::balancer { 'puppet00': } + apache::balancermember { "${::fqdn}-puppet00": + balancer_cluster => 'puppet00', + url => "ajp://${::fqdn}:8009" + options => ['ping=5', 'disablereuse=on', 'retry=5', 'ttl=120'], + } +``` + +Then declare `apache::balancer` and `apache::balancermember` on the proxy server. + +If you need to use ProxySet in the balancer config + +```puppet + apache::balancer { 'puppet01': + proxy_set => {'stickysession' => 'JSESSIONID'}, + } +``` + +##Reference + +###Classes + +####Public Classes + +* [`apache`](#class-apache): Guides the basic setup of Apache. +* `apache::dev`: Installs Apache development libraries. (*Note:* On FreeBSD, you must declare `apache::package` or `apache` before `apache::dev`.) +* [`apache::mod::[name]`](#classes-apachemodname): Enables specific Apache HTTPD modules. + +####Private Classes + +* `apache::confd::no_accf`: Creates the no-accf.conf configuration file in conf.d, required by FreeBSD's Apache 2.4. +* `apache::default_confd_files`: Includes conf.d files for FreeBSD. +* `apache::default_mods`: Installs the Apache modules required to run the default configuration. +* `apache::package`: Installs and configures basic Apache packages. +* `apache::params`: Manages Apache parameters. +* `apache::service`: Manages the Apache daemon. + +###Defined Types + +####Public Defined Types + +* `apache::balancer`: Creates an Apache balancer cluster. +* `apache::balancermember`: Defines members of [mod_proxy_balancer](http://httpd.apache.org/docs/current/mod/mod_proxy_balancer.html). +* `apache::listen`: Based on the title, controls which ports Apache binds to for listening. Adds [Listen](http://httpd.apache.org/docs/current/bind.html) directives to ports.conf in the Apache HTTPD configuration directory. Titles take the form '', ':', or ':'. +* `apache::mod`: Used to enable arbitrary Apache HTTPD modules for which there is no specific `apache::mod::[name]` class. +* `apache::namevirtualhost`: Enables name-based hosting of a virtual host. Adds all [NameVirtualHost](http://httpd.apache.org/docs/current/vhosts/name-based.html) directives to the `ports.conf` file in the Apache HTTPD configuration directory. Titles take the form '\*', '*:', '\_default_:, '', or ':'. +* `apache::vhost`: Allows specialized configurations for virtual hosts that have requirements outside the defaults. + +####Private Defined Types + +* `apache::peruser::multiplexer`: Enables the [Peruser](http://www.freebsd.org/cgi/url.cgi?ports/www/apache22-peruser-mpm/pkg-descr) module for FreeBSD only. +* `apache::peruser::processor`: Enables the [Peruser](http://www.freebsd.org/cgi/url.cgi?ports/www/apache22-peruser-mpm/pkg-descr) module for FreeBSD only. + +###Templates + +The Apache module relies heavily on templates to enable the `vhost` and `apache::mod` defined types. These templates are built based on Facter facts around your operating system. Unless explicitly called out, most templates are not meant for configuration. + +##Limitations + +###Ubuntu 10.04 + +The `apache::vhost::WSGIImportScript` parameter creates a statement inside the VirtualHost which is unsupported on older versions of Apache, causing this to fail. This will be remedied in a future refactoring. + +###RHEL/CentOS 5 + +The `apache::mod::passenger` and `apache::mod::proxy_html` classes are untested since repositories are missing compatible packages. + +###RHEL/CentOS 7 + +The `apache::mod::passenger` class is untested as the repository does not have packages for EL7 yet. The fact that passenger packages aren't available also makes us unable to test the `rack_base_uri` parameter in `apache::vhost`. + +###General + +This module is CI tested on Centos 5 & 6, Ubuntu 12.04 & 14.04, Debian 7, and RHEL 5, 6 & 7 platforms against both the OSS and Enterprise version of Puppet. + +The module contains support for other distributions and operating systems, such as FreeBSD and Amazon Linux, but is not formally tested on those and regressions may occur. + +###SELinux and Custom Paths + +If you are running with SELinux in enforcing mode and want to use custom paths for your `logroot`, `mod_dir`, `vhost_dir`, and `docroot`, you will need to manage the context for the files yourself. + +Something along the lines of: + +```puppet + exec { 'set_apache_defaults': + command => 'semanage fcontext -a -t httpd_sys_content_t "/custom/path(/.*)?"', + path => '/bin:/usr/bin/:/sbin:/usr/sbin', + require => Package['policycoreutils-python'], + } + package { 'policycoreutils-python': ensure => installed } + exec { 'restorecon_apache': + command => 'restorecon -Rv /apache_spec', + path => '/bin:/usr/bin/:/sbin:/usr/sbin', + before => Service['httpd'], + require => Class['apache'], + } + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + file { '/custom/path': ensure => directory, } + file { '/custom/path/include': ensure => present, content => '#additional_includes' } + apache::vhost { 'test.server': + docroot => '/custom/path', + additional_includes => '/custom/path/include', + } +``` + +You need to set the contexts using `semanage fcontext` not `chcon` because `file {...}` resources will reset the context to the values in the database if the resource isn't specifying the context. + +##Development + +###Contributing + +Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. + +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) + +###Running tests + +This project contains tests for both [rspec-puppet](http://rspec-puppet.com/) and [beaker-rspec](https://github.com/puppetlabs/beaker-rspec) to verify functionality. For in-depth information please see their respective documentation. + +Quickstart: + + gem install bundler + bundle install + bundle exec rake spec + bundle exec rspec spec/acceptance + RS_DEBUG=yes bundle exec rspec spec/acceptance diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/README.passenger.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/README.passenger.md new file mode 100644 index 0000000000..4b4caa8c09 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/README.passenger.md @@ -0,0 +1,278 @@ +# Passenger + +Just enabling the Passenger module is insufficient for the use of Passenger in +production. Passenger should be tunable to better fit the environment in which +it is run while being aware of the resources it required. + +To this end the Apache passenger module has been modified to apply system wide +Passenger tuning declarations to `passenger.conf`. Declarations specific to a +virtual host should be passed through when defining a `vhost` (e.g. +`rack_base_uris` parameter on the `apache::vhost` type, check `README.md`). + +Also, general apache module loading parameters can be supplied to enable using +a customized passenger module in place of a default-package-based version of +the module. + +# Operating system support and Passenger versions + +The most important configuration directive for the Apache Passenger module is +`PassengerRoot`. Its value depends on the Passenger version used (2.x, 3.x or +4.x) and on the operating system package from which the Apache Passenger module +is installed. + +The following table summarises the current *default versions* and +`PassengerRoot` settings for the operating systems supported by +puppetlabs-apache: + +OS | Passenger version | `PassengerRoot` +---------------- | ------------------ | ---------------- +Debian 7 | 3.0.13 | /usr +Ubuntu 12.04 | 2.2.11 | /usr +Ubuntu 14.04 | 4.0.37 | /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini +RHEL with EPEL6 | 3.0.21 | /usr/lib/ruby/gems/1.8/gems/passenger-3.0.21 + +As mentioned in `README.md` there are no compatible packages available for +RHEL/CentOS 5 or RHEL/CentOS 7. + +## Configuration files and locations on RHEL/CentOS + +Notice two important points: + +1. The Passenger version packaged in the EPEL repositories may change over time. +2. The value of `PassengerRoot` depends on the Passenger version installed. + +To prevent the puppetlabs-apache module from having to keep up with these +package versions the Passenger configuration files installed by the +packages are left untouched by this module. All configuration is placed in an +extra configuration file managed by puppetlabs-apache. + +This means '/etc/httpd/conf.d/passenger.conf' is installed by the +`mod_passenger` package and contains correct values for `PassengerRoot` and +`PassengerRuby`. Puppet will ignore this file. Additional configuration +directives as described in the remainder of this document are placed in +'/etc/httpd/conf.d/passenger_extra.conf', managed by Puppet. + +This pertains *only* to RHEL/CentOS, *not* Debian and Ubuntu. + +## Third-party and custom Passenger packages and versions + +The Passenger version distributed by the default OS packages may be too old to +be useful. Newer versions may be installed via Gems, from source or from +third-party OS packages. + +Most notably the Passenger developers officially provide Debian packages for a +variety of Debian and Ubuntu releases in the [Passenger APT +repository](https://oss-binaries.phusionpassenger.com/apt/passenger). Read more +about [installing these packages in the offical user +guide](http://www.modrails.com/documentation/Users%20guide%20Apache.html#install_on_debian_ubuntu). + +If you install custom Passenger packages and newer version make sure to set the +directives `PassengerRoot`, `PassengerRuby` and/or `PassengerDefaultRuby` +correctly, or Passenger and Apache will fail to function properly. + +For Passenger 4.x packages on Debian and Ubuntu the `PassengerRoot` directive +should almost universally be set to +`/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini`. + +# Parameters for `apache::mod::passenger` + +The following class parameters configure Passenger in a global, server-wide +context. + +Example: + +```puppet +class { 'apache::mod::passenger': + passenger_root => '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini', + passenger_default_ruby => '/usr/bin/ruby1.9.3', + passenger_high_performance => 'on', + rails_autodetect => 'off', + mod_lib_path => '/usr/lib/apache2/custom_modules', +} +``` + +The general form is using the all lower-case version of the configuration +directive, with underscores instead of CamelCase. + +## Parameters used with passenger.conf + +If you pass a default value to `apache::mod::passenger` it will be ignored and +not passed through to the configuration file. + +### passenger_root + +The location to the Phusion Passenger root directory. This configuration option +is essential to Phusion Passenger, and allows Phusion Passenger to locate its +own data files. + +The default depends on the Passenger version and the means of installation. See +the above section on operating system support, versions and packages for more +information. + +http://www.modrails.com/documentation/Users%20guide%20Apache.html#_passengerroot_lt_directory_gt + +### passenger_default_ruby + +This option specifies the default Ruby interpreter to use for web apps as well +as for all sorts of internal Phusion Passenger helper scripts, e.g. the one +used by PassengerPreStart. + +This directive was introduced in Passenger 4.0.0 and will not work in versions +< 4.x. Do not set this parameter if your Passenger version is older than 4.0.0. + +Defaults to `undef` for all operating systems except Ubuntu 14.04, where it is +set to '/usr/bin/ruby'. + +http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerDefaultRuby + +### passenger_ruby + +This directive is the same as `passenger_default_ruby` for Passenger versions +< 4.x and must be used instead of `passenger_default_ruby` for such versions. + +It makes no sense to set `PassengerRuby` for Passenger >= 4.x. That +directive should only be used to override the value of `PassengerDefaultRuby` +on a non-global context, i.e. in ``, ``, `` +and so on. + +Defaults to `/usr/bin/ruby` for all supported operating systems except Ubuntu +14.04, where it is set to `undef`. + +http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerRuby + +### passenger_high_performance + +Default is `off`. When turned `on` Passenger runs in a higher performance mode +that can be less compatible with other Apache modules. + +http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerHighPerformance + +### passenger_max_pool_size + +Sets the maximum number of Passenger application processes that may +simultaneously run. The default value is 6. + +http://www.modrails.com/documentation/Users%20guide%20Apache.html#_passengermaxpoolsize_lt_integer_gt + +### passenger_pool_idle_time + +The maximum number of seconds a Passenger Application process will be allowed +to remain idle before being shut down. The default value is 300. + +http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerPoolIdleTime + +### passenger_max_requests + +The maximum number of request a Passenger application will process before being +restarted. The default value is 0, which indicates that a process will only +shut down if the Pool Idle Time (see above) expires. + +http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerMaxRequests + +### passenger_stat_throttle_rate + +Sets how often Passenger performs file system checks, at most once every _x_ +seconds. Default is 0, which means the checks are performed with every request. + +http://www.modrails.com/documentation/Users%20guide%20Apache.html#_passengerstatthrottlerate_lt_integer_gt + +### rack_autodetect + +Should Passenger automatically detect if the document root of a virtual host is +a Rack application. Not set by default (`undef`). Note that this directive has +been removed in Passenger 4.0.0 and `PassengerEnabled` should be used instead. +Use this directive only on Passenger < 4.x. + +http://www.modrails.com/documentation/Users%20guide%20Apache.html#_rackautodetect_lt_on_off_gt + +### rails_autodetect + +Should Passenger automatically detect if the document root of a virtual host is +a Rails application. Not set by default (`undef`). Note that this directive +has been removed in Passenger 4.0.0 and `PassengerEnabled` should be used +instead. Use this directive only on Passenger < 4.x. + +http://www.modrails.com/documentation/Users%20guide%20Apache.html#_railsautodetect_lt_on_off_gt + +### passenger_use_global_queue + +Allows toggling of PassengerUseGlobalQueue. NOTE: PassengerUseGlobalQueue is +the default in Passenger 4.x and the versions >= 4.x have disabled this +configuration option altogether. Use with caution. + +## Parameters used to load the module + +Unlike the tuning parameters specified above, the following parameters are only +used when loading customized passenger modules. + +### mod_package + +Allows overriding the default package name used for the passenger module +package. + +### mod_package_ensure + +Allows overriding the package installation setting used by puppet when +installing the passenger module. The default is 'present'. + +### mod_id + +Allows overriding the value used by apache to identify the passenger module. +The default is 'passenger_module'. + +### mod_lib_path + +Allows overriding the directory path used by apache when loading the passenger +module. The default is the value of `$apache::params::lib_path`. + +### mod_lib + +Allows overriding the library file name used by apache when loading the +passenger module. The default is 'mod_passenger.so'. + +### mod_path + +Allows overriding the full path to the library file used by apache when loading +the passenger module. The default is the concatenation of the `mod_lib_path` +and `mod_lib` parameters. + +# Dependencies + +RedHat-based systems will need to configure additional package repositories in +order to install Passenger, specifically: + +* [Extra Packages for Enterprise Linux](https://fedoraproject.org/wiki/EPEL) +* [Phusion Passenger](http://passenger.stealthymonkeys.com) + +Configuration of these repositories is beyond the scope of this module and is +left to the user. + +# Attribution + +The Passenger tuning parameters for the `apache::mod::passenger` Puppet class +was modified by Aaron Hicks (hicksa@landcareresearch.co.nz) for work on the +NeSI Project and the Tuakiri New Zealand Access Federation as a fork from the +PuppetLabs Apache module on GitHub. + +* https://github.com/puppetlabs/puppetlabs-apache +* https://github.com/nesi/puppetlabs-apache +* http://www.nesi.org.nz// +* https://tuakiri.ac.nz/confluence/display/Tuakiri/Home + +# Copyright and License + +Copyright (C) 2012 [Puppet Labs](https://www.puppetlabs.com/) Inc + +Puppet Labs can be contacted at: info@puppetlabs.com + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/Rakefile new file mode 100644 index 0000000000..5868545f20 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/Rakefile @@ -0,0 +1,10 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.fail_on_warnings +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_class_parameter_defaults') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/files/httpd b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/files/httpd new file mode 100644 index 0000000000..d65a8d445c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/files/httpd @@ -0,0 +1,24 @@ +# Configuration file for the httpd service. + +# +# The default processing model (MPM) is the process-based +# 'prefork' model. A thread-based model, 'worker', is also +# available, but does not work with some modules (such as PHP). +# The service must be stopped before changing this variable. +# +#HTTPD=/usr/sbin/httpd.worker + +# +# To pass additional options (for instance, -D definitions) to the +# httpd binary at startup, set OPTIONS here. +# +#OPTIONS= +#OPTIONS=-DDOWN + +# +# By default, the httpd process is started in the C locale; to +# change the locale in which the server runs, the HTTPD_LANG +# variable can be set. +# +#HTTPD_LANG=C +export SHORTHOST=`hostname -s` diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod.rb new file mode 100644 index 0000000000..670aca3d03 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod.rb @@ -0,0 +1,34 @@ +class Puppet::Provider::A2mod < Puppet::Provider + def self.prefetch(mods) + instances.each do |prov| + if mod = mods[prov.name] + mod.provider = prov + end + end + end + + def flush + @property_hash.clear + end + + def properties + if @property_hash.empty? + @property_hash = query || {:ensure => :absent} + @property_hash[:ensure] = :absent if @property_hash.empty? + end + @property_hash.dup + end + + def query + self.class.instances.each do |mod| + if mod.name == self.name or mod.name.downcase == self.name + return mod.properties + end + end + nil + end + + def exists? + properties[:ensure] != :absent + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/a2mod.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/a2mod.rb new file mode 100644 index 0000000000..e257a579e8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/a2mod.rb @@ -0,0 +1,35 @@ +require 'puppet/provider/a2mod' + +Puppet::Type.type(:a2mod).provide(:a2mod, :parent => Puppet::Provider::A2mod) do + desc "Manage Apache 2 modules on Debian and Ubuntu" + + optional_commands :encmd => "a2enmod" + optional_commands :discmd => "a2dismod" + commands :apache2ctl => "apache2ctl" + + confine :osfamily => :debian + defaultfor :operatingsystem => [:debian, :ubuntu] + + def self.instances + modules = apache2ctl("-M").lines.collect { |line| + m = line.match(/(\w+)_module \(shared\)$/) + m[1] if m + }.compact + + modules.map do |mod| + new( + :name => mod, + :ensure => :present, + :provider => :a2mod + ) + end + end + + def create + encmd resource[:name] + end + + def destroy + discmd resource[:name] + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/gentoo.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/gentoo.rb new file mode 100644 index 0000000000..07319dfdc8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/gentoo.rb @@ -0,0 +1,116 @@ +require 'puppet/util/filetype' +Puppet::Type.type(:a2mod).provide(:gentoo, :parent => Puppet::Provider) do + desc "Manage Apache 2 modules on Gentoo" + + confine :operatingsystem => :gentoo + defaultfor :operatingsystem => :gentoo + + attr_accessor :property_hash + + def create + @property_hash[:ensure] = :present + end + + def exists? + (!(@property_hash[:ensure].nil?) and @property_hash[:ensure] == :present) + end + + def destroy + @property_hash[:ensure] = :absent + end + + def flush + self.class.flush + end + + class << self + attr_reader :conf_file + end + + def self.clear + @mod_resources = [] + @modules = [] + @other_args = "" + end + + def self.initvars + @conf_file = "/etc/conf.d/apache2" + @filetype = Puppet::Util::FileType.filetype(:flat).new(conf_file) + @mod_resources = [] + @modules = [] + @other_args = "" + end + + self.initvars + + # Retrieve an array of all existing modules + def self.modules + if @modules.length <= 0 + # Locate the APACHE_OPTS variable + records = filetype.read.split(/\n/) + apache2_opts = records.grep(/^\s*APACHE2_OPTS=/).first + + # Extract all defines + while apache2_opts.sub!(/-D\s+(\w+)/, '') + @modules << $1.downcase + end + + # Hang on to any remaining options. + if apache2_opts.match(/APACHE2_OPTS="(.+)"/) + @other_args = $1.strip + end + + @modules.sort!.uniq! + end + + @modules + end + + def self.prefetch(resources={}) + # Match resources with existing providers + instances.each do |provider| + if resource = resources[provider.name] + resource.provider = provider + end + end + + # Store all resources using this provider for flushing + resources.each do |name, resource| + @mod_resources << resource + end + end + + def self.instances + modules.map {|mod| new(:name => mod, :provider => :gentoo, :ensure => :present)} + end + + def self.flush + + mod_list = modules + mods_to_remove = @mod_resources.select {|mod| mod.should(:ensure) == :absent}.map {|mod| mod[:name]} + mods_to_add = @mod_resources.select {|mod| mod.should(:ensure) == :present}.map {|mod| mod[:name]} + + mod_list -= mods_to_remove + mod_list += mods_to_add + mod_list.sort!.uniq! + + if modules != mod_list + opts = @other_args + " " + opts << mod_list.map {|mod| "-D #{mod.upcase}"}.join(" ") + opts.strip! + opts.gsub!(/\s+/, ' ') + + apache2_opts = %Q{APACHE2_OPTS="#{opts}"} + Puppet.debug("Writing back \"#{apache2_opts}\" to #{conf_file}") + + records = filetype.read.split(/\n/) + + opts_index = records.find_index {|i| i.match(/^\s*APACHE2_OPTS/)} + records[opts_index] = apache2_opts + + filetype.backup + filetype.write(records.join("\n")) + @modules = mod_list + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/modfix.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/modfix.rb new file mode 100644 index 0000000000..8f35b2e4a1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/modfix.rb @@ -0,0 +1,12 @@ +Puppet::Type.type(:a2mod).provide :modfix do + desc "Dummy provider for A2mod. + + Fake nil resources when there is no crontab binary available. Allows + puppetd to run on a bootstrapped machine before a Cron package has been + installed. Workaround for: http://projects.puppetlabs.com/issues/2384 + " + + def self.instances + [] + end +end \ No newline at end of file diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/redhat.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/redhat.rb new file mode 100644 index 0000000000..ea5494cb48 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/provider/a2mod/redhat.rb @@ -0,0 +1,60 @@ +require 'puppet/provider/a2mod' + +Puppet::Type.type(:a2mod).provide(:redhat, :parent => Puppet::Provider::A2mod) do + desc "Manage Apache 2 modules on RedHat family OSs" + + commands :apachectl => "apachectl" + + confine :osfamily => :redhat + defaultfor :osfamily => :redhat + + require 'pathname' + + # modpath: Path to default apache modules directory /etc/httpd/mod.d + # modfile: Path to module load configuration file; Default: resides under modpath directory + # libfile: Path to actual apache module library. Added in modfile LoadModule + + attr_accessor :modfile, :libfile + class << self + attr_accessor :modpath + def preinit + @modpath = "/etc/httpd/mod.d" + end + end + + self.preinit + + def create + File.open(modfile,'w') do |f| + f.puts "LoadModule #{resource[:identifier]} #{libfile}" + end + end + + def destroy + File.delete(modfile) + end + + def self.instances + modules = apachectl("-M").lines.collect { |line| + m = line.match(/(\w+)_module \(shared\)$/) + m[1] if m + }.compact + + modules.map do |mod| + new( + :name => mod, + :ensure => :present, + :provider => :redhat + ) + end + end + + def modfile + modfile ||= "#{self.class.modpath}/#{resource[:name]}.load" + end + + # Set libfile path: If absolute path is passed, then maintain it. Else, make it default from 'modules' dir. + def libfile + libfile = Pathname.new(resource[:lib]).absolute? ? resource[:lib] : "modules/#{resource[:lib]}" + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/type/a2mod.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/type/a2mod.rb new file mode 100644 index 0000000000..07a911e5ee --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/lib/puppet/type/a2mod.rb @@ -0,0 +1,30 @@ +Puppet::Type.newtype(:a2mod) do + @doc = "Manage Apache 2 modules" + + ensurable + + newparam(:name) do + Puppet.warning "The a2mod provider is deprecated, please use apache::mod instead" + desc "The name of the module to be managed" + + isnamevar + + end + + newparam(:lib) do + desc "The name of the .so library to be loaded" + + defaultto { "mod_#{@resource[:name]}.so" } + end + + newparam(:identifier) do + desc "Module identifier string used by LoadModule. Default: module-name_module" + + # http://httpd.apache.org/docs/2.2/mod/module-dict.html#ModuleIdentifier + + defaultto { "#{resource[:name]}_module" } + end + + autorequire(:package) { catalog.resource(:package, 'httpd')} + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/balancer.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/balancer.pp new file mode 100644 index 0000000000..173aaec2dd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/balancer.pp @@ -0,0 +1,83 @@ +# == Define Resource Type: apache::balancer +# +# This type will create an apache balancer cluster file inside the conf.d +# directory. Each balancer cluster needs one or more balancer members (that can +# be declared with the apache::balancermember defined resource type). Using +# storeconfigs, you can export the apache::balancermember resources on all +# balancer members, and then collect them on a single apache load balancer +# server. +# +# === Requirement/Dependencies: +# +# Currently requires the puppetlabs/concat module on the Puppet Forge and uses +# storeconfigs on the Puppet Master to export/collect resources from all +# balancer members. +# +# === Parameters +# +# [*name*] +# The namevar of the defined resource type is the balancer clusters name. +# This name is also used in the name of the conf.d file +# +# [*proxy_set*] +# Hash, default empty. If given, each key-value pair will be used as a ProxySet +# line in the configuration. +# +# [*collect_exported*] +# Boolean, default 'true'. True means 'collect exported @@balancermember +# resources' (for the case when every balancermember node exports itself), +# false means 'rely on the existing declared balancermember resources' (for the +# case when you know the full set of balancermembers in advance and use +# apache::balancermember with array arguments, which allows you to deploy +# everything in 1 run) +# +# +# === Examples +# +# Exporting the resource for a balancer member: +# +# apache::balancer { 'puppet00': } +# +define apache::balancer ( + $proxy_set = {}, + $collect_exported = true, +) { + include concat::setup + include ::apache::mod::proxy_balancer + + $target = "${::apache::params::confd_dir}/balancer_${name}.conf" + + concat { $target: + owner => '0', + group => '0', + mode => '0644', + notify => Service['httpd'], + } + + concat::fragment { "00-${name}-header": + ensure => present, + target => $target, + order => '01', + content => "\n", + } + + if $collect_exported { + Apache::Balancermember <<| balancer_cluster == $name |>> + } + # else: the resources have been created and they introduced their + # concat fragments. We don't have to do anything about them. + + concat::fragment { "01-${name}-proxyset": + ensure => present, + target => $target, + order => '19', + content => inline_template("<% proxy_set.keys.sort.each do |key| %> Proxyset <%= key %>=<%= proxy_set[key] %>\n<% end %>"), + } + + concat::fragment { "01-${name}-footer": + ensure => present, + target => $target, + order => '20', + content => "\n", + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/balancermember.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/balancermember.pp new file mode 100644 index 0000000000..121e2c5533 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/balancermember.pp @@ -0,0 +1,53 @@ +# == Define Resource Type: apache::balancermember +# +# This type will setup a balancer member inside a listening service +# configuration block in /etc/apache/apache.cfg on the load balancer. +# currently it only has the ability to specify the instance name, url and an +# array of options. More features can be added as needed. The best way to +# implement this is to export this resource for all apache balancer member +# servers, and then collect them on the main apache load balancer. +# +# === Requirement/Dependencies: +# +# Currently requires the puppetlabs/concat module on the Puppet Forge and +# uses storeconfigs on the Puppet Master to export/collect resources +# from all balancer members. +# +# === Parameters +# +# [*name*] +# The title of the resource is arbitrary and only utilized in the concat +# fragment name. +# +# [*balancer_cluster*] +# The apache service's instance name (or, the title of the apache::balancer +# resource). This must match up with a declared apache::balancer resource. +# +# [*url*] +# The url used to contact the balancer member server. +# +# [*options*] +# An array of options to be specified after the url. +# +# === Examples +# +# Exporting the resource for a balancer member: +# +# @@apache::balancermember { 'apache': +# balancer_cluster => 'puppet00', +# url => "ajp://${::fqdn}:8009" +# options => ['ping=5', 'disablereuse=on', 'retry=5', 'ttl=120'], +# } +# +define apache::balancermember( + $balancer_cluster, + $url = "http://${::fqdn}/", + $options = [], +) { + + concat::fragment { "BalancerMember ${url}": + ensure => present, + target => "${::apache::params::confd_dir}/balancer_${balancer_cluster}.conf", + content => inline_template(" BalancerMember ${url} <%= @options.join ' ' %>\n"), + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/confd/no_accf.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/confd/no_accf.pp new file mode 100644 index 0000000000..f35c0c8b9d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/confd/no_accf.pp @@ -0,0 +1,10 @@ +class apache::confd::no_accf { + # Template uses no variables + file { 'no-accf.conf': + ensure => 'file', + path => "${::apache::confd_dir}/no-accf.conf", + content => template('apache/confd/no-accf.conf.erb'), + require => Exec["mkdir ${::apache::confd_dir}"], + before => File[$::apache::confd_dir], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/default_confd_files.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/default_confd_files.pp new file mode 100644 index 0000000000..c06b30c83b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/default_confd_files.pp @@ -0,0 +1,15 @@ +class apache::default_confd_files ( + $all = true, +) { + # The rest of the conf.d/* files only get loaded if we want them + if $all { + case $::osfamily { + 'freebsd': { + include ::apache::confd::no_accf + } + default: { + # do nothing + } + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/default_mods.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/default_mods.pp new file mode 100644 index 0000000000..f665d7383e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/default_mods.pp @@ -0,0 +1,158 @@ +class apache::default_mods ( + $all = true, + $mods = undef, + $apache_version = $::apache::apache_version +) { + # These are modules required to run the default configuration. + # They are not configurable at this time, so we just include + # them to make sure it works. + case $::osfamily { + 'redhat', 'freebsd': { + ::apache::mod { 'log_config': } + if versioncmp($apache_version, '2.4') >= 0 { + # Lets fork it + ::apache::mod { 'systemd': } + ::apache::mod { 'unixd': } + } + } + default: {} + } + ::apache::mod { 'authz_host': } + + # The rest of the modules only get loaded if we want all modules enabled + if $all { + case $::osfamily { + 'debian': { + include ::apache::mod::reqtimeout + } + 'redhat': { + include ::apache::mod::actions + include ::apache::mod::cache + include ::apache::mod::mime + include ::apache::mod::mime_magic + include ::apache::mod::vhost_alias + include ::apache::mod::suexec + include ::apache::mod::rewrite + include ::apache::mod::speling + ::apache::mod { 'auth_digest': } + ::apache::mod { 'authn_anon': } + ::apache::mod { 'authn_dbm': } + ::apache::mod { 'authz_dbm': } + ::apache::mod { 'authz_owner': } + ::apache::mod { 'expires': } + ::apache::mod { 'ext_filter': } + ::apache::mod { 'include': } + ::apache::mod { 'logio': } + ::apache::mod { 'substitute': } + ::apache::mod { 'usertrack': } + ::apache::mod { 'version': } + + if versioncmp($apache_version, '2.4') >= 0 { + ::apache::mod { 'authn_core': } + } + else { + ::apache::mod { 'authn_alias': } + ::apache::mod { 'authn_default': } + } + } + 'freebsd': { + include ::apache::mod::actions + include ::apache::mod::cache + include ::apache::mod::disk_cache + include ::apache::mod::headers + include ::apache::mod::info + include ::apache::mod::mime_magic + include ::apache::mod::reqtimeout + include ::apache::mod::rewrite + include ::apache::mod::userdir + include ::apache::mod::vhost_alias + include ::apache::mod::speling + + ::apache::mod { 'asis': } + ::apache::mod { 'auth_digest': } + ::apache::mod { 'authn_alias': } + ::apache::mod { 'authn_anon': } + ::apache::mod { 'authn_dbm': } + ::apache::mod { 'authn_default': } + ::apache::mod { 'authz_dbm': } + ::apache::mod { 'authz_owner': } + ::apache::mod { 'cern_meta': } + ::apache::mod { 'charset_lite': } + ::apache::mod { 'dumpio': } + ::apache::mod { 'expires': } + ::apache::mod { 'file_cache': } + ::apache::mod { 'filter':} + ::apache::mod { 'imagemap':} + ::apache::mod { 'include': } + ::apache::mod { 'logio': } + ::apache::mod { 'unique_id': } + ::apache::mod { 'usertrack': } + ::apache::mod { 'version': } + } + default: {} + } + case $::apache::mpm_module { + 'prefork': { + include ::apache::mod::cgi + } + 'worker': { + include ::apache::mod::cgid + } + default: { + # do nothing + } + } + include ::apache::mod::alias + include ::apache::mod::autoindex + include ::apache::mod::dav + include ::apache::mod::dav_fs + include ::apache::mod::deflate + include ::apache::mod::dir + include ::apache::mod::mime + include ::apache::mod::negotiation + include ::apache::mod::setenvif + ::apache::mod { 'auth_basic': } + ::apache::mod { 'authn_file': } + + if versioncmp($apache_version, '2.4') >= 0 { + # authz_core is needed for 'Require' directive + ::apache::mod { 'authz_core': + id => 'authz_core_module', + } + + # filter is needed by mod_deflate + ::apache::mod { 'filter': } + + # lots of stuff seems to break without access_compat + ::apache::mod { 'access_compat': } + } else { + ::apache::mod { 'authz_default': } + } + + ::apache::mod { 'authz_groupfile': } + ::apache::mod { 'authz_user': } + ::apache::mod { 'env': } + } elsif $mods { + ::apache::default_mods::load { $mods: } + + if versioncmp($apache_version, '2.4') >= 0 { + # authz_core is needed for 'Require' directive + ::apache::mod { 'authz_core': + id => 'authz_core_module', + } + + # filter is needed by mod_deflate + ::apache::mod { 'filter': } + } + } else { + if versioncmp($apache_version, '2.4') >= 0 { + # authz_core is needed for 'Require' directive + ::apache::mod { 'authz_core': + id => 'authz_core_module', + } + + # filter is needed by mod_deflate + ::apache::mod { 'filter': } + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/default_mods/load.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/default_mods/load.pp new file mode 100644 index 0000000000..356e9fa00e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/default_mods/load.pp @@ -0,0 +1,8 @@ +# private define +define apache::default_mods::load ($module = $title) { + if defined("apache::mod::${module}") { + include "::apache::mod::${module}" + } else { + ::apache::mod { $module: } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/dev.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/dev.pp new file mode 100644 index 0000000000..4eaeb55782 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/dev.pp @@ -0,0 +1,11 @@ +class apache::dev { + if $::osfamily == 'FreeBSD' and !defined(Class['apache::package']) { + fail('apache::dev requires apache::package; please include apache or apache::package class first') + } + include ::apache::params + $packages = $::apache::params::dev_packages + package { $packages: + ensure => present, + require => Package['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/init.pp new file mode 100644 index 0000000000..9f77d5b4e7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/init.pp @@ -0,0 +1,340 @@ +# Class: apache +# +# This class installs Apache +# +# Parameters: +# +# Actions: +# - Install Apache +# - Manage Apache service +# +# Requires: +# +# Sample Usage: +# +class apache ( + $service_name = $::apache::params::service_name, + $default_mods = true, + $default_vhost = true, + $default_confd_files = true, + $default_ssl_vhost = false, + $default_ssl_cert = $::apache::params::default_ssl_cert, + $default_ssl_key = $::apache::params::default_ssl_key, + $default_ssl_chain = undef, + $default_ssl_ca = undef, + $default_ssl_crl_path = undef, + $default_ssl_crl = undef, + $ip = undef, + $service_enable = true, + $service_ensure = 'running', + $purge_configs = true, + $purge_vdir = false, + $serveradmin = 'root@localhost', + $sendfile = 'On', + $error_documents = false, + $timeout = '120', + $httpd_dir = $::apache::params::httpd_dir, + $server_root = $::apache::params::server_root, + $confd_dir = $::apache::params::confd_dir, + $vhost_dir = $::apache::params::vhost_dir, + $vhost_enable_dir = $::apache::params::vhost_enable_dir, + $mod_dir = $::apache::params::mod_dir, + $mod_enable_dir = $::apache::params::mod_enable_dir, + $mpm_module = $::apache::params::mpm_module, + $conf_template = $::apache::params::conf_template, + $servername = $::apache::params::servername, + $manage_user = true, + $manage_group = true, + $user = $::apache::params::user, + $group = $::apache::params::group, + $keepalive = $::apache::params::keepalive, + $keepalive_timeout = $::apache::params::keepalive_timeout, + $max_keepalive_requests = $apache::params::max_keepalive_requests, + $logroot = $::apache::params::logroot, + $log_level = $::apache::params::log_level, + $log_formats = {}, + $ports_file = $::apache::params::ports_file, + $apache_version = $::apache::version::default, + $server_tokens = 'OS', + $server_signature = 'On', + $trace_enable = 'On', + $package_ensure = 'installed', +) inherits ::apache::params { + validate_bool($default_vhost) + validate_bool($default_ssl_vhost) + validate_bool($default_confd_files) + # true/false is sufficient for both ensure and enable + validate_bool($service_enable) + + $valid_mpms_re = $apache_version ? { + '2.4' => '(event|itk|peruser|prefork|worker)', + default => '(event|itk|prefork|worker)' + } + + if $mpm_module { + validate_re($mpm_module, $valid_mpms_re) + } + + # NOTE: on FreeBSD it's mpm module's responsibility to install httpd package. + # NOTE: the same strategy may be introduced for other OSes. For this, you + # should delete the 'if' block below and modify all MPM modules' manifests + # such that they include apache::package class (currently event.pp, itk.pp, + # peruser.pp, prefork.pp, worker.pp). + if $::osfamily != 'FreeBSD' { + package { 'httpd': + ensure => $package_ensure, + name => $::apache::params::apache_name, + notify => Class['Apache::Service'], + } + } + validate_re($sendfile, [ '^[oO]n$' , '^[oO]ff$' ]) + + # declare the web server user and group + # Note: requiring the package means the package ought to create them and not puppet + validate_bool($manage_user) + if $manage_user { + user { $user: + ensure => present, + gid => $group, + require => Package['httpd'], + } + } + validate_bool($manage_group) + if $manage_group { + group { $group: + ensure => present, + require => Package['httpd'] + } + } + + $valid_log_level_re = '(emerg|alert|crit|error|warn|notice|info|debug)' + + validate_re($log_level, $valid_log_level_re, + "Log level '${log_level}' is not one of the supported Apache HTTP Server log levels.") + + class { '::apache::service': + service_name => $service_name, + service_enable => $service_enable, + service_ensure => $service_ensure, + } + + # Deprecated backwards-compatibility + if $purge_vdir { + warning('Class[\'apache\'] parameter purge_vdir is deprecated in favor of purge_configs') + $purge_confd = $purge_vdir + } else { + $purge_confd = $purge_configs + } + + Exec { + path => '/bin:/sbin:/usr/bin:/usr/sbin', + } + + exec { "mkdir ${confd_dir}": + creates => $confd_dir, + require => Package['httpd'], + } + file { $confd_dir: + ensure => directory, + recurse => true, + purge => $purge_confd, + notify => Class['Apache::Service'], + require => Package['httpd'], + } + + if ! defined(File[$mod_dir]) { + exec { "mkdir ${mod_dir}": + creates => $mod_dir, + require => Package['httpd'], + } + # Don't purge available modules if an enable dir is used + $purge_mod_dir = $purge_configs and !$mod_enable_dir + file { $mod_dir: + ensure => directory, + recurse => true, + purge => $purge_mod_dir, + notify => Class['Apache::Service'], + require => Package['httpd'], + } + } + + if $mod_enable_dir and ! defined(File[$mod_enable_dir]) { + $mod_load_dir = $mod_enable_dir + exec { "mkdir ${mod_enable_dir}": + creates => $mod_enable_dir, + require => Package['httpd'], + } + file { $mod_enable_dir: + ensure => directory, + recurse => true, + purge => $purge_configs, + notify => Class['Apache::Service'], + require => Package['httpd'], + } + } else { + $mod_load_dir = $mod_dir + } + + if ! defined(File[$vhost_dir]) { + exec { "mkdir ${vhost_dir}": + creates => $vhost_dir, + require => Package['httpd'], + } + file { $vhost_dir: + ensure => directory, + recurse => true, + purge => $purge_configs, + notify => Class['Apache::Service'], + require => Package['httpd'], + } + } + + if $vhost_enable_dir and ! defined(File[$vhost_enable_dir]) { + $vhost_load_dir = $vhost_enable_dir + exec { "mkdir ${vhost_load_dir}": + creates => $vhost_load_dir, + require => Package['httpd'], + } + file { $vhost_enable_dir: + ensure => directory, + recurse => true, + purge => $purge_configs, + notify => Class['Apache::Service'], + require => Package['httpd'], + } + } else { + $vhost_load_dir = $vhost_dir + } + + concat { $ports_file: + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + notify => Class['Apache::Service'], + require => Package['httpd'], + } + concat::fragment { 'Apache ports header': + ensure => present, + target => $ports_file, + content => template('apache/ports_header.erb') + } + + if $::apache::params::conf_dir and $::apache::params::conf_file { + case $::osfamily { + 'debian': { + $docroot = '/var/www' + $pidfile = '${APACHE_PID_FILE}' + $error_log = 'error.log' + $error_documents_path = '/usr/share/apache2/error' + $scriptalias = '/usr/lib/cgi-bin' + $access_log_file = 'access.log' + } + 'redhat': { + $docroot = '/var/www/html' + $pidfile = 'run/httpd.pid' + $error_log = 'error_log' + $error_documents_path = '/var/www/error' + $scriptalias = '/var/www/cgi-bin' + $access_log_file = 'access_log' + } + 'freebsd': { + $docroot = '/usr/local/www/apache22/data' + $pidfile = '/var/run/httpd.pid' + $error_log = 'httpd-error.log' + $error_documents_path = '/usr/local/www/apache22/error' + $scriptalias = '/usr/local/www/apache22/cgi-bin' + $access_log_file = 'httpd-access.log' + } + default: { + fail("Unsupported osfamily ${::osfamily}") + } + } + + $apxs_workaround = $::osfamily ? { + 'freebsd' => true, + default => false + } + + # Template uses: + # - $pidfile + # - $user + # - $group + # - $logroot + # - $error_log + # - $sendfile + # - $mod_dir + # - $ports_file + # - $confd_dir + # - $vhost_dir + # - $error_documents + # - $error_documents_path + # - $apxs_workaround + # - $keepalive + # - $keepalive_timeout + # - $max_keepalive_requests + # - $server_root + # - $server_tokens + # - $server_signature + # - $trace_enable + file { "${::apache::params::conf_dir}/${::apache::params::conf_file}": + ensure => file, + content => template($conf_template), + notify => Class['Apache::Service'], + require => Package['httpd'], + } + + # preserve back-wards compatibility to the times when default_mods was + # only a boolean value. Now it can be an array (too) + if is_array($default_mods) { + class { '::apache::default_mods': + all => false, + mods => $default_mods, + } + } else { + class { '::apache::default_mods': + all => $default_mods, + } + } + class { '::apache::default_confd_files': + all => $default_confd_files + } + if $mpm_module { + class { "::apache::mod::${mpm_module}": } + } + + $default_vhost_ensure = $default_vhost ? { + true => 'present', + false => 'absent' + } + $default_ssl_vhost_ensure = $default_ssl_vhost ? { + true => 'present', + false => 'absent' + } + + ::apache::vhost { 'default': + ensure => $default_vhost_ensure, + port => 80, + docroot => $docroot, + scriptalias => $scriptalias, + serveradmin => $serveradmin, + access_log_file => $access_log_file, + priority => '15', + ip => $ip, + } + $ssl_access_log_file = $::osfamily ? { + 'freebsd' => $access_log_file, + default => "ssl_${access_log_file}", + } + ::apache::vhost { 'default-ssl': + ensure => $default_ssl_vhost_ensure, + port => 443, + ssl => true, + docroot => $docroot, + scriptalias => $scriptalias, + serveradmin => $serveradmin, + access_log_file => $ssl_access_log_file, + priority => '15', + ip => $ip, + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/listen.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/listen.pp new file mode 100644 index 0000000000..e6a8a3c767 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/listen.pp @@ -0,0 +1,10 @@ +define apache::listen { + $listen_addr_port = $name + + # Template uses: $listen_addr_port + concat::fragment { "Listen ${listen_addr_port}": + ensure => present, + target => $::apache::ports_file, + content => template('apache/listen.erb'), + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod.pp new file mode 100644 index 0000000000..aa5ea3f3bd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod.pp @@ -0,0 +1,130 @@ +define apache::mod ( + $package = undef, + $package_ensure = 'present', + $lib = undef, + $lib_path = $::apache::params::lib_path, + $id = undef, + $path = undef, + $loadfile_name = undef, + $loadfiles = undef, +) { + if ! defined(Class['apache']) { + fail('You must include the apache base class before using any apache defined resources') + } + + $mod = $name + #include apache #This creates duplicate resources in rspec-puppet + $mod_dir = $::apache::mod_dir + + # Determine if we have special lib + $mod_libs = $::apache::params::mod_libs + $mod_lib = $mod_libs[$mod] # 2.6 compatibility hack + if $lib { + $_lib = $lib + } elsif $mod_lib { + $_lib = $mod_lib + } else { + $_lib = "mod_${mod}.so" + } + + # Determine if declaration specified a path to the module + if $path { + $_path = $path + } else { + $_path = "${lib_path}/${_lib}" + } + + if $id { + $_id = $id + } else { + $_id = "${mod}_module" + } + + if $loadfile_name { + $_loadfile_name = $loadfile_name + } else { + $_loadfile_name = "${mod}.load" + } + + # Determine if we have a package + $mod_packages = $::apache::params::mod_packages + $mod_package = $mod_packages[$mod] # 2.6 compatibility hack + if $package { + $_package = $package + } elsif $mod_package { + $_package = $mod_package + } else { + $_package = undef + } + if $_package and ! defined(Package[$_package]) { + # note: FreeBSD/ports uses apxs tool to activate modules; apxs clutters + # httpd.conf with 'LoadModule' directives; here, by proper resource + # ordering, we ensure that our version of httpd.conf is reverted after + # the module gets installed. + $package_before = $::osfamily ? { + 'freebsd' => [ + File[$_loadfile_name], + File["${::apache::params::conf_dir}/${::apache::params::conf_file}"] + ], + default => File[$_loadfile_name], + } + # $_package may be an array + package { $_package: + ensure => $package_ensure, + require => Package['httpd'], + before => $package_before, + } + } + + file { "${_loadfile_name}": + ensure => file, + path => "${mod_dir}/${_loadfile_name}", + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + content => template('apache/mod/load.erb'), + require => [ + Package['httpd'], + Exec["mkdir ${mod_dir}"], + ], + before => File[$mod_dir], + notify => Service['httpd'], + } + + if $::osfamily == 'Debian' { + $enable_dir = $::apache::mod_enable_dir + file{ "${_loadfile_name} symlink": + ensure => link, + path => "${enable_dir}/${_loadfile_name}", + target => "${mod_dir}/${_loadfile_name}", + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + require => [ + File[$_loadfile_name], + Exec["mkdir ${enable_dir}"], + ], + before => File[$enable_dir], + notify => Service['httpd'], + } + # Each module may have a .conf file as well, which should be + # defined in the class apache::mod::module + # Some modules do not require this file. + if defined(File["${mod}.conf"]) { + file{ "${mod}.conf symlink": + ensure => link, + path => "${enable_dir}/${mod}.conf", + target => "${mod_dir}/${mod}.conf", + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + require => [ + File["${mod}.conf"], + Exec["mkdir ${enable_dir}"], + ], + before => File[$enable_dir], + notify => Service['httpd'], + } + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/actions.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/actions.pp new file mode 100644 index 0000000000..3b60f297fd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/actions.pp @@ -0,0 +1,3 @@ +class apache::mod::actions { + apache::mod { 'actions': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/alias.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/alias.pp new file mode 100644 index 0000000000..ee017b490f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/alias.pp @@ -0,0 +1,19 @@ +class apache::mod::alias( + $apache_version = $apache::apache_version +) { + $icons_path = $::osfamily ? { + 'debian' => '/usr/share/apache2/icons', + 'redhat' => '/var/www/icons', + 'freebsd' => '/usr/local/www/apache22/icons', + } + apache::mod { 'alias': } + # Template uses $icons_path + file { 'alias.conf': + ensure => file, + path => "${::apache::mod_dir}/alias.conf", + content => template('apache/mod/alias.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/auth_basic.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/auth_basic.pp new file mode 100644 index 0000000000..cacfafa4d3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/auth_basic.pp @@ -0,0 +1,3 @@ +class apache::mod::auth_basic { + ::apache::mod { 'auth_basic': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/auth_kerb.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/auth_kerb.pp new file mode 100644 index 0000000000..6b53262a1b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/auth_kerb.pp @@ -0,0 +1,5 @@ +class apache::mod::auth_kerb { + ::apache::mod { 'auth_kerb': } +} + + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/authnz_ldap.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/authnz_ldap.pp new file mode 100644 index 0000000000..800e656e89 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/authnz_ldap.pp @@ -0,0 +1,19 @@ +class apache::mod::authnz_ldap ( + $verifyServerCert = true, +) { + include '::apache::mod::ldap' + ::apache::mod { 'authnz_ldap': } + + validate_bool($verifyServerCert) + + # Template uses: + # - $verifyServerCert + file { 'authnz_ldap.conf': + ensure => file, + path => "${::apache::mod_dir}/authnz_ldap.conf", + content => template('apache/mod/authnz_ldap.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/autoindex.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/autoindex.pp new file mode 100644 index 0000000000..f5f0f07458 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/autoindex.pp @@ -0,0 +1,12 @@ +class apache::mod::autoindex { + ::apache::mod { 'autoindex': } + # Template uses no variables + file { 'autoindex.conf': + ensure => file, + path => "${::apache::mod_dir}/autoindex.conf", + content => template('apache/mod/autoindex.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/cache.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/cache.pp new file mode 100644 index 0000000000..4ab9f44bae --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/cache.pp @@ -0,0 +1,3 @@ +class apache::mod::cache { + ::apache::mod { 'cache': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/cgi.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/cgi.pp new file mode 100644 index 0000000000..6c3c6aec8d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/cgi.pp @@ -0,0 +1,4 @@ +class apache::mod::cgi { + Class['::apache::mod::prefork'] -> Class['::apache::mod::cgi'] + ::apache::mod { 'cgi': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/cgid.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/cgid.pp new file mode 100644 index 0000000000..5c89251a1c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/cgid.pp @@ -0,0 +1,23 @@ +class apache::mod::cgid { + Class['::apache::mod::worker'] -> Class['::apache::mod::cgid'] + + # Debian specifies it's cgid sock path, but RedHat uses the default value + # with no config file + $cgisock_path = $::osfamily ? { + 'debian' => '${APACHE_RUN_DIR}/cgisock', + 'freebsd' => 'cgisock', + default => undef, + } + ::apache::mod { 'cgid': } + if $cgisock_path { + # Template uses $cgisock_path + file { 'cgid.conf': + ensure => file, + path => "${::apache::mod_dir}/cgid.conf", + content => template('apache/mod/cgid.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dav.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dav.pp new file mode 100644 index 0000000000..ade9c0809c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dav.pp @@ -0,0 +1,3 @@ +class apache::mod::dav { + ::apache::mod { 'dav': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dav_fs.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dav_fs.pp new file mode 100644 index 0000000000..482f316171 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dav_fs.pp @@ -0,0 +1,20 @@ +class apache::mod::dav_fs { + $dav_lock = $::osfamily ? { + 'debian' => '${APACHE_LOCK_DIR}/DAVLock', + 'freebsd' => '/usr/local/var/DavLock', + default => '/var/lib/dav/lockdb', + } + + Class['::apache::mod::dav'] -> Class['::apache::mod::dav_fs'] + ::apache::mod { 'dav_fs': } + + # Template uses: $dav_lock + file { 'dav_fs.conf': + ensure => file, + path => "${::apache::mod_dir}/dav_fs.conf", + content => template('apache/mod/dav_fs.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dav_svn.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dav_svn.pp new file mode 100644 index 0000000000..0fd667bc3f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dav_svn.pp @@ -0,0 +1,14 @@ +class apache::mod::dav_svn ( + $authz_svn_enabled = false, +) { + Class['::apache::mod::dav'] -> Class['::apache::mod::dav_svn'] + include ::apache::mod::dav + ::apache::mod { 'dav_svn': } + + if $authz_svn_enabled { + ::apache::mod { 'authz_svn': + loadfile_name => 'dav_svn_authz_svn.load', + require => Apache::Mod['dav_svn'], + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/deflate.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/deflate.pp new file mode 100644 index 0000000000..9b597d9466 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/deflate.pp @@ -0,0 +1,12 @@ +class apache::mod::deflate { + ::apache::mod { 'deflate': } + # Template uses no variables + file { 'deflate.conf': + ensure => file, + path => "${::apache::mod_dir}/deflate.conf", + content => template('apache/mod/deflate.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dev.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dev.pp new file mode 100644 index 0000000000..5abdedd361 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dev.pp @@ -0,0 +1,5 @@ +class apache::mod::dev { + # Development packages are not apache modules + warning('apache::mod::dev is deprecated; please use apache::dev') + include ::apache::dev +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dir.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dir.pp new file mode 100644 index 0000000000..11631305a4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/dir.pp @@ -0,0 +1,21 @@ +# Note: this sets the global DirectoryIndex directive, it may be necessary to consider being able to modify the apache::vhost to declare DirectoryIndex statements in a vhost configuration +# Parameters: +# - $indexes provides a string for the DirectoryIndex directive http://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex +class apache::mod::dir ( + $dir = 'public_html', + $indexes = ['index.html','index.html.var','index.cgi','index.pl','index.php','index.xhtml'], +) { + validate_array($indexes) + ::apache::mod { 'dir': } + + # Template uses + # - $indexes + file { 'dir.conf': + ensure => file, + path => "${::apache::mod_dir}/dir.conf", + content => template('apache/mod/dir.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/disk_cache.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/disk_cache.pp new file mode 100644 index 0000000000..13c9c78352 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/disk_cache.pp @@ -0,0 +1,24 @@ +class apache::mod::disk_cache { + $cache_root = $::osfamily ? { + 'debian' => '/var/cache/apache2/mod_disk_cache', + 'redhat' => '/var/cache/mod_proxy', + 'freebsd' => '/var/cache/mod_disk_cache', + } + if $::osfamily != 'FreeBSD' { + # FIXME: investigate why disk_cache was dependent on proxy + # NOTE: on FreeBSD disk_cache is compiled by default but proxy is not + Class['::apache::mod::proxy'] -> Class['::apache::mod::disk_cache'] + } + Class['::apache::mod::cache'] -> Class['::apache::mod::disk_cache'] + + apache::mod { 'disk_cache': } + # Template uses $cache_proxy + file { 'disk_cache.conf': + ensure => file, + path => "${::apache::mod_dir}/disk_cache.conf", + content => template('apache/mod/disk_cache.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/event.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/event.pp new file mode 100644 index 0000000000..cb7ed96cd6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/event.pp @@ -0,0 +1,62 @@ +class apache::mod::event ( + $startservers = '2', + $maxclients = '150', + $minsparethreads = '25', + $maxsparethreads = '75', + $threadsperchild = '25', + $maxrequestsperchild = '0', + $serverlimit = '25', + $apache_version = $::apache::apache_version, +) { + if defined(Class['apache::mod::itk']) { + fail('May not include both apache::mod::event and apache::mod::itk on the same node') + } + if defined(Class['apache::mod::peruser']) { + fail('May not include both apache::mod::event and apache::mod::peruser on the same node') + } + if defined(Class['apache::mod::prefork']) { + fail('May not include both apache::mod::event and apache::mod::prefork on the same node') + } + if defined(Class['apache::mod::worker']) { + fail('May not include both apache::mod::event and apache::mod::worker on the same node') + } + File { + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + } + + # Template uses: + # - $startservers + # - $maxclients + # - $minsparethreads + # - $maxsparethreads + # - $threadsperchild + # - $maxrequestsperchild + # - $serverlimit + file { "${::apache::mod_dir}/event.conf": + ensure => file, + content => template('apache/mod/event.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } + + case $::osfamily { + 'redhat': { + if versioncmp($apache_version, '2.4') >= 0 { + apache::mpm{ 'event': + apache_version => $apache_version, + } + } + } + 'debian','freebsd' : { + apache::mpm{ 'event': + apache_version => $apache_version, + } + } + default: { + fail("Unsupported osfamily ${::osfamily}") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/expires.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/expires.pp new file mode 100644 index 0000000000..aae4c59d98 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/expires.pp @@ -0,0 +1,3 @@ +class apache::mod::expires { + ::apache::mod { 'expires': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/fastcgi.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/fastcgi.pp new file mode 100644 index 0000000000..a185bb31fa --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/fastcgi.pp @@ -0,0 +1,24 @@ +class apache::mod::fastcgi { + + # Debian specifies it's fastcgi lib path, but RedHat uses the default value + # with no config file + $fastcgi_lib_path = $::apache::params::fastcgi_lib_path + + ::apache::mod { 'fastcgi': } + + if $fastcgi_lib_path { + # Template uses: + # - $fastcgi_server + # - $fastcgi_socket + # - $fastcgi_dir + file { 'fastcgi.conf': + ensure => file, + path => "${::apache::mod_dir}/fastcgi.conf", + content => template('apache/mod/fastcgi.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/fcgid.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/fcgid.pp new file mode 100644 index 0000000000..70997768bc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/fcgid.pp @@ -0,0 +1,16 @@ +class apache::mod::fcgid( + $options = {}, +) { + ::apache::mod { 'fcgid': } + + # Template uses: + # - $options + file { 'fcgid.conf': + ensure => file, + path => "${::apache::mod_dir}/fcgid.conf", + content => template('apache/mod/fcgid.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/headers.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/headers.pp new file mode 100644 index 0000000000..d18c5e2793 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/headers.pp @@ -0,0 +1,3 @@ +class apache::mod::headers { + ::apache::mod { 'headers': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/include.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/include.pp new file mode 100644 index 0000000000..edbe81f324 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/include.pp @@ -0,0 +1,3 @@ +class apache::mod::include { + ::apache::mod { 'include': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/info.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/info.pp new file mode 100644 index 0000000000..18f9ea1dfe --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/info.pp @@ -0,0 +1,17 @@ +class apache::mod::info ( + $allow_from = ['127.0.0.1','::1'], + $apache_version = $::apache::apache_version, +){ + apache::mod { 'info': } + # Template uses + # $allow_from + # $apache_version + file { 'info.conf': + ensure => file, + path => "${::apache::mod_dir}/info.conf", + content => template('apache/mod/info.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/itk.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/itk.pp new file mode 100644 index 0000000000..1083e5ed24 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/itk.pp @@ -0,0 +1,53 @@ +class apache::mod::itk ( + $startservers = '8', + $minspareservers = '5', + $maxspareservers = '20', + $serverlimit = '256', + $maxclients = '256', + $maxrequestsperchild = '4000', + $apache_version = $::apache::apache_version, +) { + if defined(Class['apache::mod::event']) { + fail('May not include both apache::mod::itk and apache::mod::event on the same node') + } + if defined(Class['apache::mod::peruser']) { + fail('May not include both apache::mod::itk and apache::mod::peruser on the same node') + } + if defined(Class['apache::mod::prefork']) { + fail('May not include both apache::mod::itk and apache::mod::prefork on the same node') + } + if defined(Class['apache::mod::worker']) { + fail('May not include both apache::mod::itk and apache::mod::worker on the same node') + } + File { + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + } + + # Template uses: + # - $startservers + # - $minspareservers + # - $maxspareservers + # - $serverlimit + # - $maxclients + # - $maxrequestsperchild + file { "${::apache::mod_dir}/itk.conf": + ensure => file, + content => template('apache/mod/itk.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } + + case $::osfamily { + 'debian', 'freebsd': { + apache::mpm{ 'itk': + apache_version => $apache_version, + } + } + default: { + fail("Unsupported osfamily ${::osfamily}") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/ldap.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/ldap.pp new file mode 100644 index 0000000000..d3b17ff5b8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/ldap.pp @@ -0,0 +1,14 @@ +class apache::mod::ldap ( + $apache_version = $::apache::apache_version, +){ + ::apache::mod { 'ldap': } + # Template uses $apache_version + file { 'ldap.conf': + ensure => file, + path => "${::apache::mod_dir}/ldap.conf", + content => template('apache/mod/ldap.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/mime.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/mime.pp new file mode 100644 index 0000000000..ccdb5d4b3c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/mime.pp @@ -0,0 +1,21 @@ +class apache::mod::mime ( + $mime_support_package = $::apache::params::mime_support_package, + $mime_types_config = $::apache::params::mime_types_config, +) { + apache::mod { 'mime': } + # Template uses $mime_types_config + file { 'mime.conf': + ensure => file, + path => "${::apache::mod_dir}/mime.conf", + content => template('apache/mod/mime.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } + if $mime_support_package { + package { $mime_support_package: + ensure => 'installed', + before => File['mime.conf'], + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/mime_magic.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/mime_magic.pp new file mode 100644 index 0000000000..9de8bc4bc6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/mime_magic.pp @@ -0,0 +1,14 @@ +class apache::mod::mime_magic ( + $magic_file = "${::apache::params::conf_dir}/magic" +) { + apache::mod { 'mime_magic': } + # Template uses $magic_file + file { 'mime_magic.conf': + ensure => file, + path => "${::apache::mod_dir}/mime_magic.conf", + content => template('apache/mod/mime_magic.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/negotiation.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/negotiation.pp new file mode 100644 index 0000000000..eff685b15c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/negotiation.pp @@ -0,0 +1,12 @@ +class apache::mod::negotiation { + ::apache::mod { 'negotiation': } + # Template uses no variables + file { 'negotiation.conf': + ensure => file, + path => "${::apache::mod_dir}/negotiation.conf", + content => template('apache/mod/negotiation.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/nss.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/nss.pp new file mode 100644 index 0000000000..f0eff1cdf7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/nss.pp @@ -0,0 +1,25 @@ +class apache::mod::nss ( + $transfer_log = "${::apache::params::logroot}/access.log", + $error_log = "${::apache::params::logroot}/error.log", + $passwd_file = undef +) { + include ::apache::mod::mime + + apache::mod { 'nss': } + + $httpd_dir = $::apache::httpd_dir + + # Template uses: + # $transfer_log + # $error_log + # $http_dir + # passwd_file + file { 'nss.conf': + ensure => file, + path => "${::apache::mod_dir}/nss.conf", + content => template('apache/mod/nss.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/pagespeed.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/pagespeed.pp new file mode 100644 index 0000000000..8c1c03bd5d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/pagespeed.pp @@ -0,0 +1,55 @@ +class apache::mod::pagespeed ( + $inherit_vhost_config = 'on', + $filter_xhtml = false, + $cache_path = '/var/cache/mod_pagespeed/', + $log_dir = '/var/log/pagespeed', + $memache_servers = [], + $rewrite_level = 'CoreFilters', + $disable_filters = [], + $enable_filters = [], + $forbid_filters = [], + $rewrite_deadline_per_flush_ms = 10, + $additional_domains = undef, + $file_cache_size_kb = 102400, + $file_cache_clean_interval_ms = 3600000, + $lru_cache_per_process = 1024, + $lru_cache_byte_limit = 16384, + $css_flatten_max_bytes = 2048, + $css_inline_max_bytes = 2048, + $css_image_inline_max_bytes = 2048, + $image_inline_max_bytes = 2048, + $js_inline_max_bytes = 2048, + $css_outline_min_bytes = 3000, + $js_outline_min_bytes = 3000, + $inode_limit = 500000, + $image_max_rewrites_at_once = 8, + $num_rewrite_threads = 4, + $num_expensive_rewrite_threads = 4, + $collect_statistics = 'on', + $statistics_logging = 'on', + $allow_view_stats = [], + $allow_pagespeed_console = [], + $allow_pagespeed_message = [], + $message_buffer_size = 100000, + $additional_configuration = {}, + $apache_version = $::apache::apache_version, +){ + + $_lib = $::apache::apache_version ? { + '2.4' => 'mod_pagespeed_ap24.so', + default => undef + } + + apache::mod { 'pagespeed': + lib => $_lib, + } + + file { 'pagespeed.conf': + ensure => file, + path => "${::apache::mod_dir}/pagespeed.conf", + content => template('apache/mod/pagespeed.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/passenger.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/passenger.pp new file mode 100644 index 0000000000..12139cb2b4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/passenger.pp @@ -0,0 +1,86 @@ +class apache::mod::passenger ( + $passenger_conf_file = $::apache::params::passenger_conf_file, + $passenger_conf_package_file = $::apache::params::passenger_conf_package_file, + $passenger_high_performance = undef, + $passenger_pool_idle_time = undef, + $passenger_max_requests = undef, + $passenger_stat_throttle_rate = undef, + $rack_autodetect = undef, + $rails_autodetect = undef, + $passenger_root = $::apache::params::passenger_root, + $passenger_ruby = $::apache::params::passenger_ruby, + $passenger_default_ruby = $::apache::params::passenger_default_ruby, + $passenger_max_pool_size = undef, + $passenger_use_global_queue = undef, + $mod_package = undef, + $mod_package_ensure = undef, + $mod_lib = undef, + $mod_lib_path = undef, + $mod_id = undef, + $mod_path = undef, +) { + # Managed by the package, but declare it to avoid purging + if $passenger_conf_package_file { + file { 'passenger_package.conf': + path => "${::apache::mod_dir}/${passenger_conf_package_file}", + } + } else { + # Remove passenger_extra.conf left over from before Passenger support was + # reworked for Debian. This is a temporary fix for users running this + # module from master after release 1.0.1 It will be removed in two + # releases from now. + $passenger_package_conf_ensure = $::osfamily ? { + 'Debian' => 'absent', + default => undef, + } + + file { 'passenger_package.conf': + ensure => $passenger_package_conf_ensure, + path => "${::apache::mod_dir}/passenger_extra.conf", + } + } + + $_package = $mod_package + $_package_ensure = $mod_package_ensure + $_lib = $mod_lib + if $::osfamily == 'FreeBSD' { + if $mod_lib_path { + $_lib_path = $mod_lib_path + } else { + $_lib_path = "${passenger_root}/buildout/apache2" + } + } else { + $_lib_path = $mod_lib_path + } + + $_id = $mod_id + $_path = $mod_path + ::apache::mod { 'passenger': + package => $_package, + package_ensure => $_package_ensure, + lib => $_lib, + lib_path => $_lib_path, + id => $_id, + path => $_path, + } + + # Template uses: + # - $passenger_root + # - $passenger_ruby + # - $passenger_default_ruby + # - $passenger_max_pool_size + # - $passenger_high_performance + # - $passenger_max_requests + # - $passenger_stat_throttle_rate + # - $passenger_use_global_queue + # - $rack_autodetect + # - $rails_autodetect + file { 'passenger.conf': + ensure => file, + path => "${::apache::mod_dir}/${passenger_conf_file}", + content => template('apache/mod/passenger.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/perl.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/perl.pp new file mode 100644 index 0000000000..b57f25fd5f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/perl.pp @@ -0,0 +1,3 @@ +class apache::mod::perl { + ::apache::mod { 'perl': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/peruser.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/peruser.pp new file mode 100644 index 0000000000..518655a1d4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/peruser.pp @@ -0,0 +1,73 @@ +class apache::mod::peruser ( + $minspareprocessors = '2', + $minprocessors = '2', + $maxprocessors = '10', + $maxclients = '150', + $maxrequestsperchild = '1000', + $idletimeout = '120', + $expiretimeout = '120', + $keepalive = 'Off', +) { + if defined(Class['apache::mod::event']) { + fail('May not include both apache::mod::peruser and apache::mod::event on the same node') + } + if defined(Class['apache::mod::itk']) { + fail('May not include both apache::mod::peruser and apache::mod::itk on the same node') + } + if defined(Class['apache::mod::prefork']) { + fail('May not include both apache::mod::peruser and apache::mod::prefork on the same node') + } + if defined(Class['apache::mod::worker']) { + fail('May not include both apache::mod::peruser and apache::mod::worker on the same node') + } + File { + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + } + + $mod_dir = $::apache::mod_dir + + # Template uses: + # - $minspareprocessors + # - $minprocessors + # - $maxprocessors + # - $maxclients + # - $maxrequestsperchild + # - $idletimeout + # - $expiretimeout + # - $keepalive + # - $mod_dir + file { "${::apache::mod_dir}/peruser.conf": + ensure => file, + content => template('apache/mod/peruser.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } + file { "${::apache::mod_dir}/peruser": + ensure => directory, + require => File[$::apache::mod_dir], + } + file { "${::apache::mod_dir}/peruser/multiplexers": + ensure => directory, + require => File["${::apache::mod_dir}/peruser"], + } + file { "${::apache::mod_dir}/peruser/processors": + ensure => directory, + require => File["${::apache::mod_dir}/peruser"], + } + + ::apache::peruser::multiplexer { '01-default': } + + case $::osfamily { + 'freebsd' : { + class { '::apache::package': + mpm_module => 'peruser' + } + } + default: { + fail("Unsupported osfamily ${::osfamily}") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/php.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/php.pp new file mode 100644 index 0000000000..a94bfe50bd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/php.pp @@ -0,0 +1,55 @@ +class apache::mod::php ( + $package_name = undef, + $package_ensure = 'present', + $path = undef, + $extensions = ['.php'], + $content = undef, + $template = 'apache/mod/php5.conf.erb', + $source = undef, +) { + if ! defined(Class['apache::mod::prefork']) { + fail('apache::mod::php requires apache::mod::prefork; please enable mpm_module => \'prefork\' on Class[\'apache\']') + } + validate_array($extensions) + + if $source and ($content or $template != 'apache/mod/php5.conf.erb') { + warning('source and content or template parameters are provided. source parameter will be used') + } elsif $content and $template != 'apache/mod/php5.conf.erb' { + warning('content and template parameters are provided. content parameter will be used') + } + + $manage_content = $source ? { + undef => $content ? { + undef => template($template), + default => $content, + }, + default => undef, + } + + ::apache::mod { 'php5': + package => $package_name, + package_ensure => $package_ensure, + path => $path, + } + + include ::apache::mod::mime + include ::apache::mod::dir + Class['::apache::mod::mime'] -> Class['::apache::mod::dir'] -> Class['::apache::mod::php'] + + # Template uses $extensions + file { 'php5.conf': + ensure => file, + path => "${::apache::mod_dir}/php5.conf", + owner => 'root', + group => 'root', + mode => '0644', + content => $manage_content, + source => $source, + require => [ + Class['::apache::mod::prefork'], + Exec["mkdir ${::apache::mod_dir}"], + ], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/prefork.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/prefork.pp new file mode 100644 index 0000000000..b3adeae8c8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/prefork.pp @@ -0,0 +1,70 @@ +class apache::mod::prefork ( + $startservers = '8', + $minspareservers = '5', + $maxspareservers = '20', + $serverlimit = '256', + $maxclients = '256', + $maxrequestsperchild = '4000', + $apache_version = $::apache::apache_version, +) { + if defined(Class['apache::mod::event']) { + fail('May not include both apache::mod::prefork and apache::mod::event on the same node') + } + if defined(Class['apache::mod::itk']) { + fail('May not include both apache::mod::prefork and apache::mod::itk on the same node') + } + if defined(Class['apache::mod::peruser']) { + fail('May not include both apache::mod::prefork and apache::mod::peruser on the same node') + } + if defined(Class['apache::mod::worker']) { + fail('May not include both apache::mod::prefork and apache::mod::worker on the same node') + } + File { + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + } + + # Template uses: + # - $startservers + # - $minspareservers + # - $maxspareservers + # - $serverlimit + # - $maxclients + # - $maxrequestsperchild + file { "${::apache::mod_dir}/prefork.conf": + ensure => file, + content => template('apache/mod/prefork.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } + + case $::osfamily { + 'redhat': { + if versioncmp($apache_version, '2.4') >= 0 { + ::apache::mpm{ 'prefork': + apache_version => $apache_version, + } + } + else { + file_line { '/etc/sysconfig/httpd prefork enable': + ensure => present, + path => '/etc/sysconfig/httpd', + line => '#HTTPD=/usr/sbin/httpd.worker', + match => '#?HTTPD=/usr/sbin/httpd.worker', + require => Package['httpd'], + notify => Service['httpd'], + } + } + } + 'debian', 'freebsd' : { + ::apache::mpm{ 'prefork': + apache_version => $apache_version, + } + } + default: { + fail("Unsupported osfamily ${::osfamily}") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy.pp new file mode 100644 index 0000000000..03c1e78c95 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy.pp @@ -0,0 +1,16 @@ +class apache::mod::proxy ( + $proxy_requests = 'Off', + $allow_from = undef, + $apache_version = $::apache::apache_version, +) { + ::apache::mod { 'proxy': } + # Template uses $proxy_requests, $apache_version + file { 'proxy.conf': + ensure => file, + path => "${::apache::mod_dir}/proxy.conf", + content => template('apache/mod/proxy.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_ajp.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_ajp.pp new file mode 100644 index 0000000000..a011a17895 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_ajp.pp @@ -0,0 +1,4 @@ +class apache::mod::proxy_ajp { + Class['::apache::mod::proxy'] -> Class['::apache::mod::proxy_ajp'] + ::apache::mod { 'proxy_ajp': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_balancer.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_balancer.pp new file mode 100644 index 0000000000..5a0768d8d0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_balancer.pp @@ -0,0 +1,10 @@ +class apache::mod::proxy_balancer { + + include ::apache::mod::proxy + include ::apache::mod::proxy_http + + Class['::apache::mod::proxy'] -> Class['::apache::mod::proxy_balancer'] + Class['::apache::mod::proxy_http'] -> Class['::apache::mod::proxy_balancer'] + ::apache::mod { 'proxy_balancer': } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_html.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_html.pp new file mode 100644 index 0000000000..549eb117fa --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_html.pp @@ -0,0 +1,37 @@ +class apache::mod::proxy_html { + Class['::apache::mod::proxy'] -> Class['::apache::mod::proxy_html'] + Class['::apache::mod::proxy_http'] -> Class['::apache::mod::proxy_html'] + + # Add libxml2 + case $::osfamily { + /RedHat|FreeBSD/: { + ::apache::mod { 'xml2enc': } + $loadfiles = undef + } + 'Debian': { + $gnu_path = $::hardwaremodel ? { + 'i686' => 'i386', + default => $::hardwaremodel, + } + $loadfiles = $::apache::params::distrelease ? { + '6' => ['/usr/lib/libxml2.so.2'], + '10' => ['/usr/lib/libxml2.so.2'], + default => ["/usr/lib/${gnu_path}-linux-gnu/libxml2.so.2"], + } + } + } + + ::apache::mod { 'proxy_html': + loadfiles => $loadfiles, + } + + # Template uses $icons_path + file { 'proxy_html.conf': + ensure => file, + path => "${::apache::mod_dir}/proxy_html.conf", + content => template('apache/mod/proxy_html.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_http.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_http.pp new file mode 100644 index 0000000000..1579e68ee2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/proxy_http.pp @@ -0,0 +1,4 @@ +class apache::mod::proxy_http { + Class['::apache::mod::proxy'] -> Class['::apache::mod::proxy_http'] + ::apache::mod { 'proxy_http': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/python.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/python.pp new file mode 100644 index 0000000000..e326c8d757 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/python.pp @@ -0,0 +1,5 @@ +class apache::mod::python { + ::apache::mod { 'python': } +} + + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/reqtimeout.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/reqtimeout.pp new file mode 100644 index 0000000000..80b3018306 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/reqtimeout.pp @@ -0,0 +1,12 @@ +class apache::mod::reqtimeout { + ::apache::mod { 'reqtimeout': } + # Template uses no variables + file { 'reqtimeout.conf': + ensure => file, + path => "${::apache::mod_dir}/reqtimeout.conf", + content => template('apache/mod/reqtimeout.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/rewrite.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/rewrite.pp new file mode 100644 index 0000000000..694f0b6f5c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/rewrite.pp @@ -0,0 +1,4 @@ +class apache::mod::rewrite { + include ::apache::params + ::apache::mod { 'rewrite': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/rpaf.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/rpaf.pp new file mode 100644 index 0000000000..6fbc1d4e04 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/rpaf.pp @@ -0,0 +1,20 @@ +class apache::mod::rpaf ( + $sethostname = true, + $proxy_ips = [ '127.0.0.1' ], + $header = 'X-Forwarded-For' +) { + ::apache::mod { 'rpaf': } + + # Template uses: + # - $sethostname + # - $proxy_ips + # - $header + file { 'rpaf.conf': + ensure => file, + path => "${::apache::mod_dir}/rpaf.conf", + content => template('apache/mod/rpaf.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/setenvif.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/setenvif.pp new file mode 100644 index 0000000000..15b1441d83 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/setenvif.pp @@ -0,0 +1,12 @@ +class apache::mod::setenvif { + ::apache::mod { 'setenvif': } + # Template uses no variables + file { 'setenvif.conf': + ensure => file, + path => "${::apache::mod_dir}/setenvif.conf", + content => template('apache/mod/setenvif.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/speling.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/speling.pp new file mode 100644 index 0000000000..eb46d78f04 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/speling.pp @@ -0,0 +1,3 @@ +class apache::mod::speling { + ::apache::mod { 'speling': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/ssl.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/ssl.pp new file mode 100644 index 0000000000..dd178150c9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/ssl.pp @@ -0,0 +1,56 @@ +class apache::mod::ssl ( + $ssl_compression = false, + $ssl_options = [ 'StdEnvVars' ], + $ssl_cipher = 'HIGH:MEDIUM:!aNULL:!MD5', + $apache_version = $::apache::apache_version, +) { + $session_cache = $::osfamily ? { + 'debian' => '${APACHE_RUN_DIR}/ssl_scache(512000)', + 'redhat' => '/var/cache/mod_ssl/scache(512000)', + 'freebsd' => '/var/run/ssl_scache(512000)', + } + + case $::osfamily { + 'debian': { + if versioncmp($apache_version, '2.4') >= 0 and $::operatingsystem == 'Ubuntu' { + $ssl_mutex = 'default' + } elsif $::operatingsystem == 'Ubuntu' and $::operatingsystemrelease == '10.04' { + $ssl_mutex = 'file:/var/run/apache2/ssl_mutex' + } else { + $ssl_mutex = 'file:${APACHE_RUN_DIR}/ssl_mutex' + } + } + 'redhat': { + $ssl_mutex = 'default' + } + 'freebsd': { + $ssl_mutex = 'default' + } + default: { + fail("Unsupported osfamily ${::osfamily}") + } + } + + ::apache::mod { 'ssl': } + + if versioncmp($apache_version, '2.4') >= 0 { + ::apache::mod { 'socache_shmcb': } + } + + # Template uses + # + # $ssl_compression + # $ssl_options + # $session_cache, + # $ssl_mutex + # $apache_version + # + file { 'ssl.conf': + ensure => file, + path => "${::apache::mod_dir}/ssl.conf", + content => template('apache/mod/ssl.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/status.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/status.pp new file mode 100644 index 0000000000..cfab5d58ea --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/status.pp @@ -0,0 +1,43 @@ +# Class: apache::mod::status +# +# This class enables and configures Apache mod_status +# See: http://httpd.apache.org/docs/current/mod/mod_status.html +# +# Parameters: +# - $allow_from is an array of hosts, ip addresses, partial network numbers +# or networks in CIDR notation specifying what hosts can view the special +# /server-status URL. Defaults to ['127.0.0.1', '::1']. +# - $extended_status track and display extended status information. Valid +# values are 'On' or 'Off'. Defaults to 'On'. +# +# Actions: +# - Enable and configure Apache mod_status +# +# Requires: +# - The apache class +# +# Sample Usage: +# +# # Simple usage allowing access from localhost and a private subnet +# class { 'apache::mod::status': +# $allow_from => ['127.0.0.1', '10.10.10.10/24'], +# } +# +class apache::mod::status ( + $allow_from = ['127.0.0.1','::1'], + $extended_status = 'On', + $apache_version = $::apache::apache_version, +){ + validate_array($allow_from) + validate_re(downcase($extended_status), '^(on|off)$', "${extended_status} is not supported for extended_status. Allowed values are 'On' and 'Off'.") + ::apache::mod { 'status': } + # Template uses $allow_from, $extended_status, $apache_version + file { 'status.conf': + ensure => file, + path => "${::apache::mod_dir}/status.conf", + content => template('apache/mod/status.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/suexec.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/suexec.pp new file mode 100644 index 0000000000..ded013d499 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/suexec.pp @@ -0,0 +1,3 @@ +class apache::mod::suexec { + ::apache::mod { 'suexec': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/suphp.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/suphp.pp new file mode 100644 index 0000000000..f9a572f463 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/suphp.pp @@ -0,0 +1,14 @@ +class apache::mod::suphp ( +){ + ::apache::mod { 'suphp': } + + file {'suphp.conf': + ensure => file, + path => "${::apache::mod_dir}/suphp.conf", + content => template('apache/mod/suphp.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'] + } +} + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/userdir.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/userdir.pp new file mode 100644 index 0000000000..accfe64a79 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/userdir.pp @@ -0,0 +1,18 @@ +class apache::mod::userdir ( + $home = '/home', + $dir = 'public_html', + $disable_root = true, + $apache_version = $::apache::apache_version, +) { + ::apache::mod { 'userdir': } + + # Template uses $home, $dir, $disable_root, $apache_version + file { 'userdir.conf': + ensure => file, + path => "${::apache::mod_dir}/userdir.conf", + content => template('apache/mod/userdir.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/vhost_alias.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/vhost_alias.pp new file mode 100644 index 0000000000..30ae122e15 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/vhost_alias.pp @@ -0,0 +1,3 @@ +class apache::mod::vhost_alias { + ::apache::mod { 'vhost_alias': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/worker.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/worker.pp new file mode 100644 index 0000000000..0d2815964b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/worker.pp @@ -0,0 +1,74 @@ +class apache::mod::worker ( + $startservers = '2', + $maxclients = '150', + $minsparethreads = '25', + $maxsparethreads = '75', + $threadsperchild = '25', + $maxrequestsperchild = '0', + $serverlimit = '25', + $threadlimit = '64', + $apache_version = $::apache::apache_version, +) { + if defined(Class['apache::mod::event']) { + fail('May not include both apache::mod::worker and apache::mod::event on the same node') + } + if defined(Class['apache::mod::itk']) { + fail('May not include both apache::mod::worker and apache::mod::itk on the same node') + } + if defined(Class['apache::mod::peruser']) { + fail('May not include both apache::mod::worker and apache::mod::peruser on the same node') + } + if defined(Class['apache::mod::prefork']) { + fail('May not include both apache::mod::worker and apache::mod::prefork on the same node') + } + File { + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + } + + # Template uses: + # - $startservers + # - $maxclients + # - $minsparethreads + # - $maxsparethreads + # - $threadsperchild + # - $maxrequestsperchild + # - $serverlimit + # - $threadLimit + file { "${::apache::mod_dir}/worker.conf": + ensure => file, + content => template('apache/mod/worker.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'], + } + + case $::osfamily { + 'redhat': { + if versioncmp($apache_version, '2.4') >= 0 { + ::apache::mpm{ 'worker': + apache_version => $apache_version, + } + } + else { + file_line { '/etc/sysconfig/httpd worker enable': + ensure => present, + path => '/etc/sysconfig/httpd', + line => 'HTTPD=/usr/sbin/httpd.worker', + match => '#?HTTPD=/usr/sbin/httpd.worker', + require => Package['httpd'], + notify => Service['httpd'], + } + } + } + 'debian', 'freebsd': { + ::apache::mpm{ 'worker': + apache_version => $apache_version, + } + } + default: { + fail("Unsupported osfamily ${::osfamily}") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/wsgi.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/wsgi.pp new file mode 100644 index 0000000000..244a3458b4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/wsgi.pp @@ -0,0 +1,21 @@ +class apache::mod::wsgi ( + $wsgi_socket_prefix = undef, + $wsgi_python_path = undef, + $wsgi_python_home = undef, +){ + ::apache::mod { 'wsgi': } + + # Template uses: + # - $wsgi_socket_prefix + # - $wsgi_python_path + # - $wsgi_python_home + file {'wsgi.conf': + ensure => file, + path => "${::apache::mod_dir}/wsgi.conf", + content => template('apache/mod/wsgi.conf.erb'), + require => Exec["mkdir ${::apache::mod_dir}"], + before => File[$::apache::mod_dir], + notify => Service['httpd'] + } +} + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/xsendfile.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/xsendfile.pp new file mode 100644 index 0000000000..7c5e88437a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mod/xsendfile.pp @@ -0,0 +1,4 @@ +class apache::mod::xsendfile { + include ::apache::params + ::apache::mod { 'xsendfile': } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mpm.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mpm.pp new file mode 100644 index 0000000000..6437016ba7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/mpm.pp @@ -0,0 +1,68 @@ +define apache::mpm ( + $lib_path = $::apache::params::lib_path, + $apache_version = $::apache::apache_version, +) { + if ! defined(Class['apache']) { + fail('You must include the apache base class before using any apache defined resources') + } + + $mpm = $name + $mod_dir = $::apache::mod_dir + + $_lib = "mod_mpm_${mpm}.so" + $_path = "${lib_path}/${_lib}" + $_id = "mpm_${mpm}_module" + + if versioncmp($apache_version, '2.4') >= 0 { + file { "${mod_dir}/${mpm}.load": + ensure => file, + path => "${mod_dir}/${mpm}.load", + content => "LoadModule ${_id} ${_path}\n", + require => [ + Package['httpd'], + Exec["mkdir ${mod_dir}"], + ], + before => File[$mod_dir], + notify => Service['httpd'], + } + } + + case $::osfamily { + 'debian': { + file { "${::apache::mod_enable_dir}/${mpm}.conf": + ensure => link, + target => "${::apache::mod_dir}/${mpm}.conf", + require => Exec["mkdir ${::apache::mod_enable_dir}"], + before => File[$::apache::mod_enable_dir], + notify => Service['httpd'], + } + + if versioncmp($apache_version, '2.4') >= 0 { + file { "${::apache::mod_enable_dir}/${mpm}.load": + ensure => link, + target => "${::apache::mod_dir}/${mpm}.load", + require => Exec["mkdir ${::apache::mod_enable_dir}"], + before => File[$::apache::mod_enable_dir], + notify => Service['httpd'], + } + } + + if versioncmp($apache_version, '2.4') < 0 { + package { "apache2-mpm-${mpm}": + ensure => present, + } + } + } + 'freebsd': { + class { '::apache::package': + mpm_module => $mpm + } + } + 'redhat': { + # so we don't fail + } + default: { + fail("Unsupported osfamily ${::osfamily}") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/namevirtualhost.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/namevirtualhost.pp new file mode 100644 index 0000000000..f8c3a80d85 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/namevirtualhost.pp @@ -0,0 +1,10 @@ +define apache::namevirtualhost { + $addr_port = $name + + # Template uses: $addr_port + concat::fragment { "NameVirtualHost ${addr_port}": + ensure => present, + target => $::apache::ports_file, + content => template('apache/namevirtualhost.erb'), + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/package.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/package.pp new file mode 100644 index 0000000000..a4e4015c52 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/package.pp @@ -0,0 +1,48 @@ +class apache::package ( + $ensure = 'present', + $mpm_module = $::apache::params::mpm_module, +) inherits ::apache::params { + case $::osfamily { + 'freebsd' : { + $all_mpms = [ + 'www/apache22', + 'www/apache22-worker-mpm', + 'www/apache22-event-mpm', + 'www/apache22-itk-mpm', + 'www/apache22-peruser-mpm', + ] + if $mpm_module { + $apache_package = $mpm_module ? { + 'prefork' => 'www/apache22', + default => "www/apache22-${mpm_module}-mpm" + } + } else { + $apache_package = 'www/apache22' + } + $other_mpms = delete($all_mpms, $apache_package) + # Configure ports to have apache module packages dependent on correct + # version of apache package (apache22, apache22-worker-mpm, ...) + file_line { 'APACHE_PORT in /etc/make.conf': + ensure => $ensure, + path => '/etc/make.conf', + line => "APACHE_PORT=${apache_package}", + match => '^\s*#?\s*APACHE_PORT\s*=\s*', + before => Package['httpd'], + } + # remove other packages + ensure_resource('package', $other_mpms, { + ensure => absent, + before => Package['httpd'], + require => File_line['APACHE_PORT in /etc/make.conf'], + }) + } + default: { + $apache_package = $::apache::params::apache_name + } + } + package { 'httpd': + ensure => $ensure, + name => $apache_package, + notify => Class['Apache::Service'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/params.pp new file mode 100644 index 0000000000..d272afb319 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/params.pp @@ -0,0 +1,258 @@ +# Class: apache::params +# +# This class manages Apache parameters +# +# Parameters: +# - The $user that Apache runs as +# - The $group that Apache runs as +# - The $apache_name is the name of the package and service on the relevant +# distribution +# - The $php_package is the name of the package that provided PHP +# - The $ssl_package is the name of the Apache SSL package +# - The $apache_dev is the name of the Apache development libraries package +# - The $conf_contents is the contents of the Apache configuration file +# +# Actions: +# +# Requires: +# +# Sample Usage: +# +class apache::params inherits ::apache::version { + if($::fqdn) { + $servername = $::fqdn + } else { + $servername = $::hostname + } + + # The default error log level + $log_level = 'warn' + + if $::osfamily == 'RedHat' or $::operatingsystem == 'amazon' { + $user = 'apache' + $group = 'apache' + $root_group = 'root' + $apache_name = 'httpd' + $service_name = 'httpd' + $httpd_dir = '/etc/httpd' + $server_root = '/etc/httpd' + $conf_dir = "${httpd_dir}/conf" + $confd_dir = "${httpd_dir}/conf.d" + $mod_dir = "${httpd_dir}/conf.d" + $mod_enable_dir = undef + $vhost_dir = "${httpd_dir}/conf.d" + $vhost_enable_dir = undef + $conf_file = 'httpd.conf' + $ports_file = "${conf_dir}/ports.conf" + $logroot = '/var/log/httpd' + $lib_path = 'modules' + $mpm_module = 'prefork' + $dev_packages = 'httpd-devel' + $default_ssl_cert = '/etc/pki/tls/certs/localhost.crt' + $default_ssl_key = '/etc/pki/tls/private/localhost.key' + $ssl_certs_dir = '/etc/pki/tls/certs' + $passenger_conf_file = 'passenger_extra.conf' + $passenger_conf_package_file = 'passenger.conf' + $passenger_root = undef + $passenger_ruby = undef + $passenger_default_ruby = undef + $suphp_addhandler = 'php5-script' + $suphp_engine = 'off' + $suphp_configpath = undef + $mod_packages = { + 'auth_kerb' => 'mod_auth_kerb', + 'authnz_ldap' => 'mod_authz_ldap', + 'fastcgi' => 'mod_fastcgi', + 'fcgid' => 'mod_fcgid', + 'pagespeed' => 'mod-pagespeed-stable', + 'passenger' => 'mod_passenger', + 'perl' => 'mod_perl', + 'php5' => $::apache::version::distrelease ? { + '5' => 'php53', + default => 'php', + }, + 'proxy_html' => 'mod_proxy_html', + 'python' => 'mod_python', + 'shibboleth' => 'shibboleth', + 'ssl' => 'mod_ssl', + 'wsgi' => 'mod_wsgi', + 'dav_svn' => 'mod_dav_svn', + 'suphp' => 'mod_suphp', + 'xsendfile' => 'mod_xsendfile', + 'nss' => 'mod_nss', + } + $mod_libs = { + 'php5' => 'libphp5.so', + 'nss' => 'libmodnss.so', + } + $conf_template = 'apache/httpd.conf.erb' + $keepalive = 'Off' + $keepalive_timeout = 15 + $max_keepalive_requests = 100 + $fastcgi_lib_path = undef + $mime_support_package = 'mailcap' + $mime_types_config = '/etc/mime.types' + } elsif $::osfamily == 'Debian' { + $user = 'www-data' + $group = 'www-data' + $root_group = 'root' + $apache_name = 'apache2' + $service_name = 'apache2' + $httpd_dir = '/etc/apache2' + $server_root = '/etc/apache2' + $conf_dir = $httpd_dir + $confd_dir = "${httpd_dir}/conf.d" + $mod_dir = "${httpd_dir}/mods-available" + $mod_enable_dir = "${httpd_dir}/mods-enabled" + $vhost_dir = "${httpd_dir}/sites-available" + $vhost_enable_dir = "${httpd_dir}/sites-enabled" + $conf_file = 'apache2.conf' + $ports_file = "${conf_dir}/ports.conf" + $logroot = '/var/log/apache2' + $lib_path = '/usr/lib/apache2/modules' + $mpm_module = 'worker' + $dev_packages = ['libaprutil1-dev', 'libapr1-dev', 'apache2-prefork-dev'] + $default_ssl_cert = '/etc/ssl/certs/ssl-cert-snakeoil.pem' + $default_ssl_key = '/etc/ssl/private/ssl-cert-snakeoil.key' + $ssl_certs_dir = '/etc/ssl/certs' + $suphp_addhandler = 'x-httpd-php' + $suphp_engine = 'off' + $suphp_configpath = '/etc/php5/apache2' + $mod_packages = { + 'auth_kerb' => 'libapache2-mod-auth-kerb', + 'dav_svn' => 'libapache2-svn', + 'fastcgi' => 'libapache2-mod-fastcgi', + 'fcgid' => 'libapache2-mod-fcgid', + 'nss' => 'libapache2-mod-nss', + 'pagespeed' => 'mod-pagespeed-stable', + 'passenger' => 'libapache2-mod-passenger', + 'perl' => 'libapache2-mod-perl2', + 'php5' => 'libapache2-mod-php5', + 'proxy_html' => 'libapache2-mod-proxy-html', + 'python' => 'libapache2-mod-python', + 'rpaf' => 'libapache2-mod-rpaf', + 'suphp' => 'libapache2-mod-suphp', + 'wsgi' => 'libapache2-mod-wsgi', + 'xsendfile' => 'libapache2-mod-xsendfile', + } + $mod_libs = { + 'php5' => 'libphp5.so', + } + $conf_template = 'apache/httpd.conf.erb' + $keepalive = 'Off' + $keepalive_timeout = 15 + $max_keepalive_requests = 100 + $fastcgi_lib_path = '/var/lib/apache2/fastcgi' + $mime_support_package = 'mime-support' + $mime_types_config = '/etc/mime.types' + + # + # Passenger-specific settings + # + + $passenger_conf_file = 'passenger.conf' + $passenger_conf_package_file = undef + + case $::operatingsystem { + 'Ubuntu': { + case $::lsbdistrelease { + '12.04': { + $passenger_root = '/usr' + $passenger_ruby = '/usr/bin/ruby' + $passenger_default_ruby = undef + } + '14.04': { + $passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini' + $passenger_ruby = undef + $passenger_default_ruby = '/usr/bin/ruby' + } + default: { + # The following settings may or may not work on Ubuntu releases not + # supported by this module. + $passenger_root = '/usr' + $passenger_ruby = '/usr/bin/ruby' + $passenger_default_ruby = undef + } + } + } + 'Debian': { + case $::lsbdistcodename { + 'wheezy': { + $passenger_root = '/usr' + $passenger_ruby = '/usr/bin/ruby' + $passenger_default_ruby = undef + } + default: { + # The following settings may or may not work on Debian releases not + # supported by this module. + $passenger_root = '/usr' + $passenger_ruby = '/usr/bin/ruby' + $passenger_default_ruby = undef + } + } + } + } + } elsif $::osfamily == 'FreeBSD' { + $user = 'www' + $group = 'www' + $root_group = 'wheel' + $apache_name = 'apache22' + $service_name = 'apache22' + $httpd_dir = '/usr/local/etc/apache22' + $server_root = '/usr/local' + $conf_dir = $httpd_dir + $confd_dir = "${httpd_dir}/Includes" + $mod_dir = "${httpd_dir}/Modules" + $mod_enable_dir = undef + $vhost_dir = "${httpd_dir}/Vhosts" + $vhost_enable_dir = undef + $conf_file = 'httpd.conf' + $ports_file = "${conf_dir}/ports.conf" + $logroot = '/var/log/apache22' + $lib_path = '/usr/local/libexec/apache22' + $mpm_module = 'prefork' + $dev_packages = undef + $default_ssl_cert = '/usr/local/etc/apache22/server.crt' + $default_ssl_key = '/usr/local/etc/apache22/server.key' + $ssl_certs_dir = '/usr/local/etc/apache22' + $passenger_conf_file = 'passenger.conf' + $passenger_conf_package_file = undef + $passenger_root = '/usr/local/lib/ruby/gems/1.9/gems/passenger-4.0.10' + $passenger_ruby = '/usr/bin/ruby' + $passenger_default_ruby = undef + $suphp_addhandler = 'php5-script' + $suphp_engine = 'off' + $suphp_configpath = undef + $mod_packages = { + # NOTE: I list here only modules that are not included in www/apache22 + # NOTE: 'passenger' needs to enable APACHE_SUPPORT in make config + # NOTE: 'php' needs to enable APACHE option in make config + # NOTE: 'dav_svn' needs to enable MOD_DAV_SVN make config + # NOTE: not sure where the shibboleth should come from + # NOTE: don't know where the shibboleth module should come from + 'auth_kerb' => 'www/mod_auth_kerb2', + 'fcgid' => 'www/mod_fcgid', + 'passenger' => 'www/rubygem-passenger', + 'perl' => 'www/mod_perl2', + 'php5' => 'lang/php5', + 'proxy_html' => 'www/mod_proxy_html', + 'python' => 'www/mod_python3', + 'wsgi' => 'www/mod_wsgi', + 'dav_svn' => 'devel/subversion', + 'xsendfile' => 'www/mod_xsendfile', + 'rpaf' => 'www/mod_rpaf2' + } + $mod_libs = { + 'php5' => 'libphp5.so', + } + $conf_template = 'apache/httpd.conf.erb' + $keepalive = 'Off' + $keepalive_timeout = 15 + $max_keepalive_requests = 100 + $fastcgi_lib_path = undef # TODO: revisit + $mime_support_package = 'misc/mime-support' + $mime_types_config = '/usr/local/etc/mime.types' + } else { + fail("Class['apache::params']: Unsupported osfamily: ${::osfamily}") + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/peruser/multiplexer.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/peruser/multiplexer.pp new file mode 100644 index 0000000000..9e57ac30b2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/peruser/multiplexer.pp @@ -0,0 +1,17 @@ +define apache::peruser::multiplexer ( + $user = $::apache::user, + $group = $::apache::group, + $file = undef, +) { + if ! $file { + $filename = "${name}.conf" + } else { + $filename = $file + } + file { "${::apache::mod_dir}/peruser/multiplexers/${filename}": + ensure => file, + content => "Multiplexer ${user} ${group}\n", + require => File["${::apache::mod_dir}/peruser/multiplexers"], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/peruser/processor.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/peruser/processor.pp new file mode 100644 index 0000000000..1d68934657 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/peruser/processor.pp @@ -0,0 +1,17 @@ +define apache::peruser::processor ( + $user, + $group, + $file = undef, +) { + if ! $file { + $filename = "${name}.conf" + } else { + $filename = $file + } + file { "${::apache::mod_dir}/peruser/processors/${filename}": + ensure => file, + content => "Processor ${user} ${group}\n", + require => File["${::apache::mod_dir}/peruser/processors"], + notify => Service['httpd'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/php.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/php.pp new file mode 100644 index 0000000000..9fa9c682e2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/php.pp @@ -0,0 +1,18 @@ +# Class: apache::php +# +# This class installs PHP for Apache +# +# Parameters: +# - $php_package +# +# Actions: +# - Install Apache PHP package +# +# Requires: +# +# Sample Usage: +# +class apache::php { + warning('apache::php is deprecated; please use apache::mod::php') + include ::apache::mod::php +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/proxy.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/proxy.pp new file mode 100644 index 0000000000..050f36c278 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/proxy.pp @@ -0,0 +1,15 @@ +# Class: apache::proxy +# +# This class enabled the proxy module for Apache +# +# Actions: +# - Enables Apache Proxy module +# +# Requires: +# +# Sample Usage: +# +class apache::proxy { + warning('apache::proxy is deprecated; please use apache::mod::proxy') + include ::apache::mod::proxy +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/python.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/python.pp new file mode 100644 index 0000000000..723a753f82 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/python.pp @@ -0,0 +1,18 @@ +# Class: apache::python +# +# This class installs Python for Apache +# +# Parameters: +# - $php_package +# +# Actions: +# - Install Apache Python package +# +# Requires: +# +# Sample Usage: +# +class apache::python { + warning('apache::python is deprecated; please use apache::mod::python') + include ::apache::mod::python +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/service.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/service.pp new file mode 100644 index 0000000000..0c1f7b96aa --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/service.pp @@ -0,0 +1,44 @@ +# Class: apache::service +# +# Manages the Apache daemon +# +# Parameters: +# +# Actions: +# - Manage Apache service +# +# Requires: +# +# Sample Usage: +# +# sometype { 'foo': +# notify => Class['apache::service'], +# } +# +# +class apache::service ( + $service_name = $::apache::params::service_name, + $service_enable = true, + $service_ensure = 'running', +) { + # The base class must be included first because parameter defaults depend on it + if ! defined(Class['apache::params']) { + fail('You must include the apache::params class before using any apache defined resources') + } + validate_bool($service_enable) + + case $service_ensure { + true, false, 'running', 'stopped': { + $_service_ensure = $service_ensure + } + default: { + $_service_ensure = undef + } + } + + service { 'httpd': + ensure => $_service_ensure, + name => $service_name, + enable => $service_enable, + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/ssl.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/ssl.pp new file mode 100644 index 0000000000..d0b36593d6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/ssl.pp @@ -0,0 +1,18 @@ +# Class: apache::ssl +# +# This class installs Apache SSL capabilities +# +# Parameters: +# - The $ssl_package name from the apache::params class +# +# Actions: +# - Install Apache SSL capabilities +# +# Requires: +# +# Sample Usage: +# +class apache::ssl { + warning('apache::ssl is deprecated; please use apache::mod::ssl') + include ::apache::mod::ssl +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/version.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/version.pp new file mode 100644 index 0000000000..a8592d5e95 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/version.pp @@ -0,0 +1,35 @@ +# Class: apache::version +# +# Try to automatically detect the version by OS +# +class apache::version { + # This will be 5 or 6 on RedHat, 6 or wheezy on Debian, 12 or quantal on Ubuntu, 3 on Amazon, etc. + $osr_array = split($::operatingsystemrelease,'[\/\.]') + $distrelease = $osr_array[0] + if ! $distrelease { + fail("Class['apache::params']: Unparsable \$::operatingsystemrelease: ${::operatingsystemrelease}") + } + + case $::osfamily { + 'RedHat': { + if ($::operatingsystem == 'Fedora' and $distrelease >= 18) or ($::operatingsystem != 'Fedora' and $distrelease >= 7) { + $default = '2.4' + } else { + $default = '2.2' + } + } + 'Debian': { + if $::operatingsystem == 'Ubuntu' and $::operatingsystemrelease >= 13.10 { + $default = '2.4' + } else { + $default = '2.2' + } + } + 'FreeBSD': { + $default = '2.2' + } + default: { + fail("Class['apache::version']: Unsupported osfamily: ${::osfamily}") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/vhost.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/vhost.pp new file mode 100644 index 0000000000..40edad7e21 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/manifests/vhost.pp @@ -0,0 +1,560 @@ +# Definition: apache::vhost +# +# This class installs Apache Virtual Hosts +# +# Parameters: +# - The $port to configure the host on +# - The $docroot provides the DocumentRoot variable +# - The $virtual_docroot provides VirtualDocumentationRoot variable +# - The $serveradmin will specify an email address for Apache that it will +# display when it renders one of it's error pages +# - The $ssl option is set true or false to enable SSL for this Virtual Host +# - The $priority of the site +# - The $servername is the primary name of the virtual host +# - The $serveraliases of the site +# - The $ip to configure the host on, defaulting to * +# - The $options for the given vhost +# - The $override for the given vhost (list of AllowOverride arguments) +# - The $vhost_name for name based virtualhosting, defaulting to * +# - The $logroot specifies the location of the virtual hosts logfiles, default +# to /var/log// +# - The $log_level specifies the verbosity of the error log for this vhost. Not +# set by default for the vhost, instead the global server configuration default +# of 'warn' is used. +# - The $access_log specifies if *_access.log directives should be configured. +# - The $ensure specifies if vhost file is present or absent. +# - The $headers is a list of Header statement strings as per http://httpd.apache.org/docs/2.2/mod/mod_headers.html#header +# - The $request_headers is a list of RequestHeader statement strings as per http://httpd.apache.org/docs/2.2/mod/mod_headers.html#requestheader +# - $aliases is a list of Alias hashes for mod_alias as per http://httpd.apache.org/docs/current/mod/mod_alias.html +# each statement is a hash in the form of { alias => '/alias', path => '/real/path/to/directory' } +# - $directories is a lost of hashes for creating statements as per http://httpd.apache.org/docs/2.2/mod/core.html#directory +# each statement is a hash in the form of { path => '/path/to/directory', => } +# see README.md for list of supported directives. +# +# Actions: +# - Install Apache Virtual Hosts +# +# Requires: +# - The apache class +# +# Sample Usage: +# +# # Simple vhost definition: +# apache::vhost { 'site.name.fqdn': +# port => '80', +# docroot => '/path/to/docroot', +# } +# +# # Multiple Mod Rewrites: +# apache::vhost { 'site.name.fqdn': +# port => '80', +# docroot => '/path/to/docroot', +# rewrites => [ +# { +# comment => 'force www domain', +# rewrite_cond => ['%{HTTP_HOST} ^([a-z.]+)?example.com$ [NC]', '%{HTTP_HOST} !^www. [NC]'], +# rewrite_rule => ['.? http://www.%1example.com%{REQUEST_URI} [R=301,L]'] +# }, +# { +# comment => 'prevent image hotlinking', +# rewrite_cond => ['%{HTTP_REFERER} !^$', '%{HTTP_REFERER} !^http://(www.)?example.com/ [NC]'], +# rewrite_rule => ['.(gif|jpg|png)$ - [F]'] +# }, +# ] +# } +# +# # SSL vhost with non-SSL rewrite: +# apache::vhost { 'site.name.fqdn': +# port => '443', +# ssl => true, +# docroot => '/path/to/docroot', +# } +# apache::vhost { 'site.name.fqdn': +# port => '80', +# docroot => '/path/to/other_docroot', +# custom_fragment => template("${module_name}/my_fragment.erb"), +# } +# +define apache::vhost( + $docroot, + $virtual_docroot = false, + $port = undef, + $ip = undef, + $ip_based = false, + $add_listen = true, + $docroot_owner = 'root', + $docroot_group = $::apache::params::root_group, + $docroot_mode = undef, + $serveradmin = undef, + $ssl = false, + $ssl_cert = $::apache::default_ssl_cert, + $ssl_key = $::apache::default_ssl_key, + $ssl_chain = $::apache::default_ssl_chain, + $ssl_ca = $::apache::default_ssl_ca, + $ssl_crl_path = $::apache::default_ssl_crl_path, + $ssl_crl = $::apache::default_ssl_crl, + $ssl_certs_dir = $::apache::params::ssl_certs_dir, + $ssl_protocol = undef, + $ssl_cipher = undef, + $ssl_honorcipherorder = undef, + $ssl_verify_client = undef, + $ssl_verify_depth = undef, + $ssl_options = undef, + $ssl_proxyengine = false, + $priority = undef, + $default_vhost = false, + $servername = $name, + $serveraliases = [], + $options = ['Indexes','FollowSymLinks','MultiViews'], + $override = ['None'], + $directoryindex = '', + $vhost_name = '*', + $logroot = $::apache::logroot, + $log_level = undef, + $access_log = true, + $access_log_file = undef, + $access_log_pipe = undef, + $access_log_syslog = undef, + $access_log_format = undef, + $access_log_env_var = undef, + $aliases = undef, + $directories = undef, + $error_log = true, + $error_log_file = undef, + $error_log_pipe = undef, + $error_log_syslog = undef, + $error_documents = [], + $fallbackresource = undef, + $scriptalias = undef, + $scriptaliases = [], + $proxy_dest = undef, + $proxy_pass = undef, + $suphp_addhandler = $::apache::params::suphp_addhandler, + $suphp_engine = $::apache::params::suphp_engine, + $suphp_configpath = $::apache::params::suphp_configpath, + $php_admin_flags = [], + $php_admin_values = [], + $no_proxy_uris = [], + $proxy_preserve_host = false, + $redirect_source = '/', + $redirect_dest = undef, + $redirect_status = undef, + $redirectmatch_status = undef, + $redirectmatch_regexp = undef, + $rack_base_uris = undef, + $headers = undef, + $request_headers = undef, + $rewrites = undef, + $rewrite_base = undef, + $rewrite_rule = undef, + $rewrite_cond = undef, + $setenv = [], + $setenvif = [], + $block = [], + $ensure = 'present', + $wsgi_application_group = undef, + $wsgi_daemon_process = undef, + $wsgi_daemon_process_options = undef, + $wsgi_import_script = undef, + $wsgi_import_script_options = undef, + $wsgi_process_group = undef, + $wsgi_script_aliases = undef, + $wsgi_pass_authorization = undef, + $custom_fragment = undef, + $itk = undef, + $action = undef, + $fastcgi_server = undef, + $fastcgi_socket = undef, + $fastcgi_dir = undef, + $additional_includes = [], + $apache_version = $::apache::apache_version, + $suexec_user_group = undef, + ) { + # The base class must be included first because it is used by parameter defaults + if ! defined(Class['apache']) { + fail('You must include the apache base class before using any apache defined resources') + } + + $apache_name = $::apache::params::apache_name + + validate_re($ensure, '^(present|absent)$', + "${ensure} is not supported for ensure. + Allowed values are 'present' and 'absent'.") + validate_re($suphp_engine, '^(on|off)$', + "${suphp_engine} is not supported for suphp_engine. + Allowed values are 'on' and 'off'.") + validate_bool($ip_based) + validate_bool($access_log) + validate_bool($error_log) + validate_bool($ssl) + validate_bool($default_vhost) + validate_bool($ssl_proxyengine) + if $rewrites { + validate_array($rewrites) + validate_hash($rewrites[0]) + } + + if $suexec_user_group { + validate_re($suexec_user_group, '^\w+ \w+$', + "${suexec_user_group} is not supported for suexec_user_group. Must be 'user group'.") + } + + # Deprecated backwards-compatibility + if $rewrite_base { + warning('Apache::Vhost: parameter rewrite_base is deprecated in favor of rewrites') + } + if $rewrite_rule { + warning('Apache::Vhost: parameter rewrite_rule is deprecated in favor of rewrites') + } + if $rewrite_cond { + warning('Apache::Vhost parameter rewrite_cond is deprecated in favor of rewrites') + } + + if $wsgi_script_aliases { + validate_hash($wsgi_script_aliases) + } + if $wsgi_daemon_process_options { + validate_hash($wsgi_daemon_process_options) + } + if $wsgi_import_script_options { + validate_hash($wsgi_import_script_options) + } + if $itk { + validate_hash($itk) + } + + if $log_level { + validate_re($log_level, '^(emerg|alert|crit|error|warn|notice|info|debug)$', + "Log level '${log_level}' is not one of the supported Apache HTTP Server log levels.") + } + + if $access_log_file and $access_log_pipe { + fail("Apache::Vhost[${name}]: 'access_log_file' and 'access_log_pipe' cannot be defined at the same time") + } + + if $error_log_file and $error_log_pipe { + fail("Apache::Vhost[${name}]: 'error_log_file' and 'error_log_pipe' cannot be defined at the same time") + } + + if $fallbackresource { + validate_re($fallbackresource, '^/|disabled', 'Please make sure fallbackresource starts with a / (or is "disabled")') + } + + if $ssl and $ensure == 'present' { + include ::apache::mod::ssl + # Required for the AddType lines. + include ::apache::mod::mime + } + + if $virtual_docroot { + include ::apache::mod::vhost_alias + } + + if $wsgi_daemon_process { + include ::apache::mod::wsgi + } + + if $suexec_user_group { + include ::apache::mod::suexec + } + + # This ensures that the docroot exists + # But enables it to be specified across multiple vhost resources + if ! defined(File[$docroot]) { + file { $docroot: + ensure => directory, + owner => $docroot_owner, + group => $docroot_group, + mode => $docroot_mode, + require => Package['httpd'], + } + } + + # Same as above, but for logroot + if ! defined(File[$logroot]) { + file { $logroot: + ensure => directory, + require => Package['httpd'], + } + } + + + # Is apache::mod::passenger enabled (or apache::mod['passenger']) + $passenger_enabled = defined(Apache::Mod['passenger']) + + # Define log file names + if $access_log_file { + $access_log_destination = "${logroot}/${access_log_file}" + } elsif $access_log_pipe { + $access_log_destination = $access_log_pipe + } elsif $access_log_syslog { + $access_log_destination = $access_log_syslog + } else { + if $ssl { + $access_log_destination = "${logroot}/${name}_access_ssl.log" + } else { + $access_log_destination = "${logroot}/${name}_access.log" + } + } + + if $error_log_file { + $error_log_destination = "${logroot}/${error_log_file}" + } elsif $error_log_pipe { + $error_log_destination = $error_log_pipe + } elsif $error_log_syslog { + $error_log_destination = $error_log_syslog + } else { + if $ssl { + $error_log_destination = "${logroot}/${name}_error_ssl.log" + } else { + $error_log_destination = "${logroot}/${name}_error.log" + } + } + + # Set access log format + if $access_log_format { + $_access_log_format = "\"${access_log_format}\"" + } else { + $_access_log_format = 'combined' + } + + if $access_log_env_var { + $_access_log_env_var = "env=${access_log_env_var}" + } + + if $ip { + if $port { + $listen_addr_port = "${ip}:${port}" + $nvh_addr_port = "${ip}:${port}" + } else { + $listen_addr_port = undef + $nvh_addr_port = $ip + if ! $servername and ! $ip_based { + fail("Apache::Vhost[${name}]: must pass 'ip' and/or 'port' parameters for name-based vhosts") + } + } + } else { + if $port { + $listen_addr_port = $port + $nvh_addr_port = "${vhost_name}:${port}" + } else { + $listen_addr_port = undef + $nvh_addr_port = $name + if ! $servername { + fail("Apache::Vhost[${name}]: must pass 'ip' and/or 'port' parameters, and/or 'servername' parameter") + } + } + } + if $add_listen { + if $ip and defined(Apache::Listen[$port]) { + fail("Apache::Vhost[${name}]: Mixing IP and non-IP Listen directives is not possible; check the add_listen parameter of the apache::vhost define to disable this") + } + if ! defined(Apache::Listen[$listen_addr_port]) and $listen_addr_port and $ensure == 'present' { + ::apache::listen { $listen_addr_port: } + } + } + if ! $ip_based { + if ! defined(Apache::Namevirtualhost[$nvh_addr_port]) and $ensure == 'present' and (versioncmp($apache_version, '2.4') < 0) { + ::apache::namevirtualhost { $nvh_addr_port: } + } + } + + # Load mod_rewrite if needed and not yet loaded + if $rewrites or $rewrite_cond { + if ! defined(Class['apache::mod::rewrite']) { + include ::apache::mod::rewrite + } + } + + # Load mod_alias if needed and not yet loaded + if ($scriptalias or $scriptaliases != []) or ($redirect_source and $redirect_dest) { + if ! defined(Class['apache::mod::alias']) { + include ::apache::mod::alias + } + } + + # Load mod_proxy if needed and not yet loaded + if ($proxy_dest or $proxy_pass) { + if ! defined(Class['apache::mod::proxy']) { + include ::apache::mod::proxy + } + if ! defined(Class['apache::mod::proxy_http']) { + include ::apache::mod::proxy_http + } + } + + # Load mod_passenger if needed and not yet loaded + if $rack_base_uris { + if ! defined(Class['apache::mod::passenger']) { + include ::apache::mod::passenger + } + } + + # Load mod_fastci if needed and not yet loaded + if $fastcgi_server and $fastcgi_socket { + if ! defined(Class['apache::mod::fastcgi']) { + include ::apache::mod::fastcgi + } + } + + # Configure the defaultness of a vhost + if $priority { + $priority_real = $priority + } elsif $default_vhost { + $priority_real = '10' + } else { + $priority_real = '25' + } + + # Check if mod_headers is required to process $headers/$request_headers + if $headers or $request_headers { + if ! defined(Class['apache::mod::headers']) { + include ::apache::mod::headers + } + } + + ## Apache include does not always work with spaces in the filename + $filename = regsubst($name, ' ', '_', 'G') + + ## Create a default directory list if none defined + if $directories { + if !is_hash($directories) and !(is_array($directories) and is_hash($directories[0])) { + fail("Apache::Vhost[${name}]: 'directories' must be either a Hash or an Array of Hashes") + } + $_directories = $directories + } else { + $_directory = { + provider => 'directory', + path => $docroot, + options => $options, + allow_override => $override, + directoryindex => $directoryindex, + } + + if versioncmp($apache_version, '2.4') >= 0 { + $_directory_version = { + require => 'all granted', + } + } else { + $_directory_version = { + order => 'allow,deny', + allow => 'from all', + } + } + + $_directories = [ merge($_directory, $_directory_version) ] + } + + # Template uses: + # - $nvh_addr_port + # - $servername + # - $serveradmin + # - $docroot + # - $virtual_docroot + # - $options + # - $override + # - $logroot + # - $name + # - $aliases + # - $_directories + # - $log_level + # - $access_log + # - $access_log_destination + # - $_access_log_format + # - $_access_log_env_var + # - $error_log + # - $error_log_destination + # - $error_documents + # - $fallbackresource + # - $custom_fragment + # - $additional_includes + # block fragment: + # - $block + # directories fragment: + # - $passenger_enabled + # - $php_admin_flags + # - $php_admin_values + # - $directories (a list of key-value hashes is expected) + # fastcgi fragment: + # - $fastcgi_server + # - $fastcgi_socket + # - $fastcgi_dir + # proxy fragment: + # - $proxy_dest + # - $no_proxy_uris + # - $proxy_preserve_host (true to set ProxyPreserveHost to on and false to off + # rack fragment: + # - $rack_base_uris + # redirect fragment: + # - $redirect_source + # - $redirect_dest + # - $redirect_status + # header fragment + # - $headers + # requestheader fragment: + # - $request_headers + # rewrite fragment: + # - $rewrites + # scriptalias fragment: + # - $scriptalias + # - $scriptaliases + # - $ssl + # serveralias fragment: + # - $serveraliases + # setenv fragment: + # - $setenv + # - $setenvif + # ssl fragment: + # - $ssl + # - $ssl_cert + # - $ssl_key + # - $ssl_chain + # - $ssl_certs_dir + # - $ssl_ca + # - $ssl_crl + # - $ssl_crl_path + # - $ssl_verify_client + # - $ssl_verify_depth + # - $ssl_options + # suphp fragment: + # - $suphp_addhandler + # - $suphp_engine + # - $suphp_configpath + # wsgi fragment: + # - $wsgi_application_group + # - $wsgi_daemon_process + # - $wsgi_import_script + # - $wsgi_process_group + # - $wsgi_script_aliases + file { "${priority_real}-${filename}.conf": + ensure => $ensure, + path => "${::apache::vhost_dir}/${priority_real}-${filename}.conf", + content => template('apache/vhost.conf.erb'), + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + require => [ + Package['httpd'], + File[$docroot], + File[$logroot], + ], + notify => Service['httpd'], + } + if $::osfamily == 'Debian' { + $vhost_enable_dir = $::apache::vhost_enable_dir + $vhost_symlink_ensure = $ensure ? { + present => link, + default => $ensure, + } + file{ "${priority_real}-${filename}.conf symlink": + ensure => $vhost_symlink_ensure, + path => "${vhost_enable_dir}/${priority_real}-${filename}.conf", + target => "${::apache::vhost_dir}/${priority_real}-${filename}.conf", + owner => 'root', + group => $::apache::params::root_group, + mode => '0644', + require => File["${priority_real}-${filename}.conf"], + notify => Service['httpd'], + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/metadata.json b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/metadata.json new file mode 100644 index 0000000000..92663a43c4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/metadata.json @@ -0,0 +1,65 @@ +{ + "name": "puppetlabs-apache", + "version": "1.0.1", + "source": "https://github.com/puppetlabs/puppetlabs-apache", + "author": "Puppet Labs", + "license": "Apache-2.0", + "project_page": "https://github.com/puppetlabs/puppetlabs-apache", + "summary": "Puppet module for Apache", + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "5", + "6", + "7" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "5", + "6", + "7" + + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "5", + "6", + "7" + + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "5", + "6", + "7" + + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04", + "14.04" + ] + } + ], + "requirements": [ + { "name": "puppet", "version_requirement": "3.x" } + ], + "dependencies": [] +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/apache_parameters_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/apache_parameters_spec.rb new file mode 100644 index 0000000000..4fa3bf6ec6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/apache_parameters_spec.rb @@ -0,0 +1,446 @@ +require 'spec_helper_acceptance' +require_relative './version.rb' + +describe 'apache parameters', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + + # Currently this test only does something on FreeBSD. + describe 'default_confd_files => false' do + it 'doesnt do anything' do + pp = "class { 'apache': default_confd_files => false }" + apply_manifest(pp, :catch_failures => true) + end + + if fact('osfamily') == 'FreeBSD' + describe file("#{confd_dir}/no-accf.conf.erb") do + it { should_not be_file } + end + end + end + describe 'default_confd_files => true' do + it 'copies conf.d files' do + pp = "class { 'apache': default_confd_files => true }" + apply_manifest(pp, :catch_failures => true) + end + + if fact('osfamily') == 'FreeBSD' + describe file("#{$confd_dir}/no-accf.conf.erb") do + it { should be_file } + end + end + end + + describe 'when set adds a listen statement' do + it 'applys cleanly' do + pp = "class { 'apache': ip => '10.1.1.1', service_ensure => stopped }" + apply_manifest(pp, :catch_failures => true) + end + + describe file($ports_file) do + it { should be_file } + it { should contain 'Listen 10.1.1.1' } + end + end + + describe 'service tests => true' do + it 'starts the service' do + pp = <<-EOS + class { 'apache': + service_enable => true, + service_ensure => running, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service($service_name) do + it { should be_running } + it { should be_enabled } + end + end + + describe 'service tests => false' do + it 'stops the service' do + pp = <<-EOS + class { 'apache': + service_enable => false, + service_ensure => stopped, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service($service_name) do + it { should_not be_running } + it { should_not be_enabled } + end + end + + describe 'purge parameters => false' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': + purge_configs => false, + purge_vdir => false, + } + EOS + shell("touch #{$confd_dir}/test.conf") + apply_manifest(pp, :catch_failures => true) + end + + # Ensure the file didn't disappear. + describe file("#{$confd_dir}/test.conf") do + it { should be_file } + end + end + + if fact('osfamily') != 'Debian' + describe 'purge parameters => true' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': + purge_configs => true, + purge_vdir => true, + } + EOS + shell("touch #{$confd_dir}/test.conf") + apply_manifest(pp, :catch_failures => true) + end + + # File should be gone + describe file("#{$confd_dir}/test.conf") do + it { should_not be_file } + end + end + end + + describe 'serveradmin' do + it 'applies cleanly' do + pp = "class { 'apache': serveradmin => 'test@example.com' }" + apply_manifest(pp, :catch_failures => true) + end + + describe file($vhost) do + it { should be_file } + it { should contain 'ServerAdmin test@example.com' } + end + end + + describe 'sendfile' do + describe 'setup' do + it 'applies cleanly' do + pp = "class { 'apache': sendfile => 'On' }" + apply_manifest(pp, :catch_failures => true) + end + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'EnableSendfile On' } + end + + describe 'setup' do + it 'applies cleanly' do + pp = "class { 'apache': sendfile => 'Off' }" + apply_manifest(pp, :catch_failures => true) + end + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'Sendfile Off' } + end + end + + describe 'error_documents' do + describe 'setup' do + it 'applies cleanly' do + pp = "class { 'apache': error_documents => true }" + apply_manifest(pp, :catch_failures => true) + end + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'Alias /error/' } + end + end + + describe 'timeout' do + describe 'setup' do + it 'applies cleanly' do + pp = "class { 'apache': timeout => '1234' }" + apply_manifest(pp, :catch_failures => true) + end + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'Timeout 1234' } + end + end + + describe 'httpd_dir' do + describe 'setup' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': httpd_dir => '/tmp', service_ensure => stopped } + include 'apache::mod::mime' + EOS + apply_manifest(pp, :catch_failures => true) + end + end + + describe file("#{$confd_dir}/mime.conf") do + it { should be_file } + it { should contain 'AddLanguage eo .eo' } + end + end + + describe 'server_root' do + describe 'setup' do + it 'applies cleanly' do + pp = "class { 'apache': server_root => '/tmp/root', service_ensure => stopped }" + apply_manifest(pp, :catch_failures => true) + end + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'ServerRoot "/tmp/root"' } + end + end + + describe 'confd_dir' do + describe 'setup' do + it 'applies cleanly' do + pp = "class { 'apache': confd_dir => '/tmp/root', service_ensure => stopped }" + apply_manifest(pp, :catch_failures => true) + end + end + + if $apache_version == '2.4' + describe file($conf_file) do + it { should be_file } + it { should contain 'IncludeOptional "/tmp/root/*.conf"' } + end + else + describe file($conf_file) do + it { should be_file } + it { should contain 'Include "/tmp/root/*.conf"' } + end + end + end + + describe 'conf_template' do + describe 'setup' do + it 'applies cleanly' do + pp = "class { 'apache': conf_template => 'another/test.conf.erb', service_ensure => stopped }" + shell("mkdir -p #{default['distmoduledir']}/another/templates") + shell("echo 'testcontent' >> #{default['distmoduledir']}/another/templates/test.conf.erb") + apply_manifest(pp, :catch_failures => true) + end + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'testcontent' } + end + end + + describe 'servername' do + describe 'setup' do + it 'applies cleanly' do + pp = "class { 'apache': servername => 'test.server', service_ensure => stopped }" + apply_manifest(pp, :catch_failures => true) + end + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'ServerName "test.server"' } + end + end + + describe 'user' do + describe 'setup' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': + manage_user => true, + manage_group => true, + user => 'testweb', + group => 'testweb', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + end + + describe user('testweb') do + it { should exist } + it { should belong_to_group 'testweb' } + end + + describe group('testweb') do + it { should exist } + end + end + + describe 'logformats' do + describe 'setup' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': + log_formats => { + 'vhost_common' => '%v %h %l %u %t \\\"%r\\\" %>s %b', + 'vhost_combined' => '%v %h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-agent}i\\\"', + } + } + EOS + apply_manifest(pp, :catch_failures => true) + end + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common' } + it { should contain 'LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" vhost_combined' } + end + end + + + describe 'keepalive' do + describe 'setup' do + it 'applies cleanly' do + pp = "class { 'apache': keepalive => 'On', keepalive_timeout => '30', max_keepalive_requests => '200' }" + apply_manifest(pp, :catch_failures => true) + end + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'KeepAlive On' } + it { should contain 'KeepAliveTimeout 30' } + it { should contain 'MaxKeepAliveRequests 200' } + end + end + + describe 'logging' do + describe 'setup' do + it 'applies cleanly' do + pp = <<-EOS + if $::osfamily == 'RedHat' and $::selinux == 'true' { + $semanage_package = $::operatingsystemmajrelease ? { + '5' => 'policycoreutils', + 'default' => 'policycoreutils-python', + } + + package { $semanage_package: ensure => installed } + exec { 'set_apache_defaults': + command => 'semanage fcontext -a -t httpd_log_t "/apache_spec(/.*)?"', + path => '/bin:/usr/bin/:/sbin:/usr/sbin', + require => Package[$semanage_package], + } + exec { 'restorecon_apache': + command => 'restorecon -Rv /apache_spec', + path => '/bin:/usr/bin/:/sbin:/usr/sbin', + before => Service['httpd'], + require => Class['apache'], + } + } + file { '/apache_spec': ensure => directory, } + class { 'apache': logroot => '/apache_spec' } + EOS + apply_manifest(pp, :catch_failures => true) + end + end + + describe file("/apache_spec/#{$error_log}") do + it { should be_file } + end + end + + describe 'ports_file' do + it 'applys cleanly' do + pp = <<-EOS + file { '/apache_spec': ensure => directory, } + class { 'apache': + ports_file => '/apache_spec/ports_file', + ip => '10.1.1.1', + service_ensure => stopped + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file('/apache_spec/ports_file') do + it { should be_file } + it { should contain 'Listen 10.1.1.1' } + end + end + + describe 'server_tokens' do + it 'applys cleanly' do + pp = <<-EOS + class { 'apache': + server_tokens => 'Minor', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'ServerTokens Minor' } + end + end + + describe 'server_signature' do + it 'applys cleanly' do + pp = <<-EOS + class { 'apache': + server_signature => 'testsig', + service_ensure => stopped, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'ServerSignature testsig' } + end + end + + describe 'trace_enable' do + it 'applys cleanly' do + pp = <<-EOS + class { 'apache': + trace_enable => 'Off', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file($conf_file) do + it { should be_file } + it { should contain 'TraceEnable Off' } + end + end + + describe 'package_ensure' do + it 'applys cleanly' do + pp = <<-EOS + class { 'apache': + package_ensure => present, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe package($package_name) do + it { should be_installed } + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/apache_ssl_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/apache_ssl_spec.rb new file mode 100644 index 0000000000..649c02d841 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/apache_ssl_spec.rb @@ -0,0 +1,87 @@ +require 'spec_helper_acceptance' + +case fact('osfamily') +when 'RedHat' + vhostd = '/etc/httpd/conf.d' +when 'Debian' + vhostd = '/etc/apache2/sites-available' +end + +describe 'apache ssl', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + + describe 'ssl parameters' do + it 'runs without error' do + pp = <<-EOS + class { 'apache': + service_ensure => stopped, + default_ssl_vhost => true, + default_ssl_cert => '/tmp/ssl_cert', + default_ssl_key => '/tmp/ssl_key', + default_ssl_chain => '/tmp/ssl_chain', + default_ssl_ca => '/tmp/ssl_ca', + default_ssl_crl_path => '/tmp/ssl_crl_path', + default_ssl_crl => '/tmp/ssl_crl', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{vhostd}/15-default-ssl.conf") do + it { should be_file } + it { should contain 'SSLCertificateFile "/tmp/ssl_cert"' } + it { should contain 'SSLCertificateKeyFile "/tmp/ssl_key"' } + it { should contain 'SSLCertificateChainFile "/tmp/ssl_chain"' } + it { should contain 'SSLCACertificateFile "/tmp/ssl_ca"' } + it { should contain 'SSLCARevocationPath "/tmp/ssl_crl_path"' } + it { should contain 'SSLCARevocationFile "/tmp/ssl_crl"' } + end + end + + describe 'vhost ssl parameters' do + it 'runs without error' do + pp = <<-EOS + class { 'apache': + service_ensure => stopped, + } + + apache::vhost { 'test_ssl': + docroot => '/tmp/test', + ssl => true, + ssl_cert => '/tmp/ssl_cert', + ssl_key => '/tmp/ssl_key', + ssl_chain => '/tmp/ssl_chain', + ssl_ca => '/tmp/ssl_ca', + ssl_crl_path => '/tmp/ssl_crl_path', + ssl_crl => '/tmp/ssl_crl', + ssl_certs_dir => '/tmp', + ssl_protocol => 'test', + ssl_cipher => 'test', + ssl_honorcipherorder => 'test', + ssl_verify_client => 'test', + ssl_verify_depth => 'test', + ssl_options => ['test', 'test1'], + ssl_proxyengine => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{vhostd}/25-test_ssl.conf") do + it { should be_file } + it { should contain 'SSLCertificateFile "/tmp/ssl_cert"' } + it { should contain 'SSLCertificateKeyFile "/tmp/ssl_key"' } + it { should contain 'SSLCertificateChainFile "/tmp/ssl_chain"' } + it { should contain 'SSLCACertificateFile "/tmp/ssl_ca"' } + it { should contain 'SSLCARevocationPath "/tmp/ssl_crl_path"' } + it { should contain 'SSLCARevocationFile "/tmp/ssl_crl"' } + it { should contain 'SSLProxyEngine On' } + it { should contain 'SSLProtocol test' } + it { should contain 'SSLCipherSuite test' } + it { should contain 'SSLHonorCipherOrder test' } + it { should contain 'SSLVerifyClient test' } + it { should contain 'SSLVerifyDepth test' } + it { should contain 'SSLOptions test test1' } + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/basic_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/basic_spec.rb new file mode 100644 index 0000000000..6c2b3f462f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/basic_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper_acceptance' + +describe 'disable selinux:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + it "because otherwise apache won't work" do + apply_manifest(%{ + exec { "setenforce 0": + path => "/bin:/sbin:/usr/bin:/usr/sbin", + onlyif => "which setenforce && getenforce | grep Enforcing", + } + }, :catch_failures => true) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/class_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/class_spec.rb new file mode 100644 index 0000000000..830e3ed5b6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/class_spec.rb @@ -0,0 +1,78 @@ +require 'spec_helper_acceptance' + +describe 'apache class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + case fact('osfamily') + when 'RedHat' + package_name = 'httpd' + service_name = 'httpd' + when 'Debian' + package_name = 'apache2' + service_name = 'apache2' + when 'FreeBSD' + package_name = 'apache22' + service_name = 'apache22' + end + + context 'default parameters' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apache': } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + + describe package(package_name) do + it { should be_installed } + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + end + + context 'custom site/mod dir parameters' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + if $::osfamily == 'RedHat' and $::selinux == 'true' { + $semanage_package = $::operatingsystemmajrelease ? { + '5' => 'policycoreutils', + 'default' => 'policycoreutils-python', + } + + package { $semanage_package: ensure => installed } + exec { 'set_apache_defaults': + command => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"', + path => '/bin:/usr/bin/:/sbin:/usr/sbin', + require => Package[$semanage_package], + } + exec { 'restorecon_apache': + command => 'restorecon -Rv /apache_spec', + path => '/bin:/usr/bin/:/sbin:/usr/sbin', + before => Service['httpd'], + require => Class['apache'], + } + } + file { '/apache_spec': ensure => directory, } + file { '/apache_spec/apache_custom': ensure => directory, } + class { 'apache': + mod_dir => '/apache_spec/apache_custom/mods', + vhost_dir => '/apache_spec/apache_custom/vhosts', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/default_mods_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/default_mods_spec.rb new file mode 100644 index 0000000000..c7f8755605 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/default_mods_spec.rb @@ -0,0 +1,120 @@ +require 'spec_helper_acceptance' + +case fact('osfamily') +when 'RedHat' + mod_dir = '/etc/httpd/conf.d' + servicename = 'httpd' +when 'Debian' + mod_dir = '/etc/apache2/mods-available' + servicename = 'apache2' +when 'FreeBSD' + mod_dir = '/usr/local/etc/apache22/Modules' + servicename = 'apache22' +end + +describe 'apache::default_mods class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + describe 'no default mods' do + # Using puppet_apply as a helper + it 'should apply with no errors' do + pp = <<-EOS + class { 'apache': + default_mods => false, + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + + describe service(servicename) do + it { should be_running } + end + end + + describe 'no default mods and failing' do + # Using puppet_apply as a helper + it 'should apply with errors' do + pp = <<-EOS + class { 'apache': + default_mods => false, + } + apache::vhost { 'defaults.example.com': + docroot => '/var/www/defaults', + aliases => { + alias => '/css', + path => '/var/www/css', + }, + setenv => 'TEST1 one', + } + EOS + + apply_manifest(pp, { :expect_failures => true }) + end + + # Are these the same? + describe service(servicename) do + it { should_not be_running } + end + describe "service #{servicename}" do + it 'should not be running' do + shell("pidof #{servicename}", {:acceptable_exit_codes => 1}) + end + end + end + + describe 'alternative default mods' do + # Using puppet_apply as a helper + it 'should apply with no errors' do + pp = <<-EOS + class { 'apache': + default_mods => [ + 'info', + 'alias', + 'mime', + 'env', + 'expires', + ], + } + apache::vhost { 'defaults.example.com': + docroot => '/var/www/defaults', + aliases => { + alias => '/css', + path => '/var/www/css', + }, + setenv => 'TEST1 one', + } + EOS + + apply_manifest(pp, :catch_failures => true) + shell('sleep 10') + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + + describe service(servicename) do + it { should be_running } + end + end + + describe 'change loadfile name' do + it 'should apply with no errors' do + pp = <<-EOS + class { 'apache': default_mods => false } + ::apache::mod { 'auth_basic': + loadfile_name => 'zz_auth_basic.load', + } + EOS + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + + describe service(servicename) do + it { should be_running } + end + + describe file("#{mod_dir}/zz_auth_basic.load") do + it { should be_file } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/itk_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/itk_spec.rb new file mode 100644 index 0000000000..86fc2c01ce --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/itk_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper_acceptance' + +case fact('osfamily') +when 'Debian' + service_name = 'apache2' +when 'FreeBSD' + service_name = 'apache22' +else + # Not implemented yet + service_name = :skip +end + +describe 'apache::mod::itk class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) or service_name.equal? :skip do + describe 'running puppet code' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + class { 'apache': + mpm_module => 'itk', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + end + + describe service(service_name) do + it { should be_running } + it { should be_enabled } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_dav_svn_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_dav_svn_spec.rb new file mode 100644 index 0000000000..412b794540 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_dav_svn_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper_acceptance' + +describe 'apache::mod::dav_svn class' do + case fact('osfamily') + when 'Debian' + mod_dir = '/etc/apache2/mods-available' + service_name = 'apache2' + when 'RedHat' + mod_dir = '/etc/httpd/conf.d' + service_name = 'httpd' + when 'FreeBSD' + mod_dir = '/usr/local/etc/apache22/Modules' + service_name = 'apache22' + end + + context "default dav_svn config" do + it 'succeeds in puppeting dav_svn' do + pp= <<-EOS + class { 'apache': } + include apache::mod::dav_svn + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + + describe file("#{mod_dir}/dav_svn.load") do + it { should contain "LoadModule dav_svn_module" } + end + end + + context "dav_svn with enabled authz_svn config" do + it 'succeeds in puppeting dav_svn' do + pp= <<-EOS + class { 'apache': } + class { 'apache::mod::dav_svn': + authz_svn_enabled => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + + describe file("#{mod_dir}/dav_svn_authz_svn.load") do + it { should contain "LoadModule authz_svn_module" } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_deflate_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_deflate_spec.rb new file mode 100644 index 0000000000..b2ffc1436a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_deflate_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper_acceptance' + +describe 'apache::mod::deflate class' do + case fact('osfamily') + when 'Debian' + mod_dir = '/etc/apache2/mods-available' + service_name = 'apache2' + when 'RedHat' + mod_dir = '/etc/httpd/conf.d' + service_name = 'httpd' + when 'FreeBSD' + mod_dir = '/usr/local/etc/apache22/Modules' + service_name = 'apache22' + end + + context "default deflate config" do + it 'succeeds in puppeting deflate' do + pp= <<-EOS + class { 'apache': } + include apache::mod::deflate + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + + describe file("#{mod_dir}/deflate.conf") do + it { should contain "AddOutputFilterByType DEFLATE text/html text/plain text/xml" } + it { should contain "AddOutputFilterByType DEFLATE text/css" } + it { should contain "AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript" } + it { should contain "AddOutputFilterByType DEFLATE application/rss+xml" } + it { should contain "DeflateFilterNote Input instream" } + it { should contain "DeflateFilterNote Output outstream" } + it { should contain "DeflateFilterNote Ratio ratio" } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_fcgid_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_fcgid_spec.rb new file mode 100644 index 0000000000..52f793be06 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_fcgid_spec.rb @@ -0,0 +1,62 @@ +require 'spec_helper_acceptance' + +describe 'apache::mod::fcgid class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + case fact('osfamily') + when 'Debian' + # Not implemented + when 'RedHat' + context "default fcgid config" do + it 'succeeds in puppeting fcgid' do + pp = <<-EOS + class { 'epel': } # mod_fcgid lives in epel + class { 'apache': } + class { 'apache::mod::php': } # For /usr/bin/php-cgi + class { 'apache::mod::fcgid': + options => { + 'FcgidIPCDir' => '/var/run/fcgidsock', + }, + } + apache::vhost { 'fcgid.example.com': + port => '80', + docroot => '/var/www/fcgid', + directories => { + path => '/var/www/fcgid', + options => '+ExecCGI', + addhandlers => { + handler => 'fcgid-script', + extensions => '.php', + }, + fcgiwrapper => { + command => '/usr/bin/php-cgi', + suffix => '.php', + } + }, + } + file { '/var/www/fcgid/index.php': + ensure => file, + owner => 'root', + group => 'root', + content => "\\n", + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service('httpd') do + it { should be_enabled } + it { should be_running } + end + + it 'should answer to fcgid.example.com' do + shell("/usr/bin/curl -H 'Host: fcgid.example.com' 127.0.0.1:80") do |r| + r.stdout.should =~ /^Hello world$/ + r.exit_code.should == 0 + end + end + + it 'should run a php-cgi process' do + shell("pgrep -u apache php-cgi", :acceptable_exit_codes => [0]) + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_mime_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_mime_spec.rb new file mode 100644 index 0000000000..71a7037a62 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_mime_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper_acceptance' + +describe 'apache::mod::mime class' do + case fact('osfamily') + when 'Debian' + mod_dir = '/etc/apache2/mods-available' + service_name = 'apache2' + when 'RedHat' + mod_dir = '/etc/httpd/conf.d' + service_name = 'httpd' + when 'FreeBSD' + mod_dir = '/usr/local/etc/apache22/Modules' + service_name = 'apache22' + end + + context "default mime config" do + it 'succeeds in puppeting mime' do + pp= <<-EOS + class { 'apache': } + include apache::mod::mime + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + + describe file("#{mod_dir}/mime.conf") do + it { should contain "AddType application/x-compress .Z" } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_pagespeed_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_pagespeed_spec.rb new file mode 100644 index 0000000000..de59a347c1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_pagespeed_spec.rb @@ -0,0 +1,85 @@ +require 'spec_helper_acceptance' + +describe 'apache::mod::pagespeed class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + case fact('osfamily') + when 'Debian' + vhost_dir = '/etc/apache2/sites-enabled' + mod_dir = '/etc/apache2/mods-available' + service_name = 'apache2' + when 'RedHat' + vhost_dir = '/etc/httpd/conf.d' + mod_dir = '/etc/httpd/conf.d' + service_name = 'httpd' + when 'FreeBSD' + vhost_dir = '/usr/local/etc/apache22/Vhosts' + mod_dir = '/usr/local/etc/apache22/Modules' + service_name = 'apache22' + end + + context "default pagespeed config" do + it 'succeeds in puppeting pagespeed' do + pp= <<-EOS + if $::osfamily == 'Debian' { + class { 'apt': } + + apt::source { 'mod-pagespeed': + key => '7FAC5991', + key_server => 'pgp.mit.edu', + location => 'http://dl.google.com/linux/mod-pagespeed/deb/', + release => 'stable', + repos => 'main', + include_src => false, + before => Class['apache'], + } + } elsif $::osfamily == 'RedHat' { + yumrepo { 'mod-pagespeed': + baseurl => 'http://dl.google.com/linux/mod-pagespeed/rpm/stable/x86_64', + enabled => 1, + gpgcheck => 1, + gpgkey => 'https://dl-ssl.google.com/linux/linux_signing_key.pub', + before => Class['apache'], + } + } + + class { 'apache': + mpm_module => 'prefork', + } + class { 'apache::mod::pagespeed': + enable_filters => ['remove_comments'], + disable_filters => ['extend_cache'], + forbid_filters => ['rewrite_javascript'], + } + apache::vhost { 'pagespeed.example.com': + port => '80', + docroot => '/var/www/pagespeed', + } + host { 'pagespeed.example.com': ip => '127.0.0.1', } + file { '/var/www/pagespeed/index.html': + ensure => file, + content => "\n\n\nHello World!\n\n", + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + + describe file("#{mod_dir}/pagespeed.conf") do + it { should contain "AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html" } + it { should contain "ModPagespeedEnableFilters remove_comments" } + it { should contain "ModPagespeedDisableFilters extend_cache" } + it { should contain "ModPagespeedForbidFilters rewrite_javascript" } + end + + it 'should answer to pagespeed.example.com and include and be stripped of comments by mod_pagespeed' do + shell("/usr/bin/curl pagespeed.example.com:80") do |r| + r.stdout.should =~ // + r.stdout.should_not =~ // + r.exit_code.should == 0 + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_passenger_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_passenger_spec.rb new file mode 100644 index 0000000000..fbfac1672a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_passenger_spec.rb @@ -0,0 +1,294 @@ +require 'spec_helper_acceptance' + +describe 'apache::mod::passenger class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + case fact('osfamily') + when 'Debian' + service_name = 'apache2' + mod_dir = '/etc/apache2/mods-available/' + conf_file = "#{mod_dir}passenger.conf" + load_file = "#{mod_dir}passenger.load" + + case fact('operatingsystem') + when 'Ubuntu' + case fact('lsbdistrelease') + when '10.04' + passenger_root = '/usr' + passenger_ruby = '/usr/bin/ruby' + when '12.04' + passenger_root = '/usr' + passenger_ruby = '/usr/bin/ruby' + when '14.04' + passenger_root = '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini' + passenger_ruby = '/usr/bin/ruby' + passenger_default_ruby = '/usr/bin/ruby' + else + # This may or may not work on Ubuntu releases other than the above + passenger_root = '/usr' + passenger_ruby = '/usr/bin/ruby' + end + when 'Debian' + case fact('lsbdistcodename') + when 'wheezy' + passenger_root = '/usr' + passenger_ruby = '/usr/bin/ruby' + else + # This may or may not work on Debian releases other than the above + passenger_root = '/usr' + passenger_ruby = '/usr/bin/ruby' + end + end + + passenger_module_path = '/usr/lib/apache2/modules/mod_passenger.so' + rackapp_user = 'www-data' + rackapp_group = 'www-data' + when 'RedHat' + service_name = 'httpd' + mod_dir = '/etc/httpd/conf.d/' + conf_file = "#{mod_dir}passenger.conf" + load_file = "#{mod_dir}passenger.load" + # sometimes installs as 3.0.12, sometimes as 3.0.19 - so just check for the stable part + passenger_root = '/usr/lib/ruby/gems/1.8/gems/passenger-3.0.1' + passenger_ruby = '/usr/bin/ruby' + passenger_tempdir = '/var/run/rubygem-passenger' + passenger_module_path = 'modules/mod_passenger.so' + rackapp_user = 'apache' + rackapp_group = 'apache' + end + + pp_rackapp = <<-EOS + /* a simple ruby rack 'hellow world' app */ + file { '/var/www/passenger': + ensure => directory, + owner => '#{rackapp_user}', + group => '#{rackapp_group}', + require => Class['apache::mod::passenger'], + } + file { '/var/www/passenger/config.ru': + ensure => file, + owner => '#{rackapp_user}', + group => '#{rackapp_group}', + content => "app = proc { |env| [200, { \\"Content-Type\\" => \\"text/html\\" }, [\\"hello world\\"]] }\\nrun app", + require => File['/var/www/passenger'] , + } + apache::vhost { 'passenger.example.com': + port => '80', + docroot => '/var/www/passenger/public', + docroot_group => '#{rackapp_group}' , + docroot_owner => '#{rackapp_user}' , + custom_fragment => "PassengerRuby #{passenger_ruby}\\nRailsEnv development" , + require => File['/var/www/passenger/config.ru'] , + } + host { 'passenger.example.com': ip => '127.0.0.1', } + EOS + + case fact('osfamily') + when 'Debian' + context "default passenger config" do + it 'succeeds in puppeting passenger' do + pp = <<-EOS + /* stock apache and mod_passenger */ + class { 'apache': } + class { 'apache::mod::passenger': } + #{pp_rackapp} + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + + describe file(conf_file) do + it { should contain "PassengerRoot \"#{passenger_root}\"" } + + case fact('operatingsystem') + when 'Ubuntu' + case fact('lsbdistrelease') + when '10.04' + it { should contain "PassengerRuby \"#{passenger_ruby}\"" } + it { should_not contain "/PassengerDefaultRuby/" } + when '12.04' + it { should contain "PassengerRuby \"#{passenger_ruby}\"" } + it { should_not contain "/PassengerDefaultRuby/" } + when '14.04' + it { should contain "PassengerDefaultRuby \"#{passenger_ruby}\"" } + it { should_not contain "/PassengerRuby/" } + else + # This may or may not work on Ubuntu releases other than the above + it { should contain "PassengerRuby \"#{passenger_ruby}\"" } + it { should_not contain "/PassengerDefaultRuby/" } + end + when 'Debian' + case fact('lsbdistcodename') + when 'wheezy' + it { should contain "PassengerRuby \"#{passenger_ruby}\"" } + it { should_not contain "/PassengerDefaultRuby/" } + else + # This may or may not work on Debian releases other than the above + it { should contain "PassengerRuby \"#{passenger_ruby}\"" } + it { should_not contain "/PassengerDefaultRuby/" } + end + end + end + + describe file(load_file) do + it { should contain "LoadModule passenger_module #{passenger_module_path}" } + end + + it 'should output status via passenger-memory-stats' do + shell("sudo /usr/sbin/passenger-memory-stats") do |r| + r.stdout.should =~ /Apache processes/ + r.stdout.should =~ /Nginx processes/ + r.stdout.should =~ /Passenger processes/ + + # passenger-memory-stats output on Ubuntu 14.04 does not contain + # these two lines + unless fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '14.04' + r.stdout.should =~ /### Processes: [0-9]+/ + r.stdout.should =~ /### Total private dirty RSS: [0-9\.]+ MB/ + end + + r.exit_code.should == 0 + end + end + + # passenger-status fails under stock ubuntu-server-12042-x64 + mod_passenger, + # even when the passenger process is successfully installed and running + unless fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '12.04' + it 'should output status via passenger-status' do + # xml output not available on ubunutu <= 10.04, so sticking with default pool output + shell("sudo /usr/sbin/passenger-status") do |r| + # spacing may vary + r.stdout.should =~ /[\-]+ General information [\-]+/ + if fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemrelease') == '14.04' + r.stdout.should =~ /Max pool size[ ]+: [0-9]+/ + r.stdout.should =~ /Processes[ ]+: [0-9]+/ + r.stdout.should =~ /Requests in top-level queue[ ]+: [0-9]+/ + else + r.stdout.should =~ /max[ ]+= [0-9]+/ + r.stdout.should =~ /count[ ]+= [0-9]+/ + r.stdout.should =~ /active[ ]+= [0-9]+/ + r.stdout.should =~ /inactive[ ]+= [0-9]+/ + r.stdout.should =~ /Waiting on global queue: [0-9]+/ + end + + r.exit_code.should == 0 + end + end + end + + it 'should answer to passenger.example.com' do + shell("/usr/bin/curl passenger.example.com:80") do |r| + r.stdout.should =~ /^hello world<\/b>$/ + r.exit_code.should == 0 + end + end + + end + + when 'RedHat' + # no fedora 18 passenger package yet, and rhel5 packages only exist for ruby 1.8.5 + unless (fact('operatingsystem') == 'Fedora' and fact('operatingsystemrelease').to_f >= 18) or (fact('osfamily') == 'RedHat' and fact('operatingsystemmajrelease') == '5' and fact('rubyversion') != '1.8.5') + + context "default passenger config" do + it 'succeeds in puppeting passenger' do + pp = <<-EOS + /* EPEL and passenger repositories */ + class { 'epel': } + exec { 'passenger.repo GPG key': + command => '/usr/bin/sudo /usr/bin/curl -o /etc/yum.repos.d/RPM-GPG-KEY-stealthymonkeys.asc http://passenger.stealthymonkeys.com/RPM-GPG-KEY-stealthymonkeys.asc', + creates => '/etc/yum.repos.d/RPM-GPG-KEY-stealthymonkeys.asc', + } + file { 'passenger.repo GPG key': + ensure => file, + path => '/etc/yum.repos.d/RPM-GPG-KEY-stealthymonkeys.asc', + require => Exec['passenger.repo GPG key'], + } + epel::rpm_gpg_key { 'passenger.stealthymonkeys.com': + path => '/etc/yum.repos.d/RPM-GPG-KEY-stealthymonkeys.asc', + require => [ + Class['epel'], + File['passenger.repo GPG key'], + ] + } + yumrepo { 'passenger': + baseurl => 'http://passenger.stealthymonkeys.com/rhel/$releasever/$basearch' , + descr => 'Red Hat Enterprise $releasever - Phusion Passenger', + enabled => 1, + gpgcheck => 1, + gpgkey => 'http://passenger.stealthymonkeys.com/RPM-GPG-KEY-stealthymonkeys.asc', + mirrorlist => 'http://passenger.stealthymonkeys.com/rhel/mirrors', + require => [ + Epel::Rpm_gpg_key['passenger.stealthymonkeys.com'], + ], + } + /* apache and mod_passenger */ + class { 'apache': + require => [ + Class['epel'], + ], + } + class { 'apache::mod::passenger': + require => [ + Yumrepo['passenger'] + ], + } + #{pp_rackapp} + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + + describe file(conf_file) do + it { should contain "PassengerRoot #{passenger_root}" } + it { should contain "PassengerRuby #{passenger_ruby}" } + it { should contain "PassengerTempDir #{passenger_tempdir}" } + end + + describe file(load_file) do + it { should contain "LoadModule passenger_module #{passenger_module_path}" } + end + + it 'should output status via passenger-memory-stats' do + shell("sudo /usr/bin/passenger-memory-stats") do |r| + r.stdout.should =~ /Apache processes/ + r.stdout.should =~ /Nginx processes/ + r.stdout.should =~ /Passenger processes/ + r.stdout.should =~ /### Processes: [0-9]+/ + r.stdout.should =~ /### Total private dirty RSS: [0-9\.]+ MB/ + + r.exit_code.should == 0 + end + end + + it 'should output status via passenger-status' do + shell("sudo PASSENGER_TMPDIR=/var/run/rubygem-passenger /usr/bin/passenger-status") do |r| + # spacing may vary + r.stdout.should =~ /[\-]+ General information [\-]+/ + r.stdout.should =~ /max[ ]+= [0-9]+/ + r.stdout.should =~ /count[ ]+= [0-9]+/ + r.stdout.should =~ /active[ ]+= [0-9]+/ + r.stdout.should =~ /inactive[ ]+= [0-9]+/ + r.stdout.should =~ /Waiting on global queue: [0-9]+/ + + r.exit_code.should == 0 + end + end + + it 'should answer to passenger.example.com' do + shell("/usr/bin/curl passenger.example.com:80") do |r| + r.stdout.should =~ /^hello world<\/b>$/ + r.exit_code.should == 0 + end + end + end + + end + + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_php_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_php_spec.rb new file mode 100644 index 0000000000..ca21fbcd7e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_php_spec.rb @@ -0,0 +1,173 @@ +require 'spec_helper_acceptance' + +describe 'apache::mod::php class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + case fact('osfamily') + when 'Debian' + vhost_dir = '/etc/apache2/sites-enabled' + mod_dir = '/etc/apache2/mods-available' + service_name = 'apache2' + when 'RedHat' + vhost_dir = '/etc/httpd/conf.d' + mod_dir = '/etc/httpd/conf.d' + service_name = 'httpd' + when 'FreeBSD' + vhost_dir = '/usr/local/etc/apache22/Vhosts' + mod_dir = '/usr/local/etc/apache22/Modules' + service_name = 'apache22' + end + + context "default php config" do + it 'succeeds in puppeting php' do + pp= <<-EOS + class { 'apache': + mpm_module => 'prefork', + } + class { 'apache::mod::php': } + apache::vhost { 'php.example.com': + port => '80', + docroot => '/var/www/php', + } + host { 'php.example.com': ip => '127.0.0.1', } + file { '/var/www/php/index.php': + ensure => file, + content => "\\n", + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + + describe file("#{mod_dir}/php5.conf") do + it { should contain "DirectoryIndex index.php" } + end + + it 'should answer to php.example.com' do + shell("/usr/bin/curl php.example.com:80") do |r| + r.stdout.should =~ /PHP Version/ + r.exit_code.should == 0 + end + end + end + + context "custom extensions, php_admin_flag, and php_admin_value" do + it 'succeeds in puppeting php' do + pp= <<-EOS + class { 'apache': + mpm_module => 'prefork', + } + class { 'apache::mod::php': + extensions => ['.php','.php5'], + } + apache::vhost { 'php.example.com': + port => '80', + docroot => '/var/www/php', + php_admin_values => { 'open_basedir' => '/var/www/php/:/usr/share/pear/', }, + php_admin_flags => { 'engine' => 'on', }, + } + host { 'php.example.com': ip => '127.0.0.1', } + file { '/var/www/php/index.php5': + ensure => file, + content => "\\n", + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + + describe file("#{vhost_dir}/25-php.example.com.conf") do + it { should contain " php_admin_flag engine on" } + it { should contain " php_admin_value open_basedir /var/www/php/:/usr/share/pear/" } + end + + it 'should answer to php.example.com' do + shell("/usr/bin/curl php.example.com:80") do |r| + r.stdout.should =~ /\/usr\/share\/pear\// + r.exit_code.should == 0 + end + end + end + + context "provide custom config file" do + it 'succeeds in puppeting php' do + pp= <<-EOS + class {'apache': + mpm_module => 'prefork', + } + class {'apache::mod::php': + content => '# somecontent', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{mod_dir}/php5.conf") do + it { should contain "# somecontent" } + end + end + + context "provide content and template config file" do + it 'succeeds in puppeting php' do + pp= <<-EOS + class {'apache': + mpm_module => 'prefork', + } + class {'apache::mod::php': + content => '# somecontent', + template => 'apache/mod/php5.conf.erb', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{mod_dir}/php5.conf") do + it { should contain "# somecontent" } + end + end + + context "provide source has priority over content" do + it 'succeeds in puppeting php' do + pp= <<-EOS + class {'apache': + mpm_module => 'prefork', + } + class {'apache::mod::php': + content => '# somecontent', + source => 'puppet:///modules/apache/spec', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{mod_dir}/php5.conf") do + it { should contain "# This is a file only for spec testing" } + end + end + + context "provide source has priority over template" do + it 'succeeds in puppeting php' do + pp= <<-EOS + class {'apache': + mpm_module => 'prefork', + } + class {'apache::mod::php': + template => 'apache/mod/php5.conf.erb', + source => 'puppet:///modules/apache/spec', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{mod_dir}/php5.conf") do + it { should contain "# This is a file only for spec testing" } + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_proxy_html_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_proxy_html_spec.rb new file mode 100644 index 0000000000..f015f99941 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_proxy_html_spec.rb @@ -0,0 +1,39 @@ +require 'spec_helper_acceptance' + +describe 'apache::mod::proxy_html class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + case fact('osfamily') + when 'Debian' + service_name = 'apache2' + when 'RedHat' + service_name = 'httpd' + when 'FreeBSD' + service_name = 'apache22' + end + + context "default proxy_html config" do + if fact('osfamily') == 'RedHat' and fact('operatingsystemmajrelease') =~ /(5|6)/ + it 'adds epel' do + pp = "class { 'epel': }" + apply_manifest(pp, :catch_failures => true) + end + end + + it 'succeeds in puppeting proxy_html' do + pp= <<-EOS + class { 'apache': } + class { 'apache::mod::proxy': } + class { 'apache::mod::proxy_http': } + # mod_proxy_html doesn't exist in RHEL5 + if $::osfamily == 'RedHat' and $::operatingsystemmajrelease != '5' { + class { 'apache::mod::proxy_html': } + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_suphp_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_suphp_spec.rb new file mode 100644 index 0000000000..9e26731d61 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/mod_suphp_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper_acceptance' + +describe 'apache::mod::suphp class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + case fact('osfamily') + when 'Debian' + context "default suphp config" do + it 'succeeds in puppeting suphp' do + pp = <<-EOS + class { 'apache': + mpm_module => 'prefork', + } + class { 'apache::mod::php': } + class { 'apache::mod::suphp': } + apache::vhost { 'suphp.example.com': + port => '80', + docroot => '/var/www/suphp', + } + host { 'suphp.example.com': ip => '127.0.0.1', } + file { '/var/www/suphp/index.php': + ensure => file, + owner => 'daemon', + group => 'daemon', + content => "\\n", + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service('apache2') do + it { should be_enabled } + it { should be_running } + end + + it 'should answer to suphp.example.com' do + shell("/usr/bin/curl suphp.example.com:80") do |r| + r.stdout.should =~ /^daemon$/ + r.exit_code.should == 0 + end + end + end + when 'RedHat' + # Not implemented yet + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-59-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-59-x64.yml new file mode 100644 index 0000000000..cde1fe5a85 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-59-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + centos-59-x64: + roles: + - master + platform: el-5-x86_64 + box : centos-59-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-64-x64-pe.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-64-x64-pe.yml new file mode 100644 index 0000000000..e408d1be77 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-64-x64-pe.yml @@ -0,0 +1,13 @@ +HOSTS: + centos-64-x64: + roles: + - master + - database + - dashboard + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: pe diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-64-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-64-x64.yml new file mode 100644 index 0000000000..ce47212a8c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-64-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-65-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-65-x64.yml new file mode 100644 index 0000000000..ac76349736 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/centos-65-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + centos-65-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-65-x64-virtualbox-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-607-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-607-x64.yml new file mode 100644 index 0000000000..e642e09925 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-607-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + debian-607-x64: + roles: + - master + platform: debian-6-amd64 + box : debian-607-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-70rc1-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-70rc1-x64.yml new file mode 100644 index 0000000000..cbbbfb2cc6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-70rc1-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + debian-70rc1-x64: + roles: + - master + platform: debian-7-amd64 + box : debian-70rc1-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-73-i386.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-73-i386.yml new file mode 100644 index 0000000000..a38902d897 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-73-i386.yml @@ -0,0 +1,11 @@ +HOSTS: + debian-73-i386: + roles: + - master + platform: debian-7-i386 + box : debian-73-i386-virtualbox-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-i386-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-73-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-73-x64.yml new file mode 100644 index 0000000000..f9cf0c9b8a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/debian-73-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + debian-73-x64: + roles: + - master + platform: debian-7-amd64 + box : debian-73-x64-virtualbox-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/default.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000000..ce47212a8c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/default.yml @@ -0,0 +1,11 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/fedora-18-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/fedora-18-x64.yml new file mode 100644 index 0000000000..086cae995c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/fedora-18-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + fedora-18-x64: + roles: + - master + platform: fedora-18-x86_64 + box : fedora-18-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/sles-11sp1-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/sles-11sp1-x64.yml new file mode 100644 index 0000000000..a9f01d5f42 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/sles-11sp1-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + sles-11sp1-x64: + roles: + - master + platform: sles-11-x86_64 + box : sles-11sp1-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml new file mode 100644 index 0000000000..c1b8bdf8fa --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-10044-x64: + roles: + - master + platform: ubuntu-10.04-amd64 + box : ubuntu-server-10044-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 0000000000..f7df2ccce1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-12.04-amd64 + box : ubuntu-server-12042-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-1310-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-1310-x64.yml new file mode 100644 index 0000000000..f4b2366f3b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-1310-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-1310-x64: + roles: + - master + platform: ubuntu-13.10-amd64 + box : ubuntu-server-1310-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-1310-x64-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + log_level : debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 0000000000..cba1cd04c2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box : puppetlabs/ubuntu-14.04-64-nocm + box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm + hypervisor : vagrant +CONFIG: + log_level : debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/prefork_worker_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/prefork_worker_spec.rb new file mode 100644 index 0000000000..beffe0a014 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/prefork_worker_spec.rb @@ -0,0 +1,79 @@ +require 'spec_helper_acceptance' + +case fact('osfamily') +when 'RedHat' + servicename = 'httpd' +when 'Debian' + servicename = 'apache2' +when 'FreeBSD' + servicename = 'apache22' +end + +case fact('osfamily') +when 'FreeBSD' + describe 'apache::mod::event class' do + describe 'running puppet code' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + class { 'apache': + mpm_module => 'event', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + end + + describe service(servicename) do + it { should be_running } + it { should be_enabled } + end + end +end + +describe 'apache::mod::worker class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + describe 'running puppet code' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + class { 'apache': + mpm_module => 'worker', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + end + + describe service(servicename) do + it { should be_running } + it { should be_enabled } + end +end + +describe 'apache::mod::prefork class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + describe 'running puppet code' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + class { 'apache': + mpm_module => 'prefork', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + end + + describe service(servicename) do + it { should be_running } + it { should be_enabled } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/service_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/service_spec.rb new file mode 100644 index 0000000000..b51ca386f0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/service_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper_acceptance' + +describe 'apache::service class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + describe 'adding dependencies in between the base class and service class' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apache': } + file { '/tmp/test': + require => Class['apache'], + notify => Class['apache::service'], + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/unsupported_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/unsupported_spec.rb new file mode 100644 index 0000000000..085845dbfc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/unsupported_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper_acceptance' + +describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + it 'should fail' do + pp = <<-EOS + class { 'apache': } + apache::vhost { 'test.lan': + docroot => '/var/www', + } + EOS + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported/i) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/version.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/version.rb new file mode 100644 index 0000000000..27498354b4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/version.rb @@ -0,0 +1,57 @@ +_osfamily = fact('osfamily') +_operatingsystem = fact('operatingsystem') +_operatingsystemrelease = fact('operatingsystemrelease').to_f + +case _osfamily +when 'RedHat' + $confd_dir = '/etc/httpd/conf.d' + $conf_file = '/etc/httpd/conf/httpd.conf' + $ports_file = '/etc/httpd/conf/ports.conf' + $vhost_dir = '/etc/httpd/conf.d' + $vhost = '/etc/httpd/conf.d/15-default.conf' + $run_dir = '/var/run/httpd' + $service_name = 'httpd' + $package_name = 'httpd' + $error_log = 'error_log' + $suphp_handler = 'php5-script' + $suphp_configpath = 'undef' + + if (_operatingsystem == 'Fedora' and _operatingsystemrelease >= 18) or (_operatingsystem != 'Fedora' and _operatingsystemrelease >= 7) + $apache_version = '2.4' + else + $apache_version = '2.2' + end +when 'Debian' + $confd_dir = '/etc/apache2/mods-available' + $conf_file = '/etc/apache2/apache2.conf' + $ports_file = '/etc/apache2/ports.conf' + $vhost = '/etc/apache2/sites-available/15-default.conf' + $vhost_dir = '/etc/apache2/sites-enabled' + $run_dir = '/var/run/apache2' + $service_name = 'apache2' + $package_name = 'apache2' + $error_log = 'error.log' + $suphp_handler = 'x-httpd-php' + $suphp_configpath = '/etc/php5/apache2' + + if _operatingsystem == 'Ubuntu' and _operatingsystemrelease >= 13.10 + $apache_version = '2.4' + else + $apache_version = '2.2' + end +when 'FreeBSD' + $confd_dir = '/usr/local/etc/apache22/Includes' + $conf_file = '/usr/local/etc/apache22/httpd.conf' + $ports_file = '/usr/local/etc/apache22/Includes/ports.conf' + $vhost = '/usr/local/etc/apache22/Vhosts/15-default.conf' + $vhost_dir = '/usr/local/etc/apache22/Vhosts' + $run_dir = '/var/run/apache22' + $service_name = 'apache22' + $package_name = 'apache22' + $error_log = 'http-error.log' + + $apache_version = '2.2' +else + $apache_version = '0' +end + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/vhost_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/vhost_spec.rb new file mode 100644 index 0000000000..c43d3f9e9e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/acceptance/vhost_spec.rb @@ -0,0 +1,1097 @@ +require 'spec_helper_acceptance' +require_relative './version.rb' + +describe 'apache::vhost define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + context 'no default vhosts' do + it 'should create no default vhosts' do + pp = <<-EOS + class { 'apache': + default_vhost => false, + default_ssl_vhost => false, + service_ensure => stopped + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/15-default.conf") do + it { should_not be_file } + end + + describe file("#{$vhost_dir}/15-default-ssl.conf") do + it { should_not be_file } + end + end + + context "default vhost without ssl" do + it 'should create a default vhost config' do + pp = <<-EOS + class { 'apache': } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/15-default.conf") do + it { should contain '' } + end + + describe file("#{$vhost_dir}/15-default-ssl.conf") do + it { should_not be_file } + end + end + + context 'default vhost with ssl' do + it 'should create default vhost configs' do + pp = <<-EOS + file { '#{$run_dir}': + ensure => 'directory', + recurse => true, + } + + class { 'apache': + default_ssl_vhost => true, + require => File['#{$run_dir}'], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/15-default.conf") do + it { should contain '' } + end + + describe file("#{$vhost_dir}/15-default-ssl.conf") do + it { should contain '' } + it { should contain "SSLEngine on" } + end + end + + context 'new vhost on port 80' do + it 'should configure an apache vhost' do + pp = <<-EOS + class { 'apache': } + file { '#{$run_dir}': + ensure => 'directory', + recurse => true, + } + + apache::vhost { 'first.example.com': + port => '80', + docroot => '/var/www/first', + require => File['#{$run_dir}'], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-first.example.com.conf") do + it { should contain '' } + it { should contain "ServerName first.example.com" } + end + end + + context 'new proxy vhost on port 80' do + it 'should configure an apache proxy vhost' do + pp = <<-EOS + class { 'apache': } + apache::vhost { 'proxy.example.com': + port => '80', + docroot => '/var/www/proxy', + proxy_pass => [ + { 'path' => '/foo', 'url' => 'http://backend-foo/'}, + ], + proxy_preserve_host => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-proxy.example.com.conf") do + it { should contain '' } + it { should contain "ServerName proxy.example.com" } + it { should contain "ProxyPass" } + it { should contain "ProxyPreserveHost On" } + it { should_not contain "" } + end + end + + context 'new vhost on port 80' do + it 'should configure two apache vhosts' do + pp = <<-EOS + class { 'apache': } + apache::vhost { 'first.example.com': + port => '80', + docroot => '/var/www/first', + } + host { 'first.example.com': ip => '127.0.0.1', } + file { '/var/www/first/index.html': + ensure => file, + content => "Hello from first\\n", + } + apache::vhost { 'second.example.com': + port => '80', + docroot => '/var/www/second', + } + host { 'second.example.com': ip => '127.0.0.1', } + file { '/var/www/second/index.html': + ensure => file, + content => "Hello from second\\n", + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service($service_name) do + it { should be_enabled } + it { should be_running } + end + + it 'should answer to first.example.com' do + shell("/usr/bin/curl first.example.com:80", {:acceptable_exit_codes => 0}) do |r| + r.stdout.should == "Hello from first\n" + end + end + + it 'should answer to second.example.com' do + shell("/usr/bin/curl second.example.com:80", {:acceptable_exit_codes => 0}) do |r| + r.stdout.should == "Hello from second\n" + end + end + end + + context 'apache_directories' do + describe 'readme example, adapted' do + it 'should configure a vhost with Files' do + pp = <<-EOS + class { 'apache': } + + if versioncmp($apache::apache_version, '2.4') >= 0 { + $_files_match_directory = { 'path' => '(\.swp|\.bak|~)$', 'provider' => 'filesmatch', 'require' => 'all denied', } + } else { + $_files_match_directory = { 'path' => '(\.swp|\.bak|~)$', 'provider' => 'filesmatch', 'deny' => 'from all', } + } + + $_directories = [ + { 'path' => '/var/www/files', }, + $_files_match_directory, + ] + + apache::vhost { 'files.example.net': + docroot => '/var/www/files', + directories => $_directories, + } + file { '/var/www/files/index.html': + ensure => file, + content => "Hello World\\n", + } + file { '/var/www/files/index.html.bak': + ensure => file, + content => "Hello World\\n", + } + host { 'files.example.net': ip => '127.0.0.1', } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service($service_name) do + it { should be_enabled } + it { should be_running } + end + + it 'should answer to files.example.net' do + shell("/usr/bin/curl -sSf files.example.net:80/index.html").stdout.should eq("Hello World\n") + shell("/usr/bin/curl -sSf files.example.net:80/index.html.bak", {:acceptable_exit_codes => 22}).stderr.should match(/curl: \(22\) The requested URL returned error: 403/) + end + end + + describe 'other Directory options' do + it 'should configure a vhost with multiple Directory sections' do + pp = <<-EOS + class { 'apache': } + + if versioncmp($apache::apache_version, '2.4') >= 0 { + $_files_match_directory = { 'path' => 'private.html$', 'provider' => 'filesmatch', 'require' => 'all denied' } + } else { + $_files_match_directory = [ + { 'path' => 'private.html$', 'provider' => 'filesmatch', 'deny' => 'from all' }, + { 'path' => '/bar/bar.html', 'provider' => 'location', allow => [ 'from 127.0.0.1', ] }, + ] + } + + $_directories = [ + { 'path' => '/var/www/files', }, + { 'path' => '/foo/', 'provider' => 'location', 'directoryindex' => 'notindex.html', }, + $_files_match_directory, + ] + + apache::vhost { 'files.example.net': + docroot => '/var/www/files', + directories => $_directories, + } + file { '/var/www/files/foo': + ensure => directory, + } + file { '/var/www/files/foo/notindex.html': + ensure => file, + content => "Hello Foo\\n", + } + file { '/var/www/files/private.html': + ensure => file, + content => "Hello World\\n", + } + file { '/var/www/files/bar': + ensure => directory, + } + file { '/var/www/files/bar/bar.html': + ensure => file, + content => "Hello Bar\\n", + } + host { 'files.example.net': ip => '127.0.0.1', } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service($service_name) do + it { should be_enabled } + it { should be_running } + end + + it 'should answer to files.example.net' do + shell("/usr/bin/curl -sSf files.example.net:80/").stdout.should eq("Hello World\n") + shell("/usr/bin/curl -sSf files.example.net:80/foo/").stdout.should eq("Hello Foo\n") + shell("/usr/bin/curl -sSf files.example.net:80/private.html", {:acceptable_exit_codes => 22}).stderr.should match(/curl: \(22\) The requested URL returned error: 403/) + shell("/usr/bin/curl -sSf files.example.net:80/bar/bar.html").stdout.should eq("Hello Bar\n") + end + end + + describe 'SetHandler directive' do + it 'should configure a vhost with a SetHandler directive' do + pp = <<-EOS + class { 'apache': } + apache::mod { 'status': } + host { 'files.example.net': ip => '127.0.0.1', } + apache::vhost { 'files.example.net': + docroot => '/var/www/files', + directories => [ + { path => '/var/www/files', }, + { path => '/server-status', provider => 'location', sethandler => 'server-status', }, + ], + } + file { '/var/www/files/index.html': + ensure => file, + content => "Hello World\\n", + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service($service_name) do + it { should be_enabled } + it { should be_running } + end + + it 'should answer to files.example.net' do + shell("/usr/bin/curl -sSf files.example.net:80/index.html").stdout.should eq("Hello World\n") + shell("/usr/bin/curl -sSf files.example.net:80/server-status?auto").stdout.should match(/Scoreboard: /) + end + end + end + + case fact('lsbdistcodename') + when 'precise', 'wheezy' + context 'vhost fallbackresouce example' do + it 'should configure a vhost with Fallbackresource' do + pp = <<-EOS + class { 'apache': } + apache::vhost { 'fallback.example.net': + docroot => '/var/www/fallback', + fallbackresource => '/index.html' + } + file { '/var/www/fallback/index.html': + ensure => file, + content => "Hello World\\n", + } + host { 'fallback.example.net': ip => '127.0.0.1', } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service($service_name) do + it { should be_enabled } + it { should be_running } + end + + it 'should answer to fallback.example.net' do + shell("/usr/bin/curl fallback.example.net:80/Does/Not/Exist") do |r| + r.stdout.should == "Hello World\n" + end + end + + end + else + # The current stable RHEL release (6.4) comes with Apache httpd 2.2.15 + # That was released March 6, 2010. + # FallbackResource was backported to 2.2.16, and released July 25, 2010. + # Ubuntu Lucid (10.04) comes with apache2 2.2.14, released October 3, 2009. + # https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x/STATUS + end + + context 'virtual_docroot hosting separate sites' do + it 'should configure a vhost with VirtualDocumentRoot' do + pp = <<-EOS + class { 'apache': } + apache::vhost { 'virt.example.com': + vhost_name => '*', + serveraliases => '*virt.example.com', + port => '80', + docroot => '/var/www/virt', + virtual_docroot => '/var/www/virt/%1', + } + host { 'virt.example.com': ip => '127.0.0.1', } + host { 'a.virt.example.com': ip => '127.0.0.1', } + host { 'b.virt.example.com': ip => '127.0.0.1', } + file { [ '/var/www/virt/a', '/var/www/virt/b', ]: ensure => directory, } + file { '/var/www/virt/a/index.html': ensure => file, content => "Hello from a.virt\\n", } + file { '/var/www/virt/b/index.html': ensure => file, content => "Hello from b.virt\\n", } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe service($service_name) do + it { should be_enabled } + it { should be_running } + end + + it 'should answer to a.virt.example.com' do + shell("/usr/bin/curl a.virt.example.com:80", {:acceptable_exit_codes => 0}) do |r| + r.stdout.should == "Hello from a.virt\n" + end + end + + it 'should answer to b.virt.example.com' do + shell("/usr/bin/curl b.virt.example.com:80", {:acceptable_exit_codes => 0}) do |r| + r.stdout.should == "Hello from b.virt\n" + end + end + end + + context 'proxy_pass for alternative vhost' do + it 'should configure a local vhost and a proxy vhost' do + apply_manifest(%{ + class { 'apache': default_vhost => false, } + apache::vhost { 'localhost': + docroot => '/var/www/local', + ip => '127.0.0.1', + port => '8888', + } + apache::listen { '*:80': } + apache::vhost { 'proxy.example.com': + docroot => '/var/www', + port => '80', + add_listen => false, + proxy_pass => { + 'path' => '/', + 'url' => 'http://localhost:8888/subdir/', + }, + } + host { 'proxy.example.com': ip => '127.0.0.1', } + file { ['/var/www/local', '/var/www/local/subdir']: ensure => directory, } + file { '/var/www/local/subdir/index.html': + ensure => file, + content => "Hello from localhost\\n", + } + }, :catch_failures => true) + end + + describe service($service_name) do + it { should be_enabled } + it { should be_running } + end + + it 'should get a response from the back end' do + shell("/usr/bin/curl --max-redirs 0 proxy.example.com:80") do |r| + r.stdout.should == "Hello from localhost\n" + r.exit_code.should == 0 + end + end + end + + describe 'ip_based' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + ip_based => true, + servername => 'test.server', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file($ports_file) do + it { should be_file } + it { should_not contain 'NameVirtualHost test.server' } + end + end + + describe 'add_listen' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': default_vhost => false } + host { 'testlisten.server': ip => '127.0.0.1' } + apache::listen { '81': } + apache::vhost { 'testlisten.server': + docroot => '/tmp', + port => '80', + add_listen => false, + servername => 'testlisten.server', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file($ports_file) do + it { should be_file } + it { should_not contain 'Listen 80' } + it { should contain 'Listen 81' } + end + end + + describe 'docroot' do + it 'applies cleanly' do + pp = <<-EOS + user { 'test_owner': ensure => present, } + group { 'test_group': ensure => present, } + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp/test', + docroot_owner => 'test_owner', + docroot_group => 'test_group', + docroot_mode => '0750', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file('/tmp/test') do + it { should be_directory } + it { should be_owned_by 'test_owner' } + it { should be_grouped_into 'test_group' } + it { should be_mode 750 } + end + end + + describe 'default_vhost' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + default_vhost => true, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file($ports_file) do + it { should be_file } + if fact('osfamily') == 'RedHat' and fact('operatingsystemmajrelease') == '7' + it { should_not contain 'NameVirtualHost test.server' } + elsif fact('operatingsystem') == 'Ubuntu' and fact('operatingsystemrelease') =~ /(14\.04|13\.10)/ + it { should_not contain 'NameVirtualHost test.server' } + else + it { should contain 'NameVirtualHost test.server' } + end + end + + describe file("#{$vhost_dir}/10-test.server.conf") do + it { should be_file } + end + end + + describe 'options' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + options => ['Indexes','FollowSymLinks', 'ExecCGI'], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'Options Indexes FollowSymLinks ExecCGI' } + end + end + + describe 'override' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + override => ['All'], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'AllowOverride All' } + end + end + + describe 'logroot' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + logroot => '/tmp', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain ' CustomLog "/tmp' } + end + end + + ['access', 'error'].each do |logtype| + case logtype + when 'access' + logname = 'CustomLog' + when 'error' + logname = 'ErrorLog' + end + + describe "#{logtype}_log" do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + logroot => '/tmp', + #{logtype}_log => false, + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should_not contain " #{logname} \"/tmp" } + end + end + + describe "#{logtype}_log_pipe" do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + logroot => '/tmp', + #{logtype}_log_pipe => '|/bin/sh', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain " #{logname} \"|/bin/sh" } + end + end + + describe "#{logtype}_log_syslog" do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + logroot => '/tmp', + #{logtype}_log_syslog => 'syslog', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain " #{logname} \"syslog\"" } + end + end + end + + describe 'access_log_format' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + logroot => '/tmp', + access_log_syslog => 'syslog', + access_log_format => '%h %l', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'CustomLog "syslog" "%h %l"' } + end + end + + describe 'access_log_env_var' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + logroot => '/tmp', + access_log_syslog => 'syslog', + access_log_env_var => 'admin', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'CustomLog "syslog" combined env=admin' } + end + end + + describe 'aliases' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + aliases => [{ alias => '/image', path => '/ftp/pub/image' }], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'Alias /image "/ftp/pub/image"' } + end + end + + describe 'scriptaliases' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + scriptaliases => [{ alias => '/myscript', path => '/usr/share/myscript', }], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'ScriptAlias /myscript "/usr/share/myscript"' } + end + end + + describe 'proxy' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': service_ensure => stopped, } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + proxy_dest => 'test2', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'ProxyPass / test2/' } + end + end + + describe 'actions' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + action => 'php-fastcgi', + } + EOS + pp = pp + "\nclass { 'apache::mod::actions': }" if fact('osfamily') == 'Debian' + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'Action php-fastcgi /cgi-bin virtual' } + end + end + + describe 'suphp' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': service_ensure => stopped, } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + suphp_addhandler => '#{$suphp_handler}', + suphp_engine => 'on', + suphp_configpath => '#{$suphp_configpath}', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain "suPHP_AddHandler #{$suphp_handler}" } + it { should contain 'suPHP_Engine on' } + it { should contain "suPHP_ConfigPath \"#{$suphp_configpath}\"" } + end + end + + describe 'no_proxy_uris' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': service_ensure => stopped, } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + proxy_dest => 'http://test2', + no_proxy_uris => [ 'http://test2/test' ], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'ProxyPass / http://test2/' } + it { should contain 'ProxyPass http://test2/test !' } + end + end + + describe 'redirect' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + redirect_source => ['/images'], + redirect_dest => ['http://test.server/'], + redirect_status => ['permanent'], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'Redirect permanent /images http://test.server/' } + end + end + + # Passenger isn't even in EPEL on el-5 + if default['platform'] !~ /^el-5/ + describe 'rack_base_uris' do + if fact('osfamily') == 'RedHat' + it 'adds epel' do + pp = "class { 'epel': }" + apply_manifest(pp, :catch_failures => true) + end + end + + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + rack_base_uris => ['/test'], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'RackBaseURI /test' } + end + end + end + + + describe 'request_headers' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + request_headers => ['append MirrorID "mirror 12"'], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'append MirrorID "mirror 12"' } + end + end + + describe 'rewrite rules' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + rewrites => [ + { comment => 'test', + rewrite_cond => '%{HTTP_USER_AGENT} ^Lynx/ [OR]', + rewrite_rule => ['^index\.html$ welcome.html'], + } + ], + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain '#test' } + it { should contain 'RewriteCond %{HTTP_USER_AGENT} ^Lynx/ [OR]' } + it { should contain 'RewriteRule ^index.html$ welcome.html' } + end + end + + describe 'setenv/setenvif' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + setenv => ['TEST /test'], + setenvif => ['Request_URI "\.gif$" object_is_image=gif'] + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'SetEnv TEST /test' } + it { should contain 'SetEnvIf Request_URI "\.gif$" object_is_image=gif' } + end + end + + describe 'block' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + block => 'scm', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain '' } + end + end + + describe 'wsgi' do + it 'import_script applies cleanly' do + pp = <<-EOS + class { 'apache': } + class { 'apache::mod::wsgi': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + wsgi_application_group => '%{GLOBAL}', + wsgi_daemon_process => 'wsgi', + wsgi_daemon_process_options => {processes => '2'}, + wsgi_process_group => 'nobody', + wsgi_script_aliases => { '/test' => '/test1' }, + wsgi_pass_authorization => 'On', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + it 'import_script applies cleanly', :unless => (fact('lsbdistcodename') == 'lucid' or UNSUPPORTED_PLATFORMS.include?(fact('osfamily'))) do + pp = <<-EOS + class { 'apache': } + class { 'apache::mod::wsgi': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + wsgi_application_group => '%{GLOBAL}', + wsgi_daemon_process => 'wsgi', + wsgi_daemon_process_options => {processes => '2'}, + wsgi_import_script => '/test1', + wsgi_import_script_options => { application-group => '%{GLOBAL}', process-group => 'wsgi' }, + wsgi_process_group => 'nobody', + wsgi_script_aliases => { '/test' => '/test1' }, + wsgi_pass_authorization => 'On', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf"), :unless => (fact('lsbdistcodename') == 'lucid' or UNSUPPORTED_PLATFORMS.include?(fact('osfamily'))) do + it { should be_file } + it { should contain 'WSGIApplicationGroup %{GLOBAL}' } + it { should contain 'WSGIDaemonProcess wsgi processes=2' } + it { should contain 'WSGIImportScript /test1 application-group=%{GLOBAL} process-group=wsgi' } + it { should contain 'WSGIProcessGroup nobody' } + it { should contain 'WSGIScriptAlias /test "/test1"' } + it { should contain 'WSGIPassAuthorization On' } + end + end + + describe 'custom_fragment' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + custom_fragment => inline_template('#weird test string'), + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain '#weird test string' } + end + end + + describe 'itk' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + itk => { user => 'nobody', group => 'nobody' } + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'AssignUserId nobody nobody' } + end + end + + # So what does this work on? + if default['platform'] !~ /^(debian-(6|7)|el-(5|6|7))/ + describe 'fastcgi' do + it 'applies cleanly' do + pp = <<-EOS + class { 'apache': } + class { 'apache::mod::fastcgi': } + host { 'test.server': ip => '127.0.0.1' } + apache::vhost { 'test.server': + docroot => '/tmp', + fastcgi_server => 'localhost', + fastcgi_socket => '/tmp/fast/1234', + fastcgi_dir => '/tmp/fast', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'FastCgiExternalServer localhost -socket /tmp/fast/1234' } + it { should contain '' } + end + end + end + + describe 'additional_includes' do + it 'applies cleanly' do + pp = <<-EOS + if $::osfamily == 'RedHat' and $::selinux == 'true' { + exec { 'set_apache_defaults': + command => 'semanage fcontext -a -t httpd_sys_content_t "/apache_spec(/.*)?"', + path => '/bin:/usr/bin/:/sbin:/usr/sbin', + require => Package[$semanage_package], + } + $semanage_package = $::operatingsystemmajrelease ? { + '5' => 'policycoreutils', + 'default' => 'policycoreutils-python', + } + + package { $semanage_package: ensure => installed } + exec { 'restorecon_apache': + command => 'restorecon -Rv /apache_spec', + path => '/bin:/usr/bin/:/sbin:/usr/sbin', + before => Service['httpd'], + require => Class['apache'], + } + } + class { 'apache': } + host { 'test.server': ip => '127.0.0.1' } + file { '/apache_spec': ensure => directory, } + file { '/apache_spec/include': ensure => present, content => '#additional_includes' } + apache::vhost { 'test.server': + docroot => '/apache_spec', + additional_includes => '/apache_spec/include', + } + EOS + apply_manifest(pp, :catch_failures => true) + end + + describe file("#{$vhost_dir}/25-test.server.conf") do + it { should be_file } + it { should contain 'Include "/apache_spec/include"' } + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/apache_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/apache_spec.rb new file mode 100644 index 0000000000..f32fec8088 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/apache_spec.rb @@ -0,0 +1,563 @@ +require 'spec_helper' + +describe 'apache', :type => :class do + context "on a Debian OS" do + let :facts do + { + :id => 'root', + :kernel => 'Linux', + :lsbdistcodename => 'squeeze', + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :operatingsystemrelease => '6', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + it { should contain_class("apache::params") } + it { should contain_package("httpd").with( + 'notify' => 'Class[Apache::Service]', + 'ensure' => 'installed' + ) + } + it { should contain_user("www-data") } + it { should contain_group("www-data") } + it { should contain_class("apache::service") } + it { should contain_file("/etc/apache2/sites-enabled").with( + 'ensure' => 'directory', + 'recurse' => 'true', + 'purge' => 'true', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) + } + it { should contain_file("/etc/apache2/mods-enabled").with( + 'ensure' => 'directory', + 'recurse' => 'true', + 'purge' => 'true', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) + } + it { should contain_file("/etc/apache2/mods-available").with( + 'ensure' => 'directory', + 'recurse' => 'true', + 'purge' => 'false', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) + } + it { should contain_concat("/etc/apache2/ports.conf").with( + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'notify' => 'Class[Apache::Service]' + ) + } + # Assert that load files are placed and symlinked for these mods, but no conf file. + [ + 'auth_basic', + 'authn_file', + 'authz_default', + 'authz_groupfile', + 'authz_host', + 'authz_user', + 'dav', + 'env' + ].each do |modname| + it { should contain_file("#{modname}.load").with( + 'path' => "/etc/apache2/mods-available/#{modname}.load", + 'ensure' => 'file' + ) } + it { should contain_file("#{modname}.load symlink").with( + 'path' => "/etc/apache2/mods-enabled/#{modname}.load", + 'ensure' => 'link', + 'target' => "/etc/apache2/mods-available/#{modname}.load" + ) } + it { should_not contain_file("#{modname}.conf") } + it { should_not contain_file("#{modname}.conf symlink") } + end + + context "with Apache version < 2.4" do + let :params do + { :apache_version => '2.2' } + end + + it { should contain_file("/etc/apache2/apache2.conf").with_content %r{^Include "/etc/apache2/conf\.d/\*\.conf"$} } + end + + context "with Apache version >= 2.4" do + let :params do + { :apache_version => '2.4' } + end + + it { should contain_file("/etc/apache2/apache2.conf").with_content %r{^IncludeOptional "/etc/apache2/conf\.d/\*\.conf"$} } + end + + # Assert that both load files and conf files are placed and symlinked for these mods + [ + 'alias', + 'autoindex', + 'dav_fs', + 'deflate', + 'dir', + 'mime', + 'negotiation', + 'setenvif', + ].each do |modname| + it { should contain_file("#{modname}.load").with( + 'path' => "/etc/apache2/mods-available/#{modname}.load", + 'ensure' => 'file' + ) } + it { should contain_file("#{modname}.load symlink").with( + 'path' => "/etc/apache2/mods-enabled/#{modname}.load", + 'ensure' => 'link', + 'target' => "/etc/apache2/mods-available/#{modname}.load" + ) } + it { should contain_file("#{modname}.conf").with( + 'path' => "/etc/apache2/mods-available/#{modname}.conf", + 'ensure' => 'file' + ) } + it { should contain_file("#{modname}.conf symlink").with( + 'path' => "/etc/apache2/mods-enabled/#{modname}.conf", + 'ensure' => 'link', + 'target' => "/etc/apache2/mods-available/#{modname}.conf" + ) } + end + + describe "Don't create user resource" do + context "when parameter manage_user is false" do + let :params do + { :manage_user => false } + end + + it { should_not contain_user('www-data') } + it { should contain_file("/etc/apache2/apache2.conf").with_content %r{^User www-data\n} } + end + end + describe "Don't create group resource" do + context "when parameter manage_group is false" do + let :params do + { :manage_group => false } + end + + it { should_not contain_group('www-data') } + it { should contain_file("/etc/apache2/apache2.conf").with_content %r{^Group www-data\n} } + end + end + + describe "Add extra LogFormats" do + context "When parameter log_formats is a hash" do + let :params do + { :log_formats => { + 'vhost_common' => "%v %h %l %u %t \"%r\" %>s %b", + 'vhost_combined' => "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" + } } + end + + it { should contain_file("/etc/apache2/apache2.conf").with_content %r{^LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common\n} } + it { should contain_file("/etc/apache2/apache2.conf").with_content %r{^LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" vhost_combined\n} } + end + end + + context "on Ubuntu" do + let :facts do + super().merge({ + :operatingsystem => 'Ubuntu' + }) + end + + context "13.10" do + let :facts do + super().merge({ + :lsbdistrelease => '13.10', + :operatingsystemrelease => '13.10' + }) + end + it { should contain_class('apache').with_apache_version('2.4') } + end + context "12.04" do + let :facts do + super().merge({ + :lsbdistrelease => '12.04', + :operatingsystemrelease => '12.04' + }) + end + it { should contain_class('apache').with_apache_version('2.2') } + end + context "13.04" do + let :facts do + super().merge({ + :lsbdistrelease => '13.04', + :operatingsystemrelease => '13.04' + }) + end + it { should contain_class('apache').with_apache_version('2.2') } + end + end + end + context "on a RedHat 5 OS" do + let :facts do + { + :id => 'root', + :kernel => 'Linux', + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '5', + :concat_basedir => '/dne', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_package("httpd").with( + 'notify' => 'Class[Apache::Service]', + 'ensure' => 'installed' + ) + } + it { should contain_user("apache") } + it { should contain_group("apache") } + it { should contain_class("apache::service") } + it { should contain_file("/etc/httpd/conf.d").with( + 'ensure' => 'directory', + 'recurse' => 'true', + 'purge' => 'true', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) + } + it { should contain_concat("/etc/httpd/conf/ports.conf").with( + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'notify' => 'Class[Apache::Service]' + ) + } + describe "Alternate confd/mod/vhosts directory" do + let :params do + { + :vhost_dir => '/etc/httpd/site.d', + :confd_dir => '/etc/httpd/conf.d', + :mod_dir => '/etc/httpd/mod.d', + } + end + + ['mod.d','site.d','conf.d'].each do |dir| + it { should contain_file("/etc/httpd/#{dir}").with( + 'ensure' => 'directory', + 'recurse' => 'true', + 'purge' => 'true', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) } + end + + # Assert that load files are placed for these mods, but no conf file. + [ + 'auth_basic', + 'authn_file', + 'authz_default', + 'authz_groupfile', + 'authz_host', + 'authz_user', + 'dav', + 'env', + ].each do |modname| + it { should contain_file("#{modname}.load").with_path( + "/etc/httpd/mod.d/#{modname}.load" + ) } + it { should_not contain_file("#{modname}.conf").with_path( + "/etc/httpd/mod.d/#{modname}.conf" + ) } + end + + # Assert that both load files and conf files are placed for these mods + [ + 'alias', + 'autoindex', + 'dav_fs', + 'deflate', + 'dir', + 'mime', + 'negotiation', + 'setenvif', + ].each do |modname| + it { should contain_file("#{modname}.load").with_path( + "/etc/httpd/mod.d/#{modname}.load" + ) } + it { should contain_file("#{modname}.conf").with_path( + "/etc/httpd/mod.d/#{modname}.conf" + ) } + end + + context "with Apache version < 2.4" do + let :params do + { :apache_version => '2.2' } + end + + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^Include "/etc/httpd/conf\.d/\*\.conf"$} } + end + + context "with Apache version >= 2.4" do + let :params do + { :apache_version => '2.4' } + end + + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^IncludeOptional "/etc/httpd/conf\.d/\*\.conf"$} } + end + + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^Include "/etc/httpd/site\.d/\*"$} } + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^Include "/etc/httpd/mod\.d/\*\.conf"$} } + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^Include "/etc/httpd/mod\.d/\*\.load"$} } + end + + describe "Alternate conf.d directory" do + let :params do + { :confd_dir => '/etc/httpd/special_conf.d' } + end + + it { should contain_file("/etc/httpd/special_conf.d").with( + 'ensure' => 'directory', + 'recurse' => 'true', + 'purge' => 'true', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) } + end + + describe "Alternate mpm_modules" do + context "when declaring mpm_module is false" do + let :params do + { :mpm_module => false } + end + it 'should not declare mpm modules' do + should_not contain_class('apache::mod::event') + should_not contain_class('apache::mod::itk') + should_not contain_class('apache::mod::peruser') + should_not contain_class('apache::mod::prefork') + should_not contain_class('apache::mod::worker') + end + end + context "when declaring mpm_module => prefork" do + let :params do + { :mpm_module => 'prefork' } + end + it { should contain_class('apache::mod::prefork') } + it { should_not contain_class('apache::mod::event') } + it { should_not contain_class('apache::mod::itk') } + it { should_not contain_class('apache::mod::peruser') } + it { should_not contain_class('apache::mod::worker') } + end + context "when declaring mpm_module => worker" do + let :params do + { :mpm_module => 'worker' } + end + it { should contain_class('apache::mod::worker') } + it { should_not contain_class('apache::mod::event') } + it { should_not contain_class('apache::mod::itk') } + it { should_not contain_class('apache::mod::peruser') } + it { should_not contain_class('apache::mod::prefork') } + end + context "when declaring mpm_module => breakme" do + let :params do + { :mpm_module => 'breakme' } + end + it { expect { subject }.to raise_error Puppet::Error, /does not match/ } + end + end + + describe "different templates for httpd.conf" do + context "with default" do + let :params do + { :conf_template => 'apache/httpd.conf.erb' } + end + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^# Security\n} } + end + context "with non-default" do + let :params do + { :conf_template => 'site_apache/fake.conf.erb' } + end + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^Fake template for rspec.$} } + end + end + + describe "default mods" do + context "without" do + let :params do + { :default_mods => false } + end + + it { should contain_apache__mod('authz_host') } + it { should_not contain_apache__mod('env') } + end + context "custom" do + let :params do + { :default_mods => [ + 'info', + 'alias', + 'mime', + 'env', + 'setenv', + 'expires', + ]} + end + + it { should contain_apache__mod('authz_host') } + it { should contain_apache__mod('env') } + it { should contain_class('apache::mod::info') } + it { should contain_class('apache::mod::mime') } + end + end + describe "Don't create user resource" do + context "when parameter manage_user is false" do + let :params do + { :manage_user => false } + end + + it { should_not contain_user('apache') } + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^User apache\n} } + end + end + describe "Don't create group resource" do + context "when parameter manage_group is false" do + let :params do + { :manage_group => false } + end + + it { should_not contain_group('apache') } + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^Group apache\n} } + + end + end + describe "sendfile" do + context "with invalid value" do + let :params do + { :sendfile => 'foo' } + end + it "should fail" do + expect do + subject + end.to raise_error(Puppet::Error, /"foo" does not match/) + end + end + context "On" do + let :params do + { :sendfile => 'On' } + end + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^EnableSendfile On\n} } + end + context "Off" do + let :params do + { :sendfile => 'Off' } + end + it { should contain_file("/etc/httpd/conf/httpd.conf").with_content %r{^EnableSendfile Off\n} } + end + end + end + context "on a FreeBSD OS" do + let :facts do + { + :id => 'root', + :kernel => 'FreeBSD', + :osfamily => 'FreeBSD', + :operatingsystem => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_class("apache::package").with({'ensure' => 'present'}) } + it { should contain_user("www") } + it { should contain_group("www") } + it { should contain_class("apache::service") } + it { should contain_file("/usr/local/etc/apache22/Vhosts").with( + 'ensure' => 'directory', + 'recurse' => 'true', + 'purge' => 'true', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) } + it { should contain_file("/usr/local/etc/apache22/Modules").with( + 'ensure' => 'directory', + 'recurse' => 'true', + 'purge' => 'true', + 'notify' => 'Class[Apache::Service]', + 'require' => 'Package[httpd]' + ) } + it { should contain_concat("/usr/local/etc/apache22/ports.conf").with( + 'owner' => 'root', + 'group' => 'wheel', + 'mode' => '0644', + 'notify' => 'Class[Apache::Service]' + ) } + # Assert that load files are placed for these mods, but no conf file. + [ + 'auth_basic', + 'authn_file', + 'authz_default', + 'authz_groupfile', + 'authz_host', + 'authz_user', + 'dav', + 'env' + ].each do |modname| + it { should contain_file("#{modname}.load").with( + 'path' => "/usr/local/etc/apache22/Modules/#{modname}.load", + 'ensure' => 'file' + ) } + it { should_not contain_file("#{modname}.conf") } + end + + # Assert that both load files and conf files are placed for these mods + [ + 'alias', + 'autoindex', + 'dav_fs', + 'deflate', + 'dir', + 'mime', + 'negotiation', + 'setenvif', + ].each do |modname| + it { should contain_file("#{modname}.load").with( + 'path' => "/usr/local/etc/apache22/Modules/#{modname}.load", + 'ensure' => 'file' + ) } + it { should contain_file("#{modname}.conf").with( + 'path' => "/usr/local/etc/apache22/Modules/#{modname}.conf", + 'ensure' => 'file' + ) } + end + end + context 'on all OSes' do + let :facts do + { + :id => 'root', + :kernel => 'Linux', + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + context 'default vhost defaults' do + it { should contain_apache__vhost('default').with_ensure('present') } + it { should contain_apache__vhost('default-ssl').with_ensure('absent') } + end + context 'without default non-ssl vhost' do + let :params do { + :default_vhost => false + } + end + it { should contain_apache__vhost('default').with_ensure('absent') } + end + context 'with default ssl vhost' do + let :params do { + :default_ssl_vhost => true + } + end + it { should contain_apache__vhost('default-ssl').with_ensure('present') } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/dev_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/dev_spec.rb new file mode 100644 index 0000000000..eceadca4a7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/dev_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +describe 'apache::dev', :type => :class do + context "on a Debian OS" do + let :facts do + { + :lsbdistcodename => 'squeeze', + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :operatingsystemrelease => '6', + } + end + it { should contain_class("apache::params") } + it { should contain_package("libaprutil1-dev") } + it { should contain_package("libapr1-dev") } + it { should contain_package("apache2-prefork-dev") } + end + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '6', + } + end + it { should contain_class("apache::params") } + it { should contain_package("httpd-devel") } + end + context "on a FreeBSD OS" do + let :pre_condition do + 'include apache::package' + end + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystem => 'FreeBSD', + :operatingsystemrelease => '9', + } + end + it { should contain_class("apache::params") } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/auth_kerb_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/auth_kerb_spec.rb new file mode 100644 index 0000000000..6e2c16b7e9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/auth_kerb_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe 'apache::mod::auth_kerb', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS", :compile do + let :facts do + { + :id => 'root', + :kernel => 'Linux', + :lsbdistcodename => 'squeeze', + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :operatingsystemrelease => '6', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod("auth_kerb") } + it { should contain_package("libapache2-mod-auth-kerb") } + end + context "on a RedHat OS", :compile do + let :facts do + { + :id => 'root', + :kernel => 'Linux', + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '6', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod("auth_kerb") } + it { should contain_package("mod_auth_kerb") } + end + context "on a FreeBSD OS", :compile do + let :facts do + { + :id => 'root', + :kernel => 'FreeBSD', + :osfamily => 'FreeBSD', + :operatingsystem => 'FreeBSD', + :operatingsystemrelease => '9', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod("auth_kerb") } + it { should contain_package("www/mod_auth_kerb2") } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/authnz_ldap_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/authnz_ldap_spec.rb new file mode 100644 index 0000000000..d9ca5398b1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/authnz_ldap_spec.rb @@ -0,0 +1,76 @@ +require 'spec_helper' + +describe 'apache::mod::authnz_ldap', :type => :class do + let :pre_condition do + 'include apache' + end + + context "on a Debian OS" do + let :facts do + { + :lsbdistcodename => 'squeeze', + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :id => 'root', + :kernel => 'Linux', + :operatingsystem => 'Debian', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_class("apache::mod::ldap") } + it { should contain_apache__mod('authnz_ldap') } + + context 'default verifyServerCert' do + it { should contain_file('authnz_ldap.conf').with_content(/^LDAPVerifyServerCert On$/) } + end + + context 'verifyServerCert = false' do + let(:params) { { :verifyServerCert => false } } + it { should contain_file('authnz_ldap.conf').with_content(/^LDAPVerifyServerCert Off$/) } + end + + context 'verifyServerCert = wrong' do + let(:params) { { :verifyServerCert => 'wrong' } } + it 'should raise an error' do + expect { should raise_error Puppet::Error } + end + end + end #Debian + + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :id => 'root', + :kernel => 'Linux', + :operatingsystem => 'RedHat', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_class("apache::mod::ldap") } + it { should contain_apache__mod('authnz_ldap') } + + context 'default verifyServerCert' do + it { should contain_file('authnz_ldap.conf').with_content(/^LDAPVerifyServerCert On$/) } + end + + context 'verifyServerCert = false' do + let(:params) { { :verifyServerCert => false } } + it { should contain_file('authnz_ldap.conf').with_content(/^LDAPVerifyServerCert Off$/) } + end + + context 'verifyServerCert = wrong' do + let(:params) { { :verifyServerCert => 'wrong' } } + it 'should raise an error' do + expect { should raise_error Puppet::Error } + end + end + end # Redhat + +end + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/dav_svn_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/dav_svn_spec.rb new file mode 100644 index 0000000000..4898cdece1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/dav_svn_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe 'apache::mod::dav_svn', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS" do + let :facts do + { + :lsbdistcodename => 'squeeze', + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('dav_svn') } + it { should contain_package("libapache2-svn") } + end + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('dav_svn') } + it { should contain_package("mod_dav_svn") } + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('dav_svn') } + it { should contain_package("devel/subversion") } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/deflate_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/deflate_spec.rb new file mode 100644 index 0000000000..f8eb881013 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/deflate_spec.rb @@ -0,0 +1,90 @@ +require 'spec_helper' + +# This function is called inside the OS specific contexts +def general_deflate_specs + it { should contain_apache__mod("deflate") } + + it do + should contain_file("deflate.conf").with_content( + "AddOutputFilterByType DEFLATE text/html text/plain text/xml\n"\ + "AddOutputFilterByType DEFLATE text/css\n"\ + "AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript\n"\ + "AddOutputFilterByType DEFLATE application/rss+xml\n"\ + "\n"\ + "DeflateFilterNote Input instream\n"\ + "DeflateFilterNote Output outstream\n"\ + "DeflateFilterNote Ratio ratio\n" + ) + end +end + +describe 'apache::mod::deflate', :type => :class do + let :pre_condition do + 'include apache' + end + + context "On a Debian OS with default params" do + let :facts do + { + :id => 'root', + :lsbdistcodename => 'squeeze', + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :operatingsystemrelease => '6', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + + # Load the more generic tests for this context + general_deflate_specs() + + it { should contain_file("deflate.conf").with({ + :ensure => 'file', + :path => '/etc/apache2/mods-available/deflate.conf', + } ) } + it { should contain_file("deflate.conf symlink").with({ + :ensure => 'link', + :path => '/etc/apache2/mods-enabled/deflate.conf', + } ) } + end + + context "on a RedHat OS with default params" do + let :facts do + { + :id => 'root', + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '6', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + + # Load the more generic tests for this context + general_deflate_specs() + + it { should contain_file("deflate.conf").with_path("/etc/httpd/conf.d/deflate.conf") } + end + + context "On a FreeBSD OS with default params" do + let :facts do + { + :id => 'root', + :osfamily => 'FreeBSD', + :operatingsystem => 'FreeBSD', + :operatingsystemrelease => '9', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :concat_basedir => '/dne', + } + end + + # Load the more generic tests for this context + general_deflate_specs() + + it { should contain_file("deflate.conf").with({ + :ensure => 'file', + :path => '/usr/local/etc/apache22/Modules/deflate.conf', + } ) } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/dev_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/dev_spec.rb new file mode 100644 index 0000000000..0de62afcb5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/dev_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe 'apache::mod::dev', :type => :class do + [ + ['RedHat', '6', 'Santiago'], + ['Debian', '6', 'squeeze'], + ['FreeBSD', '9', 'FreeBSD'], + ].each do |osfamily, operatingsystemrelease, lsbdistcodename| + if osfamily == 'FreeBSD' + let :pre_condition do + 'include apache::package' + end + end + context "on a #{osfamily} OS" do + let :facts do + { + :lsbdistcodename => lsbdistcodename, + :osfamily => osfamily, + :operatingsystem => osfamily, + :operatingsystemrelease => operatingsystemrelease, + } + end + it { should contain_class('apache::dev') } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/dir_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/dir_spec.rb new file mode 100644 index 0000000000..8bcdc0b6be --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/dir_spec.rb @@ -0,0 +1,103 @@ +require 'spec_helper' + +describe 'apache::mod::dir', :type => :class do + let :pre_condition do + 'class { "apache": + default_mods => false, + }' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :lsbdistcodename => 'squeeze', + } + end + context "passing no parameters" do + it { should contain_class("apache::params") } + it { should contain_apache__mod('dir') } + it { should contain_file('dir.conf').with_content(/^DirectoryIndex /) } + it { should contain_file('dir.conf').with_content(/ index\.html /) } + it { should contain_file('dir.conf').with_content(/ index\.html\.var /) } + it { should contain_file('dir.conf').with_content(/ index\.cgi /) } + it { should contain_file('dir.conf').with_content(/ index\.pl /) } + it { should contain_file('dir.conf').with_content(/ index\.php /) } + it { should contain_file('dir.conf').with_content(/ index\.xhtml$/) } + end + context "passing indexes => ['example.txt','fearsome.aspx']" do + let :params do + {:indexes => ['example.txt','fearsome.aspx']} + end + it { should contain_file('dir.conf').with_content(/ example\.txt /) } + it { should contain_file('dir.conf').with_content(/ fearsome\.aspx$/) } + end + end + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'Redhat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + context "passing no parameters" do + it { should contain_class("apache::params") } + it { should contain_apache__mod('dir') } + it { should contain_file('dir.conf').with_content(/^DirectoryIndex /) } + it { should contain_file('dir.conf').with_content(/ index\.html /) } + it { should contain_file('dir.conf').with_content(/ index\.html\.var /) } + it { should contain_file('dir.conf').with_content(/ index\.cgi /) } + it { should contain_file('dir.conf').with_content(/ index\.pl /) } + it { should contain_file('dir.conf').with_content(/ index\.php /) } + it { should contain_file('dir.conf').with_content(/ index\.xhtml$/) } + end + context "passing indexes => ['example.txt','fearsome.aspx']" do + let :params do + {:indexes => ['example.txt','fearsome.aspx']} + end + it { should contain_file('dir.conf').with_content(/ example\.txt /) } + it { should contain_file('dir.conf').with_content(/ fearsome\.aspx$/) } + end + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + context "passing no parameters" do + it { should contain_class("apache::params") } + it { should contain_apache__mod('dir') } + it { should contain_file('dir.conf').with_content(/^DirectoryIndex /) } + it { should contain_file('dir.conf').with_content(/ index\.html /) } + it { should contain_file('dir.conf').with_content(/ index\.html\.var /) } + it { should contain_file('dir.conf').with_content(/ index\.cgi /) } + it { should contain_file('dir.conf').with_content(/ index\.pl /) } + it { should contain_file('dir.conf').with_content(/ index\.php /) } + it { should contain_file('dir.conf').with_content(/ index\.xhtml$/) } + end + context "passing indexes => ['example.txt','fearsome.aspx']" do + let :params do + {:indexes => ['example.txt','fearsome.aspx']} + end + it { should contain_file('dir.conf').with_content(/ example\.txt /) } + it { should contain_file('dir.conf').with_content(/ fearsome\.aspx$/) } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/event_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/event_spec.rb new file mode 100644 index 0000000000..850bd5c55b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/event_spec.rb @@ -0,0 +1,103 @@ +require 'spec_helper' + +describe 'apache::mod::event', :type => :class do + let :pre_condition do + 'class { "apache": mpm_module => false, }' + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('event') } + it { should contain_file("/usr/local/etc/apache22/Modules/event.conf").with_ensure('file') } + end + context "on a Debian OS" do + let :facts do + { + :lsbdistcodename => 'squeeze', + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('event') } + it { should contain_file("/etc/apache2/mods-available/event.conf").with_ensure('file') } + it { should contain_file("/etc/apache2/mods-enabled/event.conf").with_ensure('link') } + + context "with Apache version < 2.4" do + let :params do + { + :apache_version => '2.2', + } + end + + it { should_not contain_file("/etc/apache2/mods-available/event.load") } + it { should_not contain_file("/etc/apache2/mods-enabled/event.load") } + + it { should contain_package("apache2-mpm-event") } + end + + context "with Apache version >= 2.4" do + let :params do + { + :apache_version => '2.4', + } + end + + it { should contain_file("/etc/apache2/mods-available/event.load").with({ + 'ensure' => 'file', + 'content' => "LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so\n" + }) + } + it { should contain_file("/etc/apache2/mods-enabled/event.load").with_ensure('link') } + end + end + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + context "with Apache version >= 2.4" do + let :params do + { + :apache_version => '2.4', + } + end + + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('worker') } + it { should_not contain_apache__mod('prefork') } + + it { should contain_file("/etc/httpd/conf.d/event.conf").with_ensure('file') } + + it { should contain_file("/etc/httpd/conf.d/event.load").with({ + 'ensure' => 'file', + 'content' => "LoadModule mpm_event_module modules/mod_mpm_event.so\n", + }) + } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/fastcgi_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/fastcgi_spec.rb new file mode 100644 index 0000000000..98ad2e8706 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/fastcgi_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe 'apache::mod::fastcgi', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('fastcgi') } + it { should contain_package("libapache2-mod-fastcgi") } + it { should contain_file('fastcgi.conf') } + end + + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('fastcgi') } + it { should contain_package("mod_fastcgi") } + it { should_not contain_file('fastcgi.conf') } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/fcgid_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/fcgid_spec.rb new file mode 100644 index 0000000000..16719415d5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/fcgid_spec.rb @@ -0,0 +1,86 @@ +require 'spec_helper' + +describe 'apache::mod::fcgid', :type => :class do + let :pre_condition do + 'include apache' + end + + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('fcgid') } + it { should contain_package("libapache2-mod-fcgid") } + end + + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + describe 'without parameters' do + it { should contain_class("apache::params") } + it { should contain_apache__mod('fcgid') } + it { should contain_package("mod_fcgid") } + end + + describe 'with parameters' do + let :params do { + :options => { + 'FcgidIPCDir' => '/var/run/fcgidsock', + 'SharememPath' => '/var/run/fcgid_shm', + 'FcgidMinProcessesPerClass' => '0', + 'AddHandler' => 'fcgid-script .fcgi', + } + } end + + it 'should contain the correct config' do + content = subject.resource('file', 'fcgid.conf').send(:parameters)[:content] + content.split("\n").reject { |c| c =~ /(^#|^$)/ }.should == [ + '', + ' AddHandler fcgid-script .fcgi', + ' FcgidIPCDir /var/run/fcgidsock', + ' FcgidMinProcessesPerClass 0', + ' SharememPath /var/run/fcgid_shm', + '', + ] + end + end + end + + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + it { should contain_class("apache::params") } + it { should contain_apache__mod('fcgid') } + it { should contain_package("www/mod_fcgid") } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/info_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/info_spec.rb new file mode 100644 index 0000000000..ed078c519f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/info_spec.rb @@ -0,0 +1,119 @@ +require 'spec_helper' + +# This function is called inside the OS specific contexts +def general_info_specs + it { should contain_apache__mod("info") } + + it do + should contain_file("info.conf").with_content( + "\n"\ + " SetHandler server-info\n"\ + " Order deny,allow\n"\ + " Deny from all\n"\ + " Allow from 127.0.0.1 ::1\n"\ + "\n" + ) + end +end + +describe 'apache::mod::info', :type => :class do + let :pre_condition do + 'include apache' + end + + context "On a Debian OS with default params" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + # Load the more generic tests for this context + general_info_specs() + + it { should contain_file("info.conf").with({ + :ensure => 'file', + :path => '/etc/apache2/mods-available/info.conf', + } ) } + it { should contain_file("info.conf symlink").with({ + :ensure => 'link', + :path => '/etc/apache2/mods-enabled/info.conf', + } ) } + end + + context "on a RedHat OS with default params" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + # Load the more generic tests for this context + general_info_specs() + + it { should contain_file("info.conf").with_path("/etc/httpd/conf.d/info.conf") } + end + + context "On a FreeBSD OS with default params" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + # Load the more generic tests for this context + general_info_specs() + + it { should contain_file("info.conf").with({ + :ensure => 'file', + :path => '/usr/local/etc/apache22/Modules/info.conf', + } ) } + end + + context "with $allow_from => ['10.10.10.10','11.11.11.11']" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + let :params do + { :allow_from => ['10.10.10.10','11.11.11.11'] } + end + it do + should contain_file("info.conf").with_content( + "\n"\ + " SetHandler server-info\n"\ + " Order deny,allow\n"\ + " Deny from all\n"\ + " Allow from 10.10.10.10 11.11.11.11\n"\ + "\n" + ) + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/itk_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/itk_spec.rb new file mode 100644 index 0000000000..d9fe2e3d12 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/itk_spec.rb @@ -0,0 +1,69 @@ +require 'spec_helper' + +describe 'apache::mod::itk', :type => :class do + let :pre_condition do + 'class { "apache": mpm_module => false, }' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('itk') } + it { should contain_file("/etc/apache2/mods-available/itk.conf").with_ensure('file') } + it { should contain_file("/etc/apache2/mods-enabled/itk.conf").with_ensure('link') } + + context "with Apache version < 2.4" do + let :params do + { + :apache_version => '2.2', + } + end + + it { should_not contain_file("/etc/apache2/mods-available/itk.load") } + it { should_not contain_file("/etc/apache2/mods-enabled/itk.load") } + + it { should contain_package("apache2-mpm-itk") } + end + + context "with Apache version >= 2.4" do + let :params do + { + :apache_version => '2.4', + } + end + + it { should contain_file("/etc/apache2/mods-available/itk.load").with({ + 'ensure' => 'file', + 'content' => "LoadModule mpm_itk_module /usr/lib/apache2/modules/mod_mpm_itk.so\n" + }) + } + it { should contain_file("/etc/apache2/mods-enabled/itk.load").with_ensure('link') } + end + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('itk') } + it { should contain_file("/usr/local/etc/apache22/Modules/itk.conf").with_ensure('file') } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/mime_magic_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/mime_magic_spec.rb new file mode 100644 index 0000000000..e9984ecbaf --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/mime_magic_spec.rb @@ -0,0 +1,109 @@ +require 'spec_helper' + +# This function is called inside the OS specific contexts +def general_mime_magic_specs + it { should contain_apache__mod("mime_magic") } +end + +describe 'apache::mod::mime_magic', :type => :class do + let :pre_condition do + 'include apache' + end + + context "On a Debian OS with default params" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + general_mime_magic_specs() + + it do + should contain_file("mime_magic.conf").with_content( + "MIMEMagicFile \"/etc/apache2/magic\"\n" + ) + end + + it { should contain_file("mime_magic.conf").with({ + :ensure => 'file', + :path => '/etc/apache2/mods-available/mime_magic.conf', + } ) } + it { should contain_file("mime_magic.conf symlink").with({ + :ensure => 'link', + :path => '/etc/apache2/mods-enabled/mime_magic.conf', + } ) } + + context "with magic_file => /tmp/Debian_magic" do + let :params do + { :magic_file => "/tmp/Debian_magic" } + end + + it do + should contain_file("mime_magic.conf").with_content( + "MIMEMagicFile \"/tmp/Debian_magic\"\n" + ) + end + end + + end + + context "on a RedHat OS with default params" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + general_mime_magic_specs() + + it do + should contain_file("mime_magic.conf").with_content( + "MIMEMagicFile \"/etc/httpd/conf/magic\"\n" + ) + end + + it { should contain_file("mime_magic.conf").with_path("/etc/httpd/conf.d/mime_magic.conf") } + + end + + context "with magic_file => /tmp/magic" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + let :params do + { :magic_file => "/tmp/magic" } + end + + it do + should contain_file("mime_magic.conf").with_content( + "MIMEMagicFile \"/tmp/magic\"\n" + ) + end + end + + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/mime_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/mime_spec.rb new file mode 100644 index 0000000000..2b6154fb81 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/mime_spec.rb @@ -0,0 +1,52 @@ +require 'spec_helper' + +# This function is called inside the OS specific conte, :compilexts +def general_mime_specs + it { should contain_apache__mod("mime") } +end + +describe 'apache::mod::mime', :type => :class do + let :pre_condition do + 'include apache' + end + + context "On a Debian OS with default params", :compile do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + general_mime_specs() + + it { should contain_file("mime.conf").with_path('/etc/apache2/mods-available/mime.conf') } + + end + + context "on a RedHat OS with default params", :compile do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + general_mime_specs() + + it { should contain_file("mime.conf").with_path("/etc/httpd/conf.d/mime.conf") } + + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/pagespeed_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/pagespeed_spec.rb new file mode 100644 index 0000000000..9439f719e6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/pagespeed_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe 'apache::mod::pagespeed', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('pagespeed') } + it { should contain_package("mod-pagespeed-stable") } + it { should contain_file('pagespeed.conf') } + end + + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('pagespeed') } + it { should contain_package("mod-pagespeed-stable") } + it { should contain_file('pagespeed.conf') } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/passenger_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/passenger_spec.rb new file mode 100644 index 0000000000..3bf7d29952 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/passenger_spec.rb @@ -0,0 +1,230 @@ +require 'spec_helper' + +describe 'apache::mod::passenger', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('passenger') } + it { should contain_package("libapache2-mod-passenger") } + it { should contain_file('passenger.load').with({ + 'path' => '/etc/apache2/mods-available/passenger.load', + }) } + it { should contain_file('passenger.conf').with({ + 'path' => '/etc/apache2/mods-available/passenger.conf', + }) } + it { should contain_file('passenger_package.conf').with_ensure('absent') } + describe "with passenger_root => '/usr/lib/example'" do + let :params do + { :passenger_root => '/usr/lib/example' } + end + it { should contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr/lib/example"}) } + end + describe "with passenger_ruby => /usr/lib/example/ruby" do + let :params do + { :passenger_ruby => '/usr/lib/example/ruby' } + end + it { should contain_file('passenger.conf').with_content(%r{PassengerRuby "/usr/lib/example/ruby"}) } + end + describe "with passenger_default_ruby => /usr/lib/example/ruby1.9.3" do + let :params do + { :passenger_ruby => '/usr/lib/example/ruby1.9.3' } + end + it { should contain_file('passenger.conf').with_content(%r{PassengerRuby "/usr/lib/example/ruby1.9.3"}) } + end + describe "with passenger_high_performance => on" do + let :params do + { :passenger_high_performance => 'on' } + end + it { should contain_file('passenger.conf').with_content(/^ PassengerHighPerformance on$/) } + end + describe "with passenger_pool_idle_time => 1200" do + let :params do + { :passenger_pool_idle_time => 1200 } + end + it { should contain_file('passenger.conf').with_content(/^ PassengerPoolIdleTime 1200$/) } + end + describe "with passenger_max_requests => 20" do + let :params do + { :passenger_max_requests => 20 } + end + it { should contain_file('passenger.conf').with_content(/^ PassengerMaxRequests 20$/) } + end + describe "with passenger_stat_throttle_rate => 10" do + let :params do + { :passenger_stat_throttle_rate => 10 } + end + it { should contain_file('passenger.conf').with_content(/^ PassengerStatThrottleRate 10$/) } + end + describe "with passenger_max_pool_size => 16" do + let :params do + { :passenger_max_pool_size => 16 } + end + it { should contain_file('passenger.conf').with_content(/^ PassengerMaxPoolSize 16$/) } + end + describe "with rack_autodetect => on" do + let :params do + { :rack_autodetect => 'on' } + end + it { should contain_file('passenger.conf').with_content(/^ RackAutoDetect on$/) } + end + describe "with rails_autodetect => on" do + let :params do + { :rails_autodetect => 'on' } + end + it { should contain_file('passenger.conf').with_content(/^ RailsAutoDetect on$/) } + end + describe "with passenger_use_global_queue => on" do + let :params do + { :passenger_use_global_queue => 'on' } + end + it { should contain_file('passenger.conf').with_content(/^ PassengerUseGlobalQueue on$/) } + end + describe "with mod_path => '/usr/lib/foo/mod_foo.so'" do + let :params do + { :mod_path => '/usr/lib/foo/mod_foo.so' } + end + it { should contain_file('passenger.load').with_content(/^LoadModule passenger_module \/usr\/lib\/foo\/mod_foo\.so$/) } + end + describe "with mod_lib_path => '/usr/lib/foo'" do + let :params do + { :mod_lib_path => '/usr/lib/foo' } + end + it { should contain_file('passenger.load').with_content(/^LoadModule passenger_module \/usr\/lib\/foo\/mod_passenger\.so$/) } + end + describe "with mod_lib => 'mod_foo.so'" do + let :params do + { :mod_lib => 'mod_foo.so' } + end + it { should contain_file('passenger.load').with_content(/^LoadModule passenger_module \/usr\/lib\/apache2\/modules\/mod_foo\.so$/) } + end + describe "with mod_id => 'mod_foo'" do + let :params do + { :mod_id => 'mod_foo' } + end + it { should contain_file('passenger.load').with_content(/^LoadModule mod_foo \/usr\/lib\/apache2\/modules\/mod_passenger\.so$/) } + end + + context "with Ubuntu 12.04 defaults" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '12.04', + :operatingsystem => 'Ubuntu', + :lsbdistrelease => '12.04', + :concat_basedir => '/dne', + :id => 'root', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + it { should contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr"}) } + it { should contain_file('passenger.conf').with_content(%r{PassengerRuby "/usr/bin/ruby"}) } + it { should contain_file('passenger.conf').without_content(/PassengerDefaultRuby/) } + end + + context "with Ubuntu 14.04 defaults" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '14.04', + :operatingsystem => 'Ubuntu', + :lsbdistrelease => '14.04', + :concat_basedir => '/dne', + :id => 'root', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + it { should contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini"}) } + it { should contain_file('passenger.conf').without_content(/PassengerRuby/) } + it { should contain_file('passenger.conf').with_content(%r{PassengerDefaultRuby "/usr/bin/ruby"}) } + end + + context "with Debian 7 defaults" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '7.3', + :operatingsystem => 'Debian', + :lsbdistcodename => 'wheezy', + :concat_basedir => '/dne', + :id => 'root', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + it { should contain_file('passenger.conf').with_content(%r{PassengerRoot "/usr"}) } + it { should contain_file('passenger.conf').with_content(%r{PassengerRuby "/usr/bin/ruby"}) } + it { should contain_file('passenger.conf').without_content(/PassengerDefaultRuby/) } + end + end + + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('passenger') } + it { should contain_package("mod_passenger") } + it { should contain_file('passenger_package.conf').with({ + 'path' => '/etc/httpd/conf.d/passenger.conf', + }) } + it { should contain_file('passenger_package.conf').without_content } + it { should contain_file('passenger_package.conf').without_source } + it { should contain_file('passenger.load').with({ + 'path' => '/etc/httpd/conf.d/passenger.load', + }) } + it { should contain_file('passenger.conf').without_content(/PassengerRoot/) } + it { should contain_file('passenger.conf').without_content(/PassengerRuby/) } + describe "with passenger_root => '/usr/lib/example'" do + let :params do + { :passenger_root => '/usr/lib/example' } + end + it { should contain_file('passenger.conf').with_content(/^ PassengerRoot "\/usr\/lib\/example"$/) } + end + describe "with passenger_ruby => /usr/lib/example/ruby" do + let :params do + { :passenger_ruby => '/usr/lib/example/ruby' } + end + it { should contain_file('passenger.conf').with_content(/^ PassengerRuby "\/usr\/lib\/example\/ruby"$/) } + end + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('passenger') } + it { should contain_package("www/rubygem-passenger") } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/perl_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/perl_spec.rb new file mode 100644 index 0000000000..f674318e28 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/perl_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe 'apache::mod::perl', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('perl') } + it { should contain_package("libapache2-mod-perl2") } + end + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('perl') } + it { should contain_package("mod_perl") } + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('perl') } + it { should contain_package("www/mod_perl2") } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/peruser_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/peruser_spec.rb new file mode 100644 index 0000000000..e1ee004e93 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/peruser_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe 'apache::mod::peruser', :type => :class do + let :pre_condition do + 'class { "apache": mpm_module => false, }' + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('peruser') } + it { should contain_file("/usr/local/etc/apache22/Modules/peruser.conf").with_ensure('file') } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/php_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/php_spec.rb new file mode 100644 index 0000000000..e42f4fcfe4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/php_spec.rb @@ -0,0 +1,224 @@ +require 'spec_helper' + +describe 'apache::mod::php', :type => :class do + describe "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + context "with mpm_module => prefork" do + let :pre_condition do + 'class { "apache": mpm_module => prefork, }' + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('php5') } + it { should contain_package("libapache2-mod-php5") } + it { should contain_file("php5.load").with( + :content => "LoadModule php5_module /usr/lib/apache2/modules/libphp5.so\n" + ) } + end + context 'with mpm_module => worker' do + let :pre_condition do + 'class { "apache": mpm_module => worker, }' + end + it 'should raise an error' do + expect { subject }.to raise_error Puppet::Error, /mpm_module => 'prefork'/ + end + end + end + describe "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + context "with default params" do + let :pre_condition do + 'class { "apache": }' + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('php5') } + it { should contain_package("php") } + it { should contain_file("php5.load").with( + :content => "LoadModule php5_module modules/libphp5.so\n" + ) } + end + context "with alternative package name" do let :pre_condition do + 'class { "apache": }' + end + let :params do + { :package_name => 'php54'} + end + it { should contain_package("php54") } + end + context "with alternative path" do let :pre_condition do + 'class { "apache": }' + end + let :params do + { :path => 'alternative-path'} + end + it { should contain_file("php5.load").with( + :content => "LoadModule php5_module alternative-path\n" + ) } + end + context "with alternative extensions" do let :pre_condition do + 'class { "apache": }' + end + let :params do + { :extensions => ['.php','.php5']} + end + it { should contain_file("php5.conf").with_content(/AddHandler php5-script .php .php5\n/) } + end + context "with specific version" do + let :pre_condition do + 'class { "apache": }' + end + let :params do + { :package_ensure => '5.3.13'} + end + it { should contain_package("php").with( + :ensure => '5.3.13' + ) } + end + context "with mpm_module => prefork" do + let :pre_condition do + 'class { "apache": mpm_module => prefork, }' + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('php5') } + it { should contain_package("php") } + it { should contain_file("php5.load").with( + :content => "LoadModule php5_module modules/libphp5.so\n" + ) } + end + end + describe "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + context "with mpm_module => prefork" do + let :pre_condition do + 'class { "apache": mpm_module => prefork, }' + end + it { should contain_class('apache::params') } + it { should contain_apache__mod('php5') } + it { should contain_package("lang/php5") } + it { should contain_file('php5.load') } + end + # FIXME: not sure about the following context + context 'with mpm_module => worker' do + let :pre_condition do + 'class { "apache": mpm_module => worker, }' + end + it 'should raise an error' do + expect { subject.should contain_apache__mod('php5') }.to raise_error Puppet::Error, /mpm_module => 'prefork'/ + end + end + end + describe "OS independent tests" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + } + end + context 'with content param' do + let :pre_condition do + 'class { "apache": mpm_module => prefork, }' + end + let :params do + { :content => 'somecontent' } + end + it { should contain_file('php5.conf').with( + :content => 'somecontent' + ) } + end + context 'with template param' do + let :pre_condition do + 'class { "apache": mpm_module => prefork, }' + end + let :params do + { :template => 'apache/mod/php5.conf.erb' } + end + it { should contain_file('php5.conf').with( + :content => /^# PHP is an HTML-embedded scripting language which attempts to make it/ + ) } + end + context 'with source param' do + let :pre_condition do + 'class { "apache": mpm_module => prefork, }' + end + let :params do + { :source => 'some-path' } + end + it { should contain_file('php5.conf').with( + :source => 'some-path' + ) } + end + context 'content has priority over template' do + let :pre_condition do + 'class { "apache": mpm_module => prefork, }' + end + let :params do + { + :template => 'apache/mod/php5.conf.erb', + :content => 'somecontent' + } + end + it { should contain_file('php5.conf').with( + :content => 'somecontent' + ) } + end + context 'source has priority over template' do + let :pre_condition do + 'class { "apache": mpm_module => prefork, }' + end + let :params do + { + :template => 'apache/mod/php5.conf.erb', + :source => 'some-path' + } + end + it { should contain_file('php5.conf').with( + :source => 'some-path' + ) } + end + context 'source has priority over content' do + let :pre_condition do + 'class { "apache": mpm_module => prefork, }' + end + let :params do + { + :content => 'somecontent', + :source => 'some-path' + } + end + it { should contain_file('php5.conf').with( + :source => 'some-path' + ) } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/prefork_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/prefork_spec.rb new file mode 100644 index 0000000000..847aecf9c7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/prefork_spec.rb @@ -0,0 +1,114 @@ +require 'spec_helper' + +describe 'apache::mod::prefork', :type => :class do + let :pre_condition do + 'class { "apache": mpm_module => false, }' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('prefork') } + it { should contain_file("/etc/apache2/mods-available/prefork.conf").with_ensure('file') } + it { should contain_file("/etc/apache2/mods-enabled/prefork.conf").with_ensure('link') } + + context "with Apache version < 2.4" do + let :params do + { + :apache_version => '2.2', + } + end + + it { should_not contain_file("/etc/apache2/mods-available/prefork.load") } + it { should_not contain_file("/etc/apache2/mods-enabled/prefork.load") } + + it { should contain_package("apache2-mpm-prefork") } + end + + context "with Apache version >= 2.4" do + let :params do + { + :apache_version => '2.4', + } + end + + it { should contain_file("/etc/apache2/mods-available/prefork.load").with({ + 'ensure' => 'file', + 'content' => "LoadModule mpm_prefork_module /usr/lib/apache2/modules/mod_mpm_prefork.so\n" + }) + } + it { should contain_file("/etc/apache2/mods-enabled/prefork.load").with_ensure('link') } + end + end + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('prefork') } + it { should contain_file("/etc/httpd/conf.d/prefork.conf").with_ensure('file') } + + context "with Apache version < 2.4" do + let :params do + { + :apache_version => '2.2', + } + end + + it { should contain_file_line("/etc/sysconfig/httpd prefork enable").with({ + 'require' => 'Package[httpd]', + }) + } + end + + context "with Apache version >= 2.4" do + let :params do + { + :apache_version => '2.4', + } + end + + it { should_not contain_apache__mod('event') } + + it { should contain_file("/etc/httpd/conf.d/prefork.load").with({ + 'ensure' => 'file', + 'content' => "LoadModule mpm_prefork_module modules/mod_mpm_prefork.so\n", + }) + } + end + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('prefork') } + it { should contain_file("/usr/local/etc/apache22/Modules/prefork.conf").with_ensure('file') } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/proxy_html_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/proxy_html_spec.rb new file mode 100644 index 0000000000..77e1ab15de --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/proxy_html_spec.rb @@ -0,0 +1,85 @@ +require 'spec_helper' + +describe 'apache::mod::proxy_html', :type => :class do + let :pre_condition do + [ + 'include apache', + 'include apache::mod::proxy', + 'include apache::mod::proxy_http', + ] + end + context "on a Debian OS" do + shared_examples "debian" do |loadfiles| + it { should contain_class("apache::params") } + it { should contain_apache__mod('proxy_html').with(:loadfiles => loadfiles) } + it { should contain_package("libapache2-mod-proxy-html") } + end + let :facts do + { + :osfamily => 'Debian', + :concat_basedir => '/dne', + :architecture => 'i386', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :hardwaremodel => 'i386', + } + end + + context "on squeeze" do + let(:facts) { super().merge({ :operatingsystemrelease => '6' }) } + it_behaves_like "debian", ['/usr/lib/libxml2.so.2'] + end + context "on wheezy" do + let(:facts) { super().merge({ :operatingsystemrelease => '7' }) } + context "i386" do + let(:facts) { super().merge({ + :hardwaremodel => 'i686', + :architecture => 'i386' + })} + it_behaves_like "debian", ["/usr/lib/i386-linux-gnu/libxml2.so.2"] + end + context "x64" do + let(:facts) { super().merge({ + :hardwaremodel => 'x86_64', + :architecture => 'amd64' + })} + it_behaves_like "debian", ["/usr/lib/x86_64-linux-gnu/libxml2.so.2"] + end + end + end + context "on a RedHat OS", :compile do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('proxy_html').with(:loadfiles => nil) } + it { should contain_package("mod_proxy_html") } + end + context "on a FreeBSD OS", :compile do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('proxy_html').with(:loadfiles => nil) } + it { should contain_package("www/mod_proxy_html") } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/python_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/python_spec.rb new file mode 100644 index 0000000000..d2d1fca7b9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/python_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe 'apache::mod::python', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod("python") } + it { should contain_package("libapache2-mod-python") } + end + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod("python") } + it { should contain_package("mod_python") } + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod("python") } + it { should contain_package("www/mod_python3") } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/rpaf_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/rpaf_spec.rb new file mode 100644 index 0000000000..949dd5702b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/rpaf_spec.rb @@ -0,0 +1,88 @@ +require 'spec_helper' + +describe 'apache::mod::rpaf', :type => :class do + let :pre_condition do + [ + 'include apache', + ] + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('rpaf') } + it { should contain_package("libapache2-mod-rpaf") } + it { should contain_file('rpaf.conf').with({ + 'path' => '/etc/apache2/mods-available/rpaf.conf', + }) } + it { should contain_file('rpaf.conf').with_content(/^RPAFenable On$/) } + + describe "with sethostname => true" do + let :params do + { :sethostname => 'true' } + end + it { should contain_file('rpaf.conf').with_content(/^RPAFsethostname On$/) } + end + describe "with proxy_ips => [ 10.42.17.8, 10.42.18.99 ]" do + let :params do + { :proxy_ips => [ '10.42.17.8', '10.42.18.99' ] } + end + it { should contain_file('rpaf.conf').with_content(/^RPAFproxy_ips 10.42.17.8 10.42.18.99$/) } + end + describe "with header => X-Real-IP" do + let :params do + { :header => 'X-Real-IP' } + end + it { should contain_file('rpaf.conf').with_content(/^RPAFheader X-Real-IP$/) } + end + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('rpaf') } + it { should contain_package("www/mod_rpaf2") } + it { should contain_file('rpaf.conf').with({ + 'path' => '/usr/local/etc/apache22/Modules/rpaf.conf', + }) } + it { should contain_file('rpaf.conf').with_content(/^RPAFenable On$/) } + + describe "with sethostname => true" do + let :params do + { :sethostname => 'true' } + end + it { should contain_file('rpaf.conf').with_content(/^RPAFsethostname On$/) } + end + describe "with proxy_ips => [ 10.42.17.8, 10.42.18.99 ]" do + let :params do + { :proxy_ips => [ '10.42.17.8', '10.42.18.99' ] } + end + it { should contain_file('rpaf.conf').with_content(/^RPAFproxy_ips 10.42.17.8 10.42.18.99$/) } + end + describe "with header => X-Real-IP" do + let :params do + { :header => 'X-Real-IP' } + end + it { should contain_file('rpaf.conf').with_content(/^RPAFheader X-Real-IP$/) } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/speling_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/speling_spec.rb new file mode 100644 index 0000000000..e7e6e1d640 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/speling_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe 'apache::mod::speling', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_apache__mod('speling') } + end + + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_apache__mod('speling') } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/ssl_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/ssl_spec.rb new file mode 100644 index 0000000000..11e7964ded --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/ssl_spec.rb @@ -0,0 +1,72 @@ +require 'spec_helper' + +describe 'apache::mod::ssl', :type => :class do + let :pre_condition do + 'include apache' + end + context 'on an unsupported OS' do + let :facts do + { + :osfamily => 'Magic', + :operatingsystemrelease => '0', + :concat_basedir => '/dne', + :operatingsystem => 'Magic', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { expect { subject }.to raise_error(Puppet::Error, /Unsupported osfamily:/) } + end + + context 'on a RedHat OS' do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class('apache::params') } + it { should contain_apache__mod('ssl') } + it { should contain_package('mod_ssl') } + end + + context 'on a Debian OS' do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class('apache::params') } + it { should contain_apache__mod('ssl') } + it { should_not contain_package('libapache2-mod-ssl') } + end + + context 'on a FreeBSD OS' do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class('apache::params') } + it { should contain_apache__mod('ssl') } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/status_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/status_spec.rb new file mode 100644 index 0000000000..5023bc7bf1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/status_spec.rb @@ -0,0 +1,198 @@ +require 'spec_helper' + +# Helper function for testing the contents of `status.conf` +def status_conf_spec(allow_from, extended_status) + it do + should contain_file("status.conf").with_content( + "\n"\ + " SetHandler server-status\n"\ + " Order deny,allow\n"\ + " Deny from all\n"\ + " Allow from #{Array(allow_from).join(' ')}\n"\ + "\n"\ + "ExtendedStatus #{extended_status}\n"\ + "\n"\ + "\n"\ + " # Show Proxy LoadBalancer status in mod_status\n"\ + " ProxyStatus On\n"\ + "\n" + ) + end +end + +describe 'apache::mod::status', :type => :class do + let :pre_condition do + 'include apache' + end + + context "on a Debian OS with default params" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + it { should contain_apache__mod("status") } + + status_conf_spec(["127.0.0.1", "::1"], "On") + + it { should contain_file("status.conf").with({ + :ensure => 'file', + :path => '/etc/apache2/mods-available/status.conf', + } ) } + + it { should contain_file("status.conf symlink").with({ + :ensure => 'link', + :path => '/etc/apache2/mods-enabled/status.conf', + } ) } + + end + + context "on a RedHat OS with default params" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + it { should contain_apache__mod("status") } + + status_conf_spec(["127.0.0.1", "::1"], "On") + + it { should contain_file("status.conf").with_path("/etc/httpd/conf.d/status.conf") } + + end + + context "with custom parameters $allow_from => ['10.10.10.10','11.11.11.11'], $extended_status => 'Off'" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + let :params do + { + :allow_from => ['10.10.10.10','11.11.11.11'], + :extended_status => 'Off', + } + end + + status_conf_spec(["10.10.10.10", "11.11.11.11"], "Off") + + end + + context "with valid parameter type $allow_from => ['10.10.10.10']" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + let :params do + { :allow_from => ['10.10.10.10'] } + end + it 'should expect to succeed array validation' do + expect { + should contain_file("status.conf") + }.not_to raise_error() + end + end + + context "with invalid parameter type $allow_from => '10.10.10.10'" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + let :params do + { :allow_from => '10.10.10.10' } + end + it 'should expect to fail array validation' do + expect { + should contain_file("status.conf") + }.to raise_error(Puppet::Error) + end + end + + # Only On or Off are valid options + ['On', 'Off'].each do |valid_param| + context "with valid value $extended_status => '#{valid_param}'" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + let :params do + { :extended_status => valid_param } + end + it 'should expect to succeed regular expression validation' do + expect { + should contain_file("status.conf") + }.not_to raise_error() + end + end + end + + ['Yes', 'No'].each do |invalid_param| + context "with invalid value $extended_status => '#{invalid_param}'" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + let :params do + { :extended_status => invalid_param } + end + it 'should expect to fail regular expression validation' do + expect { + should contain_file("status.conf") + }.to raise_error(Puppet::Error) + end + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/suphp_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/suphp_spec.rb new file mode 100644 index 0000000000..cb91997ac1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/suphp_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe 'apache::mod::suphp', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_package("libapache2-mod-suphp") } + end + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_package("mod_suphp") } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/worker_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/worker_spec.rb new file mode 100644 index 0000000000..4843a26e65 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/worker_spec.rb @@ -0,0 +1,161 @@ +require 'spec_helper' + +describe 'apache::mod::worker', :type => :class do + let :pre_condition do + 'class { "apache": mpm_module => false, }' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('worker') } + it { should contain_file("/etc/apache2/mods-available/worker.conf").with_ensure('file') } + it { should contain_file("/etc/apache2/mods-enabled/worker.conf").with_ensure('link') } + + context "with Apache version < 2.4" do + let :params do + { + :apache_version => '2.2', + } + end + + it { should_not contain_file("/etc/apache2/mods-available/worker.load") } + it { should_not contain_file("/etc/apache2/mods-enabled/worker.load") } + + it { should contain_package("apache2-mpm-worker") } + end + + context "with Apache version >= 2.4" do + let :params do + { + :apache_version => '2.4', + } + end + + it { should contain_file("/etc/apache2/mods-available/worker.load").with({ + 'ensure' => 'file', + 'content' => "LoadModule mpm_worker_module /usr/lib/apache2/modules/mod_mpm_worker.so\n" + }) + } + it { should contain_file("/etc/apache2/mods-enabled/worker.load").with_ensure('link') } + end + end + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('worker') } + it { should contain_file("/etc/httpd/conf.d/worker.conf").with_ensure('file') } + + context "with Apache version < 2.4" do + let :params do + { + :apache_version => '2.2', + } + end + + it { should contain_file_line("/etc/sysconfig/httpd worker enable").with({ + 'require' => 'Package[httpd]', + }) + } + end + + context "with Apache version >= 2.4" do + let :params do + { + :apache_version => '2.4', + } + end + + it { should_not contain_apache__mod('event') } + + it { should contain_file("/etc/httpd/conf.d/worker.load").with({ + 'ensure' => 'file', + 'content' => "LoadModule mpm_worker_module modules/mod_mpm_worker.so\n", + }) + } + end + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should_not contain_apache__mod('worker') } + it { should contain_file("/usr/local/etc/apache22/Modules/worker.conf").with_ensure('file') } + end + + # Template config doesn't vary by distro + context "on all distros" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + } + end + + context 'defaults' do + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+ServerLimit\s+25$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+StartServers\s+2$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+MaxClients\s+150$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+MinSpareThreads\s+25$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+MaxSpareThreads\s+75$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+ThreadsPerChild\s+25$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+MaxRequestsPerChild\s+0$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+ThreadLimit\s+64$/) } + end + + context 'setting params' do + let :params do + { + :serverlimit => 10, + :startservers => 11, + :maxclients => 12, + :minsparethreads => 13, + :maxsparethreads => 14, + :threadsperchild => 15, + :maxrequestsperchild => 16, + :threadlimit => 17 + } + end + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+ServerLimit\s+10$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+StartServers\s+11$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+MaxClients\s+12$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+MinSpareThreads\s+13$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+MaxSpareThreads\s+14$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+ThreadsPerChild\s+15$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+MaxRequestsPerChild\s+16$/) } + it { should contain_file('/etc/httpd/conf.d/worker.conf').with(:content => /^\s+ThreadLimit\s+17$/) } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/wsgi_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/wsgi_spec.rb new file mode 100644 index 0000000000..d4c391a291 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/mod/wsgi_spec.rb @@ -0,0 +1,69 @@ +require 'spec_helper' + +describe 'apache::mod::wsgi', :type => :class do + let :pre_condition do + 'include apache' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('wsgi') } + it { should contain_package("libapache2-mod-wsgi") } + end + context "on a RedHat OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('wsgi') } + it { should contain_package("mod_wsgi") } + + describe "with custom WSGISocketPrefix" do + let :params do + { :wsgi_socket_prefix => 'run/wsgi' } + end + it {should contain_file('wsgi.conf').with_content(/^ WSGISocketPrefix run\/wsgi$/)} + end + describe "with custom WSGIPythonHome" do + let :params do + { :wsgi_python_home => '/path/to/virtenv' } + end + it {should contain_file('wsgi.conf').with_content(/^ WSGIPythonHome "\/path\/to\/virtenv"$/)} + end + end + context "on a FreeBSD OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_class("apache::params") } + it { should contain_apache__mod('wsgi') } + it { should contain_package("www/mod_wsgi") } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/params_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/params_spec.rb new file mode 100644 index 0000000000..eaa178c41d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/params_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe 'apache::params', :type => :class do + context "On a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_apache__params } + + # There are 4 resources in this class currently + # there should not be any more resources because it is a params class + # The resources are class[apache::version], class[apache::params], class[main], class[settings], stage[main] + it "Should not contain any resources" do + subject.resources.size.should == 5 + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/service_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/service_spec.rb new file mode 100644 index 0000000000..2cd075357d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/classes/service_spec.rb @@ -0,0 +1,127 @@ +require 'spec_helper' + +describe 'apache::service', :type => :class do + let :pre_condition do + 'include apache::params' + end + context "on a Debian OS" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_service("httpd").with( + 'name' => 'apache2', + 'ensure' => 'running', + 'enable' => 'true' + ) + } + + context "with $service_name => 'foo'" do + let (:params) {{ :service_name => 'foo' }} + it { should contain_service("httpd").with( + 'name' => 'foo' + ) + } + end + + context "with $service_enable => true" do + let (:params) {{ :service_enable => true }} + it { should contain_service("httpd").with( + 'name' => 'apache2', + 'ensure' => 'running', + 'enable' => 'true' + ) + } + end + + context "with $service_enable => false" do + let (:params) {{ :service_enable => false }} + it { should contain_service("httpd").with( + 'name' => 'apache2', + 'ensure' => 'running', + 'enable' => 'false' + ) + } + end + + context "$service_enable must be a bool" do + let (:params) {{ :service_enable => 'not-a-boolean' }} + + it 'should fail' do + expect { subject }.to raise_error(Puppet::Error, /is not a boolean/) + end + end + + context "with $service_ensure => 'running'" do + let (:params) {{ :service_ensure => 'running', }} + it { should contain_service("httpd").with( + 'ensure' => 'running', + 'enable' => 'true' + ) + } + end + + context "with $service_ensure => 'stopped'" do + let (:params) {{ :service_ensure => 'stopped', }} + it { should contain_service("httpd").with( + 'ensure' => 'stopped', + 'enable' => 'true' + ) + } + end + + context "with $service_ensure => 'UNDEF'" do + let (:params) {{ :service_ensure => 'UNDEF' }} + it { should contain_service("httpd").without_ensure } + end + end + + + context "on a RedHat 5 OS" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '5', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_service("httpd").with( + 'name' => 'httpd', + 'ensure' => 'running', + 'enable' => 'true' + ) + } + end + + context "on a FreeBSD 5 OS" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + it { should contain_service("httpd").with( + 'name' => 'apache22', + 'ensure' => 'running', + 'enable' => 'true' + ) + } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/defines/mod_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/defines/mod_spec.rb new file mode 100644 index 0000000000..e6d5214097 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/defines/mod_spec.rb @@ -0,0 +1,118 @@ +require 'spec_helper' + +describe 'apache::mod', :type => :define do + let :pre_condition do + 'include apache' + end + context "on a RedHat osfamily" do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + describe "for non-special modules" do + let :title do + 'spec_m' + end + it { should contain_class("apache::params") } + it "should manage the module load file" do + should contain_file('spec_m.load').with({ + :path => '/etc/httpd/conf.d/spec_m.load', + :content => "LoadModule spec_m_module modules/mod_spec_m.so\n", + :owner => 'root', + :group => 'root', + :mode => '0644', + } ) + end + end + + describe "with shibboleth module and package param passed" do + # name/title for the apache::mod define + let :title do + 'xsendfile' + end + # parameters + let(:params) { {:package => 'mod_xsendfile'} } + + it { should contain_class("apache::params") } + it { should contain_package('mod_xsendfile') } + end + end + + context "on a Debian osfamily" do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + describe "for non-special modules" do + let :title do + 'spec_m' + end + it { should contain_class("apache::params") } + it "should manage the module load file" do + should contain_file('spec_m.load').with({ + :path => '/etc/apache2/mods-available/spec_m.load', + :content => "LoadModule spec_m_module /usr/lib/apache2/modules/mod_spec_m.so\n", + :owner => 'root', + :group => 'root', + :mode => '0644', + } ) + end + it "should link the module load file" do + should contain_file('spec_m.load symlink').with({ + :path => '/etc/apache2/mods-enabled/spec_m.load', + :target => '/etc/apache2/mods-available/spec_m.load', + :owner => 'root', + :group => 'root', + :mode => '0644', + } ) + end + end + end + + context "on a FreeBSD osfamily" do + let :facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + + describe "for non-special modules" do + let :title do + 'spec_m' + end + it { should contain_class("apache::params") } + it "should manage the module load file" do + should contain_file('spec_m.load').with({ + :path => '/usr/local/etc/apache22/Modules/spec_m.load', + :content => "LoadModule spec_m_module /usr/local/libexec/apache22/mod_spec_m.so\n", + :owner => 'root', + :group => 'wheel', + :mode => '0644', + } ) + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/defines/vhost_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/defines/vhost_spec.rb new file mode 100644 index 0000000000..4037b3011c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/defines/vhost_spec.rb @@ -0,0 +1,1469 @@ +require 'spec_helper' + +describe 'apache::vhost', :type => :define do + let :pre_condition do + 'class { "apache": default_vhost => false, }' + end + let :title do + 'rspec.example.com' + end + let :default_params do + { + :docroot => '/rspec/docroot', + :port => '84', + } + end + describe 'os-dependent items' do + context "on RedHat based systems" do + let :default_facts do + { + :osfamily => 'RedHat', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :operatingsystem => 'RedHat', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + let :params do default_params end + let :facts do default_facts end + it { should contain_class("apache") } + it { should contain_class("apache::params") } + end + context "on Debian based systems" do + let :default_facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + let :params do default_params end + let :facts do default_facts end + it { should contain_class("apache") } + it { should contain_class("apache::params") } + it { should contain_file("25-rspec.example.com.conf").with( + :ensure => 'present', + :path => '/etc/apache2/sites-available/25-rspec.example.com.conf' + ) } + it { should contain_file("25-rspec.example.com.conf symlink").with( + :ensure => 'link', + :path => '/etc/apache2/sites-enabled/25-rspec.example.com.conf', + :target => '/etc/apache2/sites-available/25-rspec.example.com.conf' + ) } + end + context "on FreeBSD systems" do + let :default_facts do + { + :osfamily => 'FreeBSD', + :operatingsystemrelease => '9', + :concat_basedir => '/dne', + :operatingsystem => 'FreeBSD', + :id => 'root', + :kernel => 'FreeBSD', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + let :params do default_params end + let :facts do default_facts end + it { should contain_class("apache") } + it { should contain_class("apache::params") } + it { should contain_file("25-rspec.example.com.conf").with( + :ensure => 'present', + :path => '/usr/local/etc/apache22/Vhosts/25-rspec.example.com.conf' + ) } + end + end + describe 'os-independent items' do + let :facts do + { + :osfamily => 'Debian', + :operatingsystemrelease => '6', + :concat_basedir => '/dne', + :lsbdistcodename => 'squeeze', + :operatingsystem => 'Debian', + :id => 'root', + :kernel => 'Linux', + :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + } + end + describe 'basic assumptions' do + let :params do default_params end + it { should contain_class("apache") } + it { should contain_class("apache::params") } + it { should contain_apache__listen(params[:port]) } + it { should contain_apache__namevirtualhost("*:#{params[:port]}") } + end + + # All match and notmatch should be a list of regexs and exact match strings + context ".conf content" do + [ + { + :title => 'should contain docroot', + :attr => 'docroot', + :value => '/not/default', + :match => [/^ DocumentRoot "\/not\/default"$/,/ /], + }, + { + :title => 'should set a port', + :attr => 'port', + :value => '8080', + :match => [/^$/], + }, + { + :title => 'should set an ip', + :attr => 'ip', + :value => '10.0.0.1', + :match => [/^$/], + }, + { + :title => 'should set a serveradmin', + :attr => 'serveradmin', + :value => 'test@test.com', + :match => [/^ ServerAdmin test@test.com$/], + }, + { + :title => 'should enable ssl', + :attr => 'ssl', + :value => true, + :match => [/^ SSLEngine on$/], + }, + { + :title => 'should set a servername', + :attr => 'servername', + :value => 'param.test', + :match => [/^ ServerName param.test$/], + }, + { + :title => 'should accept server aliases', + :attr => 'serveraliases', + :value => ['one.com','two.com'], + :match => [ + /^ ServerAlias one\.com$/, + /^ ServerAlias two\.com$/ + ], + }, + { + :title => 'should accept setenv', + :attr => 'setenv', + :value => ['TEST1 one','TEST2 two'], + :match => [ + /^ SetEnv TEST1 one$/, + /^ SetEnv TEST2 two$/ + ], + }, + { + :title => 'should accept setenvif', + :attr => 'setenvif', + ## These are bugged in rspec-puppet; the $1 is droped + #:value => ['Host "^([^\.]*)\.website\.com$" CLIENT_NAME=$1'], + #:match => [' SetEnvIf Host "^([^\.]*)\.website\.com$" CLIENT_NAME=$1'], + :value => ['Host "^test\.com$" VHOST_ACCESS=test'], + :match => [/^ SetEnvIf Host "\^test\\.com\$" VHOST_ACCESS=test$/], + }, + { + :title => 'should accept options', + :attr => 'options', + :value => ['Fake','Options'], + :match => [/^ Options Fake Options$/], + }, + { + :title => 'should accept overrides', + :attr => 'override', + :value => ['Fake', 'Override'], + :match => [/^ AllowOverride Fake Override$/], + }, + { + :title => 'should accept logroot', + :attr => 'logroot', + :value => '/fake/log', + :match => [/CustomLog "\/fake\/log\//,/ErrorLog "\/fake\/log\//], + }, + { + :title => 'should accept log_level', + :attr => 'log_level', + :value => 'info', + :match => [/LogLevel info/], + }, + { + :title => 'should accept pipe destination for access log', + :attr => 'access_log_pipe', + :value => '| /bin/fake/logging', + :match => [/CustomLog "| \/bin\/fake\/logging" combined$/], + }, + { + :title => 'should accept pipe destination for error log', + :attr => 'error_log_pipe', + :value => '| /bin/fake/logging', + :match => [/ErrorLog "| \/bin\/fake\/logging" combined$/], + }, + { + :title => 'should accept syslog destination for access log', + :attr => 'access_log_syslog', + :value => 'syslog:local1', + :match => [/CustomLog "syslog:local1" combined$/], + }, + { + :title => 'should accept syslog destination for error log', + :attr => 'error_log_syslog', + :value => 'syslog', + :match => [/ErrorLog "syslog"$/], + }, + { + :title => 'should accept custom format for access logs', + :attr => 'access_log_format', + :value => '%h %{X-Forwarded-For}i %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\" \"Host: %{Host}i\" %T %D', + :match => [/CustomLog "\/var\/log\/.+_access\.log" "%h %\{X-Forwarded-For\}i %l %u %t \\"%r\\" %s %b \\"%\{Referer\}i\\" \\"%\{User-agent\}i\\" \\"Host: %\{Host\}i\\" %T %D"$/], + }, + { + :title => 'should contain access logs', + :attr => 'access_log', + :value => true, + :match => [/CustomLog "\/var\/log\/.+_access\.log" combined$/], + }, + { + :title => 'should not contain access logs', + :attr => 'access_log', + :value => false, + :notmatch => [/CustomLog "\/var\/log\/.+_access\.log" combined$/], + }, + { + :title => 'should contain error logs', + :attr => 'error_log', + :value => true, + :match => [/ErrorLog.+$/], + }, + { + :title => 'should not contain error logs', + :attr => 'error_log', + :value => false, + :notmatch => [/ErrorLog.+$/], + }, + { + :title => 'should set ErrorDocument 503', + :attr => 'error_documents', + :value => [ { 'error_code' => '503', 'document' => '"Go away, the backend is broken."'}], + :match => [/^ ErrorDocument 503 "Go away, the backend is broken."$/], + }, + { + :title => 'should set ErrorDocuments 503 407', + :attr => 'error_documents', + :value => [ + { 'error_code' => '503', 'document' => '/service-unavail'}, + { 'error_code' => '407', 'document' => 'https://example.com/proxy/login'}, + ], + :match => [ + /^ ErrorDocument 503 \/service-unavail$/, + /^ ErrorDocument 407 https:\/\/example\.com\/proxy\/login$/, + ], + }, + { + :title => 'should set ErrorDocument 503 in directory', + :attr => 'directories', + :value => { 'path' => '/srv/www', 'error_documents' => [{ 'error_code' => '503', 'document' => '"Go away, the backend is broken."'}] }, + :match => [/^ ErrorDocument 503 "Go away, the backend is broken."$/], + }, + { + :title => 'should set ErrorDocuments 503 407 in directory', + :attr => 'directories', + :value => { 'path' => '/srv/www', 'error_documents' => + [ + { 'error_code' => '503', 'document' => '/service-unavail'}, + { 'error_code' => '407', 'document' => 'https://example.com/proxy/login'}, + ]}, + :match => [ + /^ ErrorDocument 503 \/service-unavail$/, + /^ ErrorDocument 407 https:\/\/example\.com\/proxy\/login$/, + ], + }, + { + :title => 'should accept a scriptalias', + :attr => 'scriptalias', + :value => '/usr/scripts', + :match => [ + /^ ScriptAlias \/cgi-bin "\/usr\/scripts"$/, + ], + }, + { + :title => 'should accept a single scriptaliases', + :attr => 'scriptaliases', + :value => { 'alias' => '/blah/', 'path' => '/usr/scripts' }, + :match => [ + /^ ScriptAlias \/blah\/ "\/usr\/scripts"$/, + ], + :nomatch => [/ScriptAlias \/cgi\-bin\//], + }, + { + :title => 'should accept multiple scriptaliases', + :attr => 'scriptaliases', + :value => [ { 'alias' => '/blah', 'path' => '/usr/scripts' }, { 'alias' => '/blah2', 'path' => '/usr/scripts' } ], + :match => [ + /^ ScriptAlias \/blah "\/usr\/scripts"$/, + /^ ScriptAlias \/blah2 "\/usr\/scripts"$/, + ], + :nomatch => [/ScriptAlias \/cgi\-bin\//], + }, + { + :title => 'should accept multiple scriptaliases with and without trailing slashes', + :attr => 'scriptaliases', + :value => [ { 'alias' => '/blah', 'path' => '/usr/scripts' }, { 'alias' => '/blah2/', 'path' => '/usr/scripts2/' } ], + :match => [ + /^ ScriptAlias \/blah "\/usr\/scripts"$/, + /^ ScriptAlias \/blah2\/ "\/usr\/scripts2\/"$/, + ], + :nomatch => [/ScriptAlias \/cgi\-bin\//], + }, + { + :title => 'should accept a ScriptAliasMatch directive', + :attr => 'scriptaliases', + ## XXX As mentioned above, rspec-puppet drops constructs like $1. + ## Thus, these tests don't work as they should. As a workaround we + ## use FOO instead of $1 here. + :value => [ { 'aliasmatch' => '^/cgi-bin(.*)', 'path' => '/usr/local/apache/cgi-binFOO' } ], + :match => [ + /^ ScriptAliasMatch \^\/cgi-bin\(\.\*\) "\/usr\/local\/apache\/cgi-binFOO"$/ + ], + }, + { + :title => 'should accept multiple ScriptAliasMatch directives', + :attr => 'scriptaliases', + ## XXX As mentioned above, rspec-puppet drops constructs like $1. + ## Thus, these tests don't work as they should. As a workaround we + ## use FOO instead of $1 here. + :value => [ + { 'aliasmatch' => '^/cgi-bin(.*)', 'path' => '/usr/local/apache/cgi-binFOO' }, + { 'aliasmatch' => '"(?x)^/git/(.*/(HEAD|info/refs|objects/(info/[^/]+|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(pack|idx))|git-(upload|receive)-pack))"', 'path' => '/var/www/bin/gitolite-suexec-wrapper/FOO' }, + ], + :match => [ + /^ ScriptAliasMatch \^\/cgi-bin\(\.\*\) "\/usr\/local\/apache\/cgi-binFOO"$/, + /^ ScriptAliasMatch "\(\?x\)\^\/git\/\(\.\*\/\(HEAD\|info\/refs\|objects\/\(info\/\[\^\/\]\+\|\[0-9a-f\]\{2\}\/\[0-9a-f\]\{38\}\|pack\/pack-\[0-9a-f\]\{40\}\\\.\(pack\|idx\)\)\|git-\(upload\|receive\)-pack\)\)" "\/var\/www\/bin\/gitolite-suexec-wrapper\/FOO"$/, + ], + }, + { + :title => 'should accept mixed ScriptAlias and ScriptAliasMatch directives', + :attr => 'scriptaliases', + ## XXX As mentioned above, rspec-puppet drops constructs like $1. + ## Thus, these tests don't work as they should. As a workaround we + ## use FOO instead of $1 here. + :value => [ + { 'aliasmatch' => '"(?x)^/git/(.*/(HEAD|info/refs|objects/(info/[^/]+|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(pack|idx))|git-(upload|receive)-pack))"', 'path' => '/var/www/bin/gitolite-suexec-wrapper/FOO' }, + { 'alias' => '/git', 'path' => '/var/www/gitweb/index.cgi' }, + { 'aliasmatch' => '^/cgi-bin(.*)', 'path' => '/usr/local/apache/cgi-binFOO' }, + { 'alias' => '/trac', 'path' => '/etc/apache2/trac.fcgi' }, + ], + :match => [ + /^ ScriptAliasMatch "\(\?x\)\^\/git\/\(\.\*\/\(HEAD\|info\/refs\|objects\/\(info\/\[\^\/\]\+\|\[0-9a-f\]\{2\}\/\[0-9a-f\]\{38\}\|pack\/pack-\[0-9a-f\]\{40\}\\\.\(pack\|idx\)\)\|git-\(upload\|receive\)-pack\)\)" "\/var\/www\/bin\/gitolite-suexec-wrapper\/FOO"$/, + /^ ScriptAlias \/git "\/var\/www\/gitweb\/index\.cgi"$/, + /^ ScriptAliasMatch \^\/cgi-bin\(\.\*\) "\/usr\/local\/apache\/cgi-binFOO"$/, + /^ ScriptAlias \/trac "\/etc\/apache2\/trac.fcgi"$/, + ], + }, + { + :title => 'should accept proxy destinations', + :attr => 'proxy_dest', + :value => 'http://fake.com', + :match => [ + /^ ProxyPass \/ http:\/\/fake.com\/$/, + /^ $/, + /^ ProxyPassReverse http:\/\/fake.com\/$/, + /^ <\/Location>$/, + ], + :notmatch => [/ProxyPass .+!$/], + }, + { + :title => 'should accept proxy_pass hash', + :attr => 'proxy_pass', + :value => { 'path' => '/path-a', 'url' => 'http://fake.com/a' }, + :match => [ + /^ ProxyPass \/path-a http:\/\/fake.com\/a$/, + /^ $/, + /^ ProxyPassReverse http:\/\/fake.com\/a$/, + /^ <\/Location>$/, + + ], + :notmatch => [/ProxyPass .+!$/], + }, + { + :title => 'should accept proxy_pass array of hash', + :attr => 'proxy_pass', + :value => [ + { 'path' => '/path-a/', 'url' => 'http://fake.com/a/' }, + { 'path' => '/path-b', 'url' => 'http://fake.com/b' }, + ], + :match => [ + /^ ProxyPass \/path-a\/ http:\/\/fake.com\/a\/$/, + /^ $/, + /^ ProxyPassReverse http:\/\/fake.com\/a\/$/, + /^ <\/Location>$/, + /^ ProxyPass \/path-b http:\/\/fake.com\/b$/, + /^ $/, + /^ ProxyPassReverse http:\/\/fake.com\/b$/, + /^ <\/Location>$/, + ], + :notmatch => [/ProxyPass .+!$/], + }, + { + :title => 'should enable rack', + :attr => 'rack_base_uris', + :value => ['/rack1','/rack2'], + :match => [ + /^ RackBaseURI \/rack1$/, + /^ RackBaseURI \/rack2$/, + ], + }, + { + :title => 'should accept headers', + :attr => 'headers', + :value => ['add something', 'merge something_else'], + :match => [ + /^ Header add something$/, + /^ Header merge something_else$/, + ], + }, + { + :title => 'should accept request headers', + :attr => 'request_headers', + :value => ['append something', 'unset something_else'], + :match => [ + /^ RequestHeader append something$/, + /^ RequestHeader unset something_else$/, + ], + }, + { + :title => 'should accept rewrite rules', + :attr => 'rewrite_rule', + :value => 'not a real rule', + :match => [/^ RewriteRule not a real rule$/], + }, + { + :title => 'should accept rewrite rules', + :attr => 'rewrites', + :value => [{'rewrite_rule' => ['not a real rule']}], + :match => [/^ RewriteRule not a real rule$/], + }, + { + :title => 'should accept rewrite comment', + :attr => 'rewrites', + :value => [{'comment' => 'rewrite comment', 'rewrite_rule' => ['not a real rule']}], + :match => [/^ #rewrite comment/], + }, + { + :title => 'should accept rewrite conditions', + :attr => 'rewrites', + :value => [{'comment' => 'redirect IE', 'rewrite_cond' => ['%{HTTP_USER_AGENT} ^MSIE'], 'rewrite_rule' => ['^index\.html$ welcome.html'],}], + :match => [ + /^ #redirect IE$/, + /^ RewriteCond %{HTTP_USER_AGENT} \^MSIE$/, + /^ RewriteRule \^index\\\.html\$ welcome.html$/, + ], + }, + { + :title => 'should accept multiple rewrites', + :attr => 'rewrites', + :value => [ + {'rewrite_rule' => ['not a real rule']}, + {'rewrite_rule' => ['not a real rule two']}, + ], + :match => [ + /^ RewriteRule not a real rule$/, + /^ RewriteRule not a real rule two$/, + ], + }, + { + :title => 'should block scm', + :attr => 'block', + :value => 'scm', + :match => [/^ $/], + }, + { + :title => 'should accept a custom fragment', + :attr => 'custom_fragment', + :value => " Some custom fragment line\n That spans multiple lines", + :match => [ + /^ Some custom fragment line$/, + /^ That spans multiple lines$/, + /^<\/VirtualHost>$/, + ], + }, + { + :title => 'should accept an array of alias hashes', + :attr => 'aliases', + :value => [ { 'alias' => '/', 'path' => '/var/www'} ], + :match => [/^ Alias \/ "\/var\/www"$/], + }, + { + :title => 'should accept an alias hash', + :attr => 'aliases', + :value => { 'alias' => '/', 'path' => '/var/www'}, + :match => [/^ Alias \/ "\/var\/www"$/], + }, + { + :title => 'should accept multiple aliases', + :attr => 'aliases', + :value => [ + { 'alias' => '/', 'path' => '/var/www'}, + { 'alias' => '/cgi-bin', 'path' => '/var/www/cgi-bin'}, + { 'alias' => '/css', 'path' => '/opt/someapp/css'}, + ], + :match => [ + /^ Alias \/ "\/var\/www"$/, + /^ Alias \/cgi-bin "\/var\/www\/cgi-bin"$/, + /^ Alias \/css "\/opt\/someapp\/css"$/, + ], + }, + { + :title => 'should accept an aliasmatch hash', + :attr => 'aliases', + ## XXX As mentioned above, rspec-puppet drops the $1. Thus, these + # tests don't work. + #:value => { 'aliasmatch' => '^/image/(.*).gif', 'path' => '/files/gifs/$1.gif' }, + #:match => [/^ AliasMatch \^\/image\/\(\.\*\)\.gif \/files\/gifs\/\$1\.gif$/], + }, + { + :title => 'should accept a array of alias and aliasmatch hashes mixed', + :attr => 'aliases', + ## XXX As mentioned above, rspec-puppet drops the $1. Thus, these + # tests don't work. + #:value => [ + # { 'alias' => '/css', 'path' => '/files/css' }, + # { 'aliasmatch' => '^/image/(.*).gif', 'path' => '/files/gifs/$1.gif' }, + # { 'aliasmatch' => '^/image/(.*).jpg', 'path' => '/files/jpgs/$1.jpg' }, + # { 'alias' => '/image', 'path' => '/files/images' }, + #], + #:match => [ + # /^ Alias \/css \/files\/css$/, + # /^ AliasMatch \^\/image\/\(.\*\)\.gif \/files\/gifs\/\$1\.gif$/, + # /^ AliasMatch \^\/image\/\(.\*\)\.jpg \/files\/jpgs\/\$1\.jpg$/, + # /^ Alias \/image \/files\/images$/ + #], + }, + { + :title => 'should accept multiple additional includes', + :attr => 'additional_includes', + :value => [ + '/tmp/proxy_group_a', + '/tmp/proxy_group_b', + '/tmp/proxy_group_c', + ], + :match => [ + /^ Include "\/tmp\/proxy_group_a"$/, + /^ Include "\/tmp\/proxy_group_b"$/, + /^ Include "\/tmp\/proxy_group_c"$/, + ], + }, + { + :title => 'should accept a suPHP_Engine', + :attr => 'suphp_engine', + :value => 'on', + :match => [/^ suPHP_Engine on$/], + }, + { + :title => 'should accept a php_admin_flags', + :attr => 'php_admin_flags', + :value => { 'engine' => 'on' }, + :match => [/^ php_admin_flag engine on$/], + }, + { + :title => 'should accept php_admin_values', + :attr => 'php_admin_values', + :value => { 'open_basedir' => '/srv/web/www.com/:/usr/share/pear/' }, + :match => [/^ php_admin_value open_basedir \/srv\/web\/www.com\/:\/usr\/share\/pear\/$/], + }, + { + :title => 'should accept php_admin_flags in directories', + :attr => 'directories', + :value => { + 'path' => '/srv/www', + 'php_admin_flags' => { 'php_engine' => 'on' } + }, + :match => [/^ php_admin_flag php_engine on$/], + }, + { + :title => 'should accept php_admin_values', + :attr => 'php_admin_values', + :value => { 'open_basedir' => '/srv/web/www.com/:/usr/share/pear/' }, + :match => [/^ php_admin_value open_basedir \/srv\/web\/www.com\/:\/usr\/share\/pear\/$/], + }, + { + :title => 'should accept php_admin_values in directories', + :attr => 'directories', + :value => { + 'path' => '/srv/www', + 'php_admin_values' => { 'open_basedir' => '/srv/web/www.com/:/usr/share/pear/' } + }, + :match => [/^ php_admin_value open_basedir \/srv\/web\/www.com\/:\/usr\/share\/pear\/$/], + }, + { + :title => 'should accept a wsgi script alias', + :attr => 'wsgi_script_aliases', + :value => { '/' => '/var/www/myapp.wsgi'}, + :match => [/^ WSGIScriptAlias \/ "\/var\/www\/myapp.wsgi"$/], + }, + { + :title => 'should accept multiple wsgi aliases', + :attr => 'wsgi_script_aliases', + :value => { + '/wiki' => '/usr/local/wsgi/scripts/mywiki.wsgi', + '/blog' => '/usr/local/wsgi/scripts/myblog.wsgi', + '/' => '/usr/local/wsgi/scripts/myapp.wsgi', + }, + :match => [ + /^ WSGIScriptAlias \/wiki "\/usr\/local\/wsgi\/scripts\/mywiki.wsgi"$/, + /^ WSGIScriptAlias \/blog "\/usr\/local\/wsgi\/scripts\/myblog.wsgi"$/, + /^ WSGIScriptAlias \/ "\/usr\/local\/wsgi\/scripts\/myapp.wsgi"$/, + ], + }, + { + :title => 'should accept a wsgi application group', + :attr => 'wsgi_application_group', + :value => '%{GLOBAL}', + :match => [/^ WSGIApplicationGroup %{GLOBAL}$/], + }, + { + :title => 'should set wsgi pass authorization', + :attr => 'wsgi_pass_authorization', + :value => 'On', + :match => [/^ WSGIPassAuthorization On$/], + }, + { + :title => 'should set wsgi pass authorization false', + :attr => 'wsgi_pass_authorization', + :value => 'Off', + :match => [/^ WSGIPassAuthorization Off$/], + }, + { + :title => 'should contain environment variables', + :attr => 'access_log_env_var', + :value => 'admin', + :match => [/CustomLog "\/var\/log\/.+_access\.log" combined env=admin$/] + }, + { + :title => 'should contain virtual_docroot', + :attr => 'virtual_docroot', + :value => '/not/default', + :match => [ + /^ VirtualDocumentRoot "\/not\/default"$/, + ], + }, + { + :title => 'should accept multiple directories', + :attr => 'directories', + :value => [ + { 'path' => '/opt/app' }, + { 'path' => '/var/www' }, + { 'path' => '/rspec/docroot'} + ], + :match => [ + /^ $/, + /^ $/, + /^ $/, + ], + }, + ].each do |param| + describe "when #{param[:attr]} is #{param[:value]}" do + let :params do default_params.merge({ param[:attr].to_sym => param[:value] }) end + + it { should contain_file("25-#{title}.conf").with_mode('0644') } + if param[:match] + it "#{param[:title]}: matches" do + param[:match].each do |match| + should contain_file("25-#{title}.conf").with_content( match ) + end + end + end + if param[:notmatch] + it "#{param[:title]}: notmatches" do + param[:notmatch].each do |notmatch| + should_not contain_file("25-#{title}.conf").with_content( notmatch ) + end + end + end + end + end + end + + # Apache below 2.4 (Default Version). All match and notmatch should be a list of regexs and exact match strings + context ".conf content with $apache_version < 2.4" do + [ + { + :title => 'should accept a directory', + :attr => 'directories', + :value => { 'path' => '/opt/app' }, + :notmatch => [' '], + :match => [ + /^ $/, + /^ AllowOverride None$/, + /^ Order allow,deny$/, + /^ Allow from all$/, + /^ <\/Directory>$/, + ], + }, + { + :title => 'should accept directory directives hash', + :attr => 'directories', + :value => { + 'path' => '/opt/app', + 'headers' => 'Set X-Robots-Tag "noindex, noarchive, nosnippet"', + 'allow' => 'from rspec.org', + 'allow_override' => 'Lol', + 'deny' => 'from google.com', + 'options' => '-MultiViews', + 'order' => 'deny,yned', + 'passenger_enabled' => 'onf', + 'sethandler' => 'None', + }, + :match => [ + /^ $/, + /^ Header Set X-Robots-Tag "noindex, noarchive, nosnippet"$/, + /^ Allow from rspec.org$/, + /^ AllowOverride Lol$/, + /^ Deny from google.com$/, + /^ Options -MultiViews$/, + /^ Order deny,yned$/, + /^ SetHandler None$/, + /^ PassengerEnabled onf$/, + /^ <\/Directory>$/, + ], + }, + { + :title => 'should accept directory directives with arrays and hashes', + :attr => 'directories', + :value => [ + { + 'path' => '/opt/app1', + 'allow' => 'from rspec.org', + 'allow_override' => ['AuthConfig','Indexes'], + 'deny' => 'from google.com', + 'options' => ['-MultiViews','+MultiViews'], + 'order' => ['deny','yned'], + 'passenger_enabled' => 'onf', + }, + { + 'path' => '/opt/app2', + 'addhandlers' => { + 'handler' => 'cgi-script', + 'extensions' => '.cgi', + }, + }, + ], + :match => [ + /^ $/, + /^ Allow from rspec.org$/, + /^ AllowOverride AuthConfig Indexes$/, + /^ Deny from google.com$/, + /^ Options -MultiViews \+MultiViews$/, + /^ Order deny,yned$/, + /^ PassengerEnabled onf$/, + /^ <\/Directory>$/, + /^ $/, + /^ AllowOverride None$/, + /^ Order allow,deny$/, + /^ Allow from all$/, + /^ AddHandler cgi-script .cgi$/, + /^ <\/Directory>$/, + ], + }, + { + :title => 'should accept location for provider', + :attr => 'directories', + :value => { + 'path' => '/', + 'provider' => 'location', + }, + :notmatch => [' AllowOverride None'], + :match => [ + /^ $/, + /^ Order allow,deny$/, + /^ Allow from all$/, + /^ <\/Location>$/, + ], + }, + { + :title => 'should accept files for provider', + :attr => 'directories', + :value => { + 'path' => 'index.html', + 'provider' => 'files', + }, + :notmatch => [' AllowOverride None'], + :match => [ + /^ $/, + /^ Order allow,deny$/, + /^ Allow from all$/, + /^ <\/Files>$/, + ], + }, + { + :title => 'should accept files match for provider', + :attr => 'directories', + :value => { + 'path' => 'index.html', + 'provider' => 'filesmatch', + }, + :notmatch => [' AllowOverride None'], + :match => [ + /^ $/, + /^ Order allow,deny$/, + /^ Allow from all$/, + /^ <\/FilesMatch>$/, + ], + }, + ].each do |param| + describe "when #{param[:attr]} is #{param[:value]}" do + let :params do default_params.merge({ + param[:attr].to_sym => param[:value], + :apache_version => '2.2', + }) end + + it { should contain_file("25-#{title}.conf").with_mode('0644') } + if param[:match] + it "#{param[:title]}: matches" do + param[:match].each do |match| + should contain_file("25-#{title}.conf").with_content( match ) + end + end + end + if param[:notmatch] + it "#{param[:title]}: notmatches" do + param[:notmatch].each do |notmatch| + should_not contain_file("25-#{title}.conf").with_content( notmatch ) + end + end + end + end + end + end + + # Apache equals or above 2.4. All match and notmatch should be a list of regexs and exact match strings + context ".conf content with $apache_version >= 2.4" do + [ + { + :title => 'should accept a directory', + :attr => 'directories', + :value => { 'path' => '/opt/app' }, + :notmatch => [' '], + :match => [ + /^ $/, + /^ AllowOverride None$/, + /^ Require all granted$/, + /^ <\/Directory>$/, + ], + }, + { + :title => 'should accept directory directives hash', + :attr => 'directories', + :value => { + 'path' => '/opt/app', + 'headers' => 'Set X-Robots-Tag "noindex, noarchive, nosnippet"', + 'allow_override' => 'Lol', + 'options' => '-MultiViews', + 'require' => 'something denied', + 'passenger_enabled' => 'onf', + }, + :match => [ + /^ $/, + /^ Header Set X-Robots-Tag "noindex, noarchive, nosnippet"$/, + /^ AllowOverride Lol$/, + /^ Options -MultiViews$/, + /^ Require something denied$/, + /^ PassengerEnabled onf$/, + /^ <\/Directory>$/, + ], + }, + { + :title => 'should accept directory directives with arrays and hashes', + :attr => 'directories', + :value => [ + { + 'path' => '/opt/app1', + 'allow_override' => ['AuthConfig','Indexes'], + 'options' => ['-MultiViews','+MultiViews'], + 'require' => ['host','example.org'], + 'passenger_enabled' => 'onf', + }, + { + 'path' => '/opt/app2', + 'addhandlers' => { + 'handler' => 'cgi-script', + 'extensions' => '.cgi', + }, + }, + ], + :match => [ + /^ $/, + /^ AllowOverride AuthConfig Indexes$/, + /^ Options -MultiViews \+MultiViews$/, + /^ Require host example.org$/, + /^ PassengerEnabled onf$/, + /^ <\/Directory>$/, + /^ $/, + /^ AllowOverride None$/, + /^ Require all granted$/, + /^ AddHandler cgi-script .cgi$/, + /^ <\/Directory>$/, + ], + }, + { + :title => 'should accept location for provider', + :attr => 'directories', + :value => { + 'path' => '/', + 'provider' => 'location', + }, + :notmatch => [' AllowOverride None'], + :match => [ + /^ $/, + /^ Require all granted$/, + /^ <\/Location>$/, + ], + }, + { + :title => 'should accept files for provider', + :attr => 'directories', + :value => { + 'path' => 'index.html', + 'provider' => 'files', + }, + :notmatch => [' AllowOverride None'], + :match => [ + /^ $/, + /^ Require all granted$/, + /^ <\/Files>$/, + ], + }, + { + :title => 'should accept files match for provider', + :attr => 'directories', + :value => { + 'path' => 'index.html', + 'provider' => 'filesmatch', + }, + :notmatch => [' AllowOverride None'], + :match => [ + /^ $/, + /^ Require all granted$/, + /^ <\/FilesMatch>$/, + ], + }, + ].each do |param| + describe "when #{param[:attr]} is #{param[:value]}" do + let :params do default_params.merge({ + param[:attr].to_sym => param[:value], + :apache_version => '2.4', + }) end + + it { should contain_file("25-#{title}.conf").with_mode('0644') } + if param[:match] + it "#{param[:title]}: matches" do + param[:match].each do |match| + should contain_file("25-#{title}.conf").with_content( match ) + end + end + end + if param[:notmatch] + it "#{param[:title]}: notmatches" do + param[:notmatch].each do |notmatch| + should_not contain_file("25-#{title}.conf").with_content( notmatch ) + end + end + end + end + end + end + + # All match and notmatch should be a list of regexs and exact match strings + context ".conf content with SSL" do + [ + { + :title => 'should accept setting SSLCertificateFile', + :attr => 'ssl_cert', + :value => '/path/to/cert.pem', + :match => [/^ SSLCertificateFile "\/path\/to\/cert\.pem"$/], + }, + { + :title => 'should accept setting SSLCertificateKeyFile', + :attr => 'ssl_key', + :value => '/path/to/cert.pem', + :match => [/^ SSLCertificateKeyFile "\/path\/to\/cert\.pem"$/], + }, + { + :title => 'should accept setting SSLCertificateChainFile', + :attr => 'ssl_chain', + :value => '/path/to/cert.pem', + :match => [/^ SSLCertificateChainFile "\/path\/to\/cert\.pem"$/], + }, + { + :title => 'should accept setting SSLCertificatePath', + :attr => 'ssl_certs_dir', + :value => '/path/to/certs', + :match => [/^ SSLCACertificatePath "\/path\/to\/certs"$/], + }, + { + :title => 'should accept setting SSLCertificateFile', + :attr => 'ssl_ca', + :value => '/path/to/ca.pem', + :match => [/^ SSLCACertificateFile "\/path\/to\/ca\.pem"$/], + }, + { + :title => 'should accept setting SSLRevocationPath', + :attr => 'ssl_crl_path', + :value => '/path/to/crl', + :match => [/^ SSLCARevocationPath "\/path\/to\/crl"$/], + }, + { + :title => 'should accept setting SSLRevocationFile', + :attr => 'ssl_crl', + :value => '/path/to/crl.pem', + :match => [/^ SSLCARevocationFile "\/path\/to\/crl\.pem"$/], + }, + { + :title => 'should accept setting SSLProxyEngine', + :attr => 'ssl_proxyengine', + :value => true, + :match => [/^ SSLProxyEngine On$/], + }, + { + :title => 'should accept setting SSLProtocol', + :attr => 'ssl_protocol', + :value => 'all -SSLv2', + :match => [/^ SSLProtocol all -SSLv2$/], + }, + { + :title => 'should accept setting SSLCipherSuite', + :attr => 'ssl_cipher', + :value => 'RC4-SHA:HIGH:!ADH:!SSLv2', + :match => [/^ SSLCipherSuite RC4-SHA:HIGH:!ADH:!SSLv2$/], + }, + { + :title => 'should accept setting SSLHonorCipherOrder', + :attr => 'ssl_honorcipherorder', + :value => 'On', + :match => [/^ SSLHonorCipherOrder On$/], + }, + { + :title => 'should accept setting SSLVerifyClient', + :attr => 'ssl_verify_client', + :value => 'optional', + :match => [/^ SSLVerifyClient optional$/], + }, + { + :title => 'should accept setting SSLVerifyDepth', + :attr => 'ssl_verify_depth', + :value => '1', + :match => [/^ SSLVerifyDepth 1$/], + }, + { + :title => 'should accept setting SSLOptions with a string', + :attr => 'ssl_options', + :value => '+ExportCertData', + :match => [/^ SSLOptions \+ExportCertData$/], + }, + { + :title => 'should accept setting SSLOptions with an array', + :attr => 'ssl_options', + :value => ['+StrictRequire','+ExportCertData'], + :match => [/^ SSLOptions \+StrictRequire \+ExportCertData/], + }, + { + :title => 'should accept setting SSLOptions with a string in directories', + :attr => 'directories', + :value => { 'path' => '/srv/www', 'ssl_options' => '+ExportCertData'}, + :match => [/^ SSLOptions \+ExportCertData$/], + }, + { + :title => 'should accept setting SSLOptions with an array in directories', + :attr => 'directories', + :value => { 'path' => '/srv/www', 'ssl_options' => ['-StdEnvVars','+ExportCertData']}, + :match => [/^ SSLOptions -StdEnvVars \+ExportCertData/], + }, + ].each do |param| + describe "when #{param[:attr]} is #{param[:value]} with SSL" do + let :params do + default_params.merge( { + param[:attr].to_sym => param[:value], + :ssl => true, + } ) + end + it { should contain_file("25-#{title}.conf").with_mode('0644') } + if param[:match] + it "#{param[:title]}: matches" do + param[:match].each do |match| + should contain_file("25-#{title}.conf").with_content( match ) + end + end + end + if param[:notmatch] + it "#{param[:title]}: notmatches" do + param[:notmatch].each do |notmatch| + should_not contain_file("25-#{title}.conf").with_content( notmatch ) + end + end + end + end + end + end + + context 'attribute resources' do + describe 'when access_log_file and access_log_pipe are specified' do + let :params do default_params.merge({ + :access_log_file => 'fake.log', + :access_log_pipe => '| /bin/fake', + }) end + it 'should cause a failure' do + expect { subject }.to raise_error(Puppet::Error, /'access_log_file' and 'access_log_pipe' cannot be defined at the same time/) + end + end + describe 'when error_log_file and error_log_pipe are specified' do + let :params do default_params.merge({ + :error_log_file => 'fake.log', + :error_log_pipe => '| /bin/fake', + }) end + it 'should cause a failure' do + expect { subject }.to raise_error(Puppet::Error, /'error_log_file' and 'error_log_pipe' cannot be defined at the same time/) + end + end + describe 'when docroot owner and mode is specified' do + let :params do default_params.merge({ + :docroot_owner => 'testuser', + :docroot_group => 'testgroup', + :docroot_mode => '0750', + }) end + it 'should set vhost ownership and permissions' do + should contain_file(params[:docroot]).with({ + :ensure => :directory, + :owner => 'testuser', + :group => 'testgroup', + :mode => '0750', + }) + end + end + + describe 'when wsgi_daemon_process and wsgi_daemon_process_options are specified' do + let :params do default_params.merge({ + :wsgi_daemon_process => 'example.org', + :wsgi_daemon_process_options => { 'processes' => '2', 'threads' => '15' }, + }) end + it 'should set wsgi_daemon_process_options' do + should contain_file("25-#{title}.conf").with_content( + /^ WSGIDaemonProcess example.org processes=2 threads=15$/ + ) + end + end + + describe 'when wsgi_import_script and wsgi_import_script_options are specified' do + let :params do default_params.merge({ + :wsgi_import_script => '/var/www/demo.wsgi', + :wsgi_import_script_options => { 'application-group' => '%{GLOBAL}', 'process-group' => 'wsgi' }, + }) end + it 'should set wsgi_import_script_options' do + should contain_file("25-#{title}.conf").with_content( + /^ WSGIImportScript \/var\/www\/demo.wsgi application-group=%{GLOBAL} process-group=wsgi$/ + ) + end + end + + describe 'when rewrites are specified' do + let :params do default_params.merge({ + :rewrites => [ + { + 'comment' => 'test rewrites', + 'rewrite_base' => '/mytestpath/', + 'rewrite_cond' => ['%{HTTP_USER_AGENT} ^Lynx/ [OR]', '%{HTTP_USER_AGENT} ^Mozilla/[12]'], + 'rewrite_rule' => ['^index\.html$ welcome.html', '^index\.cgi$ index.php'], + } + ] + }) end + it 'should set RewriteConds and RewriteRules' do + should contain_file("25-#{title}.conf").with_content( + /^ #test rewrites$/ + ) + should contain_file("25-#{title}.conf").with_content( + /^ RewriteCond %\{HTTP_USER_AGENT\} \^Lynx\/ \[OR\]$/ + ) + should contain_file("25-#{title}.conf").with_content( + /^ RewriteBase \/mytestpath\/$/ + ) + should contain_file("25-#{title}.conf").with_content( + /^ RewriteCond %\{HTTP_USER_AGENT\} \^Mozilla\/\[12\]$/ + ) + should contain_file("25-#{title}.conf").with_content( + /^ RewriteRule \^index\\.html\$ welcome.html$/ + ) + should contain_file("25-#{title}.conf").with_content( + /^ RewriteRule \^index\\.cgi\$ index.php$/ + ) + end + end + + describe 'when rewrite_rule and rewrite_cond are specified' do + let :params do default_params.merge({ + :rewrite_cond => '%{HTTPS} off', + :rewrite_rule => '(.*) https://%{HTTPS_HOST}%{REQUEST_URI}', + }) end + it 'should set RewriteCond' do + should contain_file("25-#{title}.conf").with_content( + /^ RewriteCond %\{HTTPS\} off$/ + ) + end + end + + describe 'when action is specified specified' do + let :params do default_params.merge({ + :action => 'php-fastcgi', + }) end + it 'should set Action' do + should contain_file("25-#{title}.conf").with_content( + /^ Action php-fastcgi \/cgi-bin virtual$/ + ) + end + end + + describe 'when suphp_engine is on and suphp_configpath is specified' do + let :params do default_params.merge({ + :suphp_engine => 'on', + :suphp_configpath => '/etc/php5/apache2', + }) end + it 'should set suphp_configpath' do + should contain_file("25-#{title}.conf").with_content( + /^ suPHP_ConfigPath "\/etc\/php5\/apache2"$/ + ) + end + end + + describe 'when suphp_engine is on and suphp_addhandler is specified' do + let :params do default_params.merge({ + :suphp_engine => 'on', + :suphp_addhandler => 'x-httpd-php', + }) end + it 'should set suphp_addhandler' do + should contain_file("25-#{title}.conf").with_content( + /^ suPHP_AddHandler x-httpd-php/ + ) + end + end + + describe 'when suphp_engine is on and suphp { user & group } is specified' do + let :params do default_params.merge({ + :suphp_engine => 'on', + :directories => { 'path' => '/srv/www', + 'suphp' => { 'user' => 'myappuser', 'group' => 'myappgroup' }, + } + }) end + it 'should set suphp_UserGroup' do + should contain_file("25-#{title}.conf").with_content( + /^ suPHP_UserGroup myappuser myappgroup/ + ) + end + end + + describe 'priority/default settings' do + describe 'when neither priority/default is specified' do + let :params do default_params end + it { should contain_file("25-#{title}.conf").with_path( + /25-#{title}.conf/ + ) } + end + describe 'when both priority/default_vhost is specified' do + let :params do + default_params.merge({ + :priority => 15, + :default_vhost => true, + }) + end + it { should contain_file("15-#{title}.conf").with_path( + /15-#{title}.conf/ + ) } + end + describe 'when only priority is specified' do + let :params do + default_params.merge({ :priority => 14, }) + end + it { should contain_file("14-#{title}.conf").with_path( + /14-#{title}.conf/ + ) } + end + describe 'when only default is specified' do + let :params do + default_params.merge({ :default_vhost => true, }) + end + it { should contain_file("10-#{title}.conf").with_path( + /10-#{title}.conf/ + ) } + end + end + + describe 'fcgid directory options' do + describe 'No fcgiwrapper' do + let :params do + default_params.merge({ + :directories => { 'path' => '/srv/www' }, + }) + end + + it { should_not contain_file("25-#{title}.conf").with_content(%r{FcgidWrapper}) } + end + + describe 'Only a command' do + let :params do + default_params.merge({ + :directories => { 'path' => '/srv/www', + 'fcgiwrapper' => { 'command' => '/usr/local/bin/fcgiwrapper' }, + } + }) + end + + it { should contain_file("25-#{title}.conf").with_content(%r{^ FcgidWrapper /usr/local/bin/fcgiwrapper $}) } + end + + describe 'All parameters' do + let :params do + default_params.merge({ + :directories => { 'path' => '/srv/www', + 'fcgiwrapper' => { 'command' => '/usr/local/bin/fcgiwrapper', 'suffix' => '.php', 'virtual' => 'virtual' }, + } + }) + end + + it { should contain_file("25-#{title}.conf").with_content(%r{^ FcgidWrapper /usr/local/bin/fcgiwrapper .php virtual$}) } + end + end + + describe 'various ip/port combos' do + describe 'when ip_based is true' do + let :params do default_params.merge({ :ip_based => true }) end + it 'should not specify a NameVirtualHost' do + should contain_apache__listen(params[:port]) + should_not contain_apache__namevirtualhost("*:#{params[:port]}") + end + end + + describe 'when ip_based is default' do + let :params do default_params end + it 'should specify a NameVirtualHost' do + should contain_apache__listen(params[:port]) + should contain_apache__namevirtualhost("*:#{params[:port]}") + end + end + + describe 'when an ip is set' do + let :params do default_params.merge({ :ip => '10.0.0.1' }) end + it 'should specify a NameVirtualHost for the ip' do + should_not contain_apache__listen(params[:port]) + should contain_apache__listen("10.0.0.1:#{params[:port]}") + should contain_apache__namevirtualhost("10.0.0.1:#{params[:port]}") + end + end + + describe 'an ip_based vhost without a port' do + let :params do + { + :docroot => '/fake', + :ip => '10.0.0.1', + :ip_based => true, + } + end + it 'should specify a NameVirtualHost for the ip' do + should_not contain_apache__listen(params[:ip]) + should_not contain_apache__namevirtualhost(params[:ip]) + should contain_file("25-#{title}.conf").with_content %r{} + end + end + end + + describe 'when suexec_user_group is specified' do + let :params do + default_params.merge({ + :suexec_user_group => 'nobody nogroup', + }) + end + + it { should contain_file("25-#{title}.conf").with_content %r{^ SuexecUserGroup nobody nogroup$} } + end + + describe 'redirect rules' do + describe 'without lockstep arrays' do + let :params do + default_params.merge({ + :redirect_source => [ + '/login', + '/logout', + ], + :redirect_dest => [ + 'http://10.0.0.10/login', + 'http://10.0.0.10/logout', + ], + :redirect_status => [ + 'permanent', + '', + ], + }) + end + + it { should contain_file("25-#{title}.conf").with_content %r{ Redirect permanent /login http://10\.0\.0\.10/login} } + it { should contain_file("25-#{title}.conf").with_content %r{ Redirect /logout http://10\.0\.0\.10/logout} } + end + describe 'redirect match rules' do + let :params do + default_params.merge({ + :redirectmatch_status => [ + '404', + ], + :redirectmatch_regexp => [ + '/\.git(/.*|$)', + ], + }) + end + + it { should contain_file("25-#{title}.conf").with_content %r{ RedirectMatch 404 } } + end + describe 'without a status' do + let :params do + default_params.merge({ + :redirect_source => [ + '/login', + '/logout', + ], + :redirect_dest => [ + 'http://10.0.0.10/login', + 'http://10.0.0.10/logout', + ], + }) + end + + it { should contain_file("25-#{title}.conf").with_content %r{ Redirect /login http://10\.0\.0\.10/login} } + it { should contain_file("25-#{title}.conf").with_content %r{ Redirect /logout http://10\.0\.0\.10/logout} } + end + describe 'with a single status and dest' do + let :params do + default_params.merge({ + :redirect_source => [ + '/login', + '/logout', + ], + :redirect_dest => 'http://10.0.0.10/test', + :redirect_status => 'permanent', + }) + end + + it { should contain_file("25-#{title}.conf").with_content %r{ Redirect permanent /login http://10\.0\.0\.10/test} } + it { should contain_file("25-#{title}.conf").with_content %r{ Redirect permanent /logout http://10\.0\.0\.10/test} } + end + + describe 'with a directoryindex specified' do + let :params do + default_params.merge({ + :directoryindex => 'index.php' + }) + end + it { should contain_file("25-#{title}.conf").with_content %r{DirectoryIndex index.php} } + end + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/fixtures/files/spec b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/fixtures/files/spec new file mode 100644 index 0000000000..76e9a14466 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/fixtures/files/spec @@ -0,0 +1 @@ +# This is a file only for spec testing diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/fixtures/modules/site_apache/templates/fake.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/fixtures/modules/site_apache/templates/fake.conf.erb new file mode 100644 index 0000000000..019debfe48 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/fixtures/modules/site_apache/templates/fake.conf.erb @@ -0,0 +1 @@ +Fake template for rspec. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/spec.opts b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/spec.opts new file mode 100644 index 0000000000..de653df4b3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/spec.opts @@ -0,0 +1,4 @@ +--format s +--colour +--loadby mtime +--backtrace diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/spec_helper.rb new file mode 100644 index 0000000000..65379ee38a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/spec_helper.rb @@ -0,0 +1,25 @@ +require 'puppetlabs_spec_helper/module_spec_helper' + +RSpec.configure do |c| + c.treat_symbols_as_metadata_keys_with_true_values = true + + c.before :each do + # Ensure that we don't accidentally cache facts and environment + # between test cases. + Facter::Util::Loader.any_instance.stubs(:load_all) + Facter.clear + Facter.clear_messages + + # Store any environment variables away to be restored later + @old_env = {} + ENV.each_key {|k| @old_env[k] = ENV[k]} + + if ENV['STRICT_VARIABLES'] == 'yes' + Puppet.settings[:strict_variables]=true + end + end +end + +shared_examples :compile, :compile => true do + it { should compile.with_all_deps } +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/spec_helper_acceptance.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000000..370de46c0d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/spec_helper_acceptance.rb @@ -0,0 +1,45 @@ +require 'beaker-rspec/spec_helper' +require 'beaker-rspec/helpers/serverspec' + + +unless ENV['RS_PROVISION'] == 'no' + hosts.each do |host| + if host['platform'] =~ /debian/ + on host, 'echo \'export PATH=/var/lib/gems/1.8/bin/:${PATH}\' >> ~/.bashrc' + end + if host.is_pe? + install_pe + else + install_puppet + on host, "mkdir -p #{host['distmoduledir']}" + end + end +end + +UNSUPPORTED_PLATFORMS = ['Suse','windows','AIX','Solaris'] + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + puppet_module_install(:source => proj_root, :module_name => 'apache') + hosts.each do |host| + # Required for mod_passenger tests. + if fact('osfamily') == 'RedHat' + on host, puppet('module','install','stahnma/epel'), { :acceptable_exit_codes => [0,1] } + end + # Required for manifest to make mod_pagespeed repository available + if fact('osfamily') == 'Debian' + on host, puppet('module','install','puppetlabs-apt'), { :acceptable_exit_codes => [0,1] } + end + on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + on host, puppet('module','install','puppetlabs-concat'), { :acceptable_exit_codes => [0,1] } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/unit/provider/a2mod/gentoo_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/unit/provider/a2mod/gentoo_spec.rb new file mode 100644 index 0000000000..ddb9dddda4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/spec/unit/provider/a2mod/gentoo_spec.rb @@ -0,0 +1,184 @@ +#!/usr/bin/env rspec + +require 'spec_helper' + +provider_class = Puppet::Type.type(:a2mod).provider(:gentoo) + +describe provider_class do + before :each do + provider_class.clear + end + + [:conf_file, :instances, :modules, :initvars, :conf_file, :clear].each do |method| + it "should respond to the class method #{method}" do + provider_class.should respond_to(method) + end + end + + describe "when fetching modules" do + before do + @filetype = mock() + end + + it "should return a sorted array of the defined parameters" do + @filetype.expects(:read).returns(%Q{APACHE2_OPTS="-D FOO -D BAR -D BAZ"\n}) + provider_class.expects(:filetype).returns(@filetype) + + provider_class.modules.should == %w{bar baz foo} + end + + it "should cache the module list" do + @filetype.expects(:read).once.returns(%Q{APACHE2_OPTS="-D FOO -D BAR -D BAZ"\n}) + provider_class.expects(:filetype).once.returns(@filetype) + + 2.times { provider_class.modules.should == %w{bar baz foo} } + end + + it "should normalize parameters" do + @filetype.expects(:read).returns(%Q{APACHE2_OPTS="-D FOO -D BAR -D BAR"\n}) + provider_class.expects(:filetype).returns(@filetype) + + provider_class.modules.should == %w{bar foo} + end + end + + describe "when prefetching" do + it "should match providers to resources" do + provider = mock("ssl_provider", :name => "ssl") + resource = mock("ssl_resource") + resource.expects(:provider=).with(provider) + + provider_class.expects(:instances).returns([provider]) + provider_class.prefetch("ssl" => resource) + end + end + + describe "when flushing" do + before :each do + @filetype = mock() + @filetype.stubs(:backup) + provider_class.expects(:filetype).at_least_once.returns(@filetype) + + @info = mock() + @info.stubs(:[]).with(:name).returns("info") + @info.stubs(:provider=) + + @mpm = mock() + @mpm.stubs(:[]).with(:name).returns("mpm") + @mpm.stubs(:provider=) + + @ssl = mock() + @ssl.stubs(:[]).with(:name).returns("ssl") + @ssl.stubs(:provider=) + end + + it "should add modules whose ensure is present" do + @filetype.expects(:read).at_least_once.returns(%Q{APACHE2_OPTS=""}) + @filetype.expects(:write).with(%Q{APACHE2_OPTS="-D INFO"}) + + @info.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("info" => @info) + + provider_class.flush + end + + it "should remove modules whose ensure is present" do + @filetype.expects(:read).at_least_once.returns(%Q{APACHE2_OPTS="-D INFO"}) + @filetype.expects(:write).with(%Q{APACHE2_OPTS=""}) + + @info.stubs(:should).with(:ensure).returns(:absent) + @info.stubs(:provider=) + provider_class.prefetch("info" => @info) + + provider_class.flush + end + + it "should not modify providers without resources" do + @filetype.expects(:read).at_least_once.returns(%Q{APACHE2_OPTS="-D INFO -D MPM"}) + @filetype.expects(:write).with(%Q{APACHE2_OPTS="-D MPM -D SSL"}) + + @info.stubs(:should).with(:ensure).returns(:absent) + provider_class.prefetch("info" => @info) + + @ssl.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("ssl" => @ssl) + + provider_class.flush + end + + it "should write the modules in sorted order" do + @filetype.expects(:read).at_least_once.returns(%Q{APACHE2_OPTS=""}) + @filetype.expects(:write).with(%Q{APACHE2_OPTS="-D INFO -D MPM -D SSL"}) + + @mpm.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("mpm" => @mpm) + @info.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("info" => @info) + @ssl.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("ssl" => @ssl) + + provider_class.flush + end + + it "should write the records back once" do + @filetype.expects(:read).at_least_once.returns(%Q{APACHE2_OPTS=""}) + @filetype.expects(:write).once.with(%Q{APACHE2_OPTS="-D INFO -D SSL"}) + + @info.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("info" => @info) + + @ssl.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("ssl" => @ssl) + + provider_class.flush + end + + it "should only modify the line containing APACHE2_OPTS" do + @filetype.expects(:read).at_least_once.returns(%Q{# Comment\nAPACHE2_OPTS=""\n# Another comment}) + @filetype.expects(:write).once.with(%Q{# Comment\nAPACHE2_OPTS="-D INFO"\n# Another comment}) + + @info.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("info" => @info) + provider_class.flush + end + + it "should restore any arbitrary arguments" do + @filetype.expects(:read).at_least_once.returns(%Q{APACHE2_OPTS="-Y -D MPM -X"}) + @filetype.expects(:write).once.with(%Q{APACHE2_OPTS="-Y -X -D INFO -D MPM"}) + + @info.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("info" => @info) + provider_class.flush + end + + it "should backup the file once if changes were made" do + @filetype.expects(:read).at_least_once.returns(%Q{APACHE2_OPTS=""}) + @filetype.expects(:write).once.with(%Q{APACHE2_OPTS="-D INFO -D SSL"}) + + @info.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("info" => @info) + + @ssl.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("ssl" => @ssl) + + @filetype.unstub(:backup) + @filetype.expects(:backup) + provider_class.flush + end + + it "should not write the file or run backups if no changes were made" do + @filetype.expects(:read).at_least_once.returns(%Q{APACHE2_OPTS="-X -D INFO -D SSL -Y"}) + @filetype.expects(:write).never + + @info.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("info" => @info) + + @ssl.stubs(:should).with(:ensure).returns(:present) + provider_class.prefetch("ssl" => @ssl) + + @filetype.unstub(:backup) + @filetype.expects(:backup).never + provider_class.flush + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/confd/no-accf.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/confd/no-accf.conf.erb new file mode 100644 index 0000000000..10e51644ce --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/confd/no-accf.conf.erb @@ -0,0 +1,4 @@ + + AcceptFilter http none + AcceptFilter https none + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/httpd.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/httpd.conf.erb new file mode 100644 index 0000000000..cac3aaf102 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/httpd.conf.erb @@ -0,0 +1,109 @@ +# Security +ServerTokens <%= @server_tokens %> +ServerSignature <%= @server_signature %> +TraceEnable <%= @trace_enable %> + +ServerName "<%= @servername %>" +ServerRoot "<%= @server_root %>" +PidFile <%= @pidfile %> +Timeout <%= @timeout %> +KeepAlive <%= @keepalive %> +MaxKeepAliveRequests <%= @max_keepalive_requests %> +KeepAliveTimeout <%= @keepalive_timeout %> + +User <%= @user %> +Group <%= @group %> + +AccessFileName .htaccess + +<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require all denied +<%- else -%> + Order allow,deny + Deny from all + Satisfy all +<%- end -%> + + + + Options FollowSymLinks + AllowOverride None + + +DefaultType none +HostnameLookups Off +ErrorLog "<%= @logroot %>/<%= @error_log %>" +LogLevel <%= @log_level %> +EnableSendfile <%= @sendfile %> + +#Listen 80 + +<% if @apxs_workaround -%> +# Workaround: without this hack apxs would be confused about where to put +# LoadModule directives and fail entire procedure of apache package +# installation/reinstallation. This problem was observed on FreeBSD (apache22). +#LoadModule fake_module libexec/apache22/mod_fake.so +<% end -%> + +Include "<%= @mod_load_dir %>/*.load" +<% if @mod_load_dir != @confd_dir and @mod_load_dir != @vhost_load_dir -%> +Include "<%= @mod_load_dir %>/*.conf" +<% end -%> +Include "<%= @ports_file %>" + +LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined +LogFormat "%h %l %u %t \"%r\" %>s %b" common +LogFormat "%{Referer}i -> %U" referer +LogFormat "%{User-agent}i" agent +<% if @log_formats and !@log_formats.empty? -%> + <%- @log_formats.each do |nickname,format| -%> +LogFormat "<%= format -%>" <%= nickname %> + <%- end -%> +<% end -%> + +<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> +IncludeOptional "<%= @confd_dir %>/*.conf" +<%- else -%> +Include "<%= @confd_dir %>/*.conf" +<%- end -%> +<% if @vhost_load_dir != @confd_dir -%> +Include "<%= @vhost_load_dir %>/*" +<% end -%> + +<% if @error_documents -%> +# /usr/share/apache2/error on debian +Alias /error/ "<%= @error_documents_path %>/" + +"> + AllowOverride None + Options IncludesNoExec + AddOutputFilter Includes html + AddHandler type-map var +<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require all granted +<%- else -%> + Order allow,deny + Allow from all +<%- end -%> + LanguagePriority en cs de es fr it nl sv pt-br ro + ForceLanguagePriority Prefer Fallback + + +ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var +ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var +ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var +ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var +ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var +ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var +ErrorDocument 410 /error/HTTP_GONE.html.var +ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var +ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var +ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var +ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var +ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var +ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var +ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var +ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var +ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var +ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/listen.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/listen.erb new file mode 100644 index 0000000000..8fc871b0ad --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/listen.erb @@ -0,0 +1,6 @@ +<%# Listen should always be one of: + - + - : + - [ +-%> +Listen <%= @listen_addr_port %> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/alias.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/alias.conf.erb new file mode 100644 index 0000000000..151a806c9f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/alias.conf.erb @@ -0,0 +1,13 @@ + +Alias /icons/ "<%= @icons_path %>/" +"> + Options Indexes MultiViews + AllowOverride None +<%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require all granted +<%- else -%> + Order allow,deny + Allow from all +<%- end -%> + + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/authnz_ldap.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/authnz_ldap.conf.erb new file mode 100644 index 0000000000..565fcf0df9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/authnz_ldap.conf.erb @@ -0,0 +1,5 @@ +<% if @verifyServerCert == true -%> +LDAPVerifyServerCert On +<% else -%> +LDAPVerifyServerCert Off +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/autoindex.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/autoindex.conf.erb new file mode 100644 index 0000000000..ef6bbebea6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/autoindex.conf.erb @@ -0,0 +1,56 @@ +IndexOptions FancyIndexing VersionSort HTMLTable NameWidth=* DescriptionWidth=* Charset=UTF-8 +AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip x-bzip2 + +AddIconByType (TXT,/icons/text.gif) text/* +AddIconByType (IMG,/icons/image2.gif) image/* +AddIconByType (SND,/icons/sound2.gif) audio/* +AddIconByType (VID,/icons/movie.gif) video/* + +AddIcon /icons/binary.gif .bin .exe +AddIcon /icons/binhex.gif .hqx +AddIcon /icons/tar.gif .tar +AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv +AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip +AddIcon /icons/a.gif .ps .ai .eps +AddIcon /icons/layout.gif .html .shtml .htm .pdf +AddIcon /icons/text.gif .txt +AddIcon /icons/c.gif .c +AddIcon /icons/p.gif .pl .py +AddIcon /icons/f.gif .for +AddIcon /icons/dvi.gif .dvi +AddIcon /icons/uuencoded.gif .uu +AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl +AddIcon /icons/tex.gif .tex +AddIcon /icons/bomb.gif /core +AddIcon (SND,/icons/sound2.gif) .ogg +AddIcon (VID,/icons/movie.gif) .ogm + +AddIcon /icons/back.gif .. +AddIcon /icons/hand.right.gif README +AddIcon /icons/folder.gif ^^DIRECTORY^^ +AddIcon /icons/blank.gif ^^BLANKICON^^ + +AddIcon /icons/odf6odt-20x22.png .odt +AddIcon /icons/odf6ods-20x22.png .ods +AddIcon /icons/odf6odp-20x22.png .odp +AddIcon /icons/odf6odg-20x22.png .odg +AddIcon /icons/odf6odc-20x22.png .odc +AddIcon /icons/odf6odf-20x22.png .odf +AddIcon /icons/odf6odb-20x22.png .odb +AddIcon /icons/odf6odi-20x22.png .odi +AddIcon /icons/odf6odm-20x22.png .odm + +AddIcon /icons/odf6ott-20x22.png .ott +AddIcon /icons/odf6ots-20x22.png .ots +AddIcon /icons/odf6otp-20x22.png .otp +AddIcon /icons/odf6otg-20x22.png .otg +AddIcon /icons/odf6otc-20x22.png .otc +AddIcon /icons/odf6otf-20x22.png .otf +AddIcon /icons/odf6oti-20x22.png .oti +AddIcon /icons/odf6oth-20x22.png .oth + +DefaultIcon /icons/unknown.gif +ReadmeName README.html +HeaderName HEADER.html + +IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/cgid.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/cgid.conf.erb new file mode 100644 index 0000000000..5f82d7424c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/cgid.conf.erb @@ -0,0 +1 @@ +ScriptSock "<%= @cgisock_path %>" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/dav_fs.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/dav_fs.conf.erb new file mode 100644 index 0000000000..3c53e9e14b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/dav_fs.conf.erb @@ -0,0 +1 @@ +DAVLockDB "<%= @dav_lock %>" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/deflate.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/deflate.conf.erb new file mode 100644 index 0000000000..a3cdf0552e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/deflate.conf.erb @@ -0,0 +1,8 @@ +AddOutputFilterByType DEFLATE text/html text/plain text/xml +AddOutputFilterByType DEFLATE text/css +AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript +AddOutputFilterByType DEFLATE application/rss+xml + +DeflateFilterNote Input instream +DeflateFilterNote Output outstream +DeflateFilterNote Ratio ratio diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/dir.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/dir.conf.erb new file mode 100644 index 0000000000..741f6ae034 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/dir.conf.erb @@ -0,0 +1 @@ +DirectoryIndex <%= @indexes.join(' ') %> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/disk_cache.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/disk_cache.conf.erb new file mode 100644 index 0000000000..0c7e2c4b73 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/disk_cache.conf.erb @@ -0,0 +1,8 @@ + + + CacheEnable disk / + CacheRoot "<%= @cache_root %>" + CacheDirLevels 2 + CacheDirLength 1 + + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/event.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/event.conf.erb new file mode 100644 index 0000000000..40099543d5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/event.conf.erb @@ -0,0 +1,9 @@ + + ServerLimit <%= @serverlimit %> + StartServers <%= @startservers %> + MaxClients <%= @maxclients %> + MinSpareThreads <%= @minsparethreads %> + MaxSpareThreads <%= @maxsparethreads %> + ThreadsPerChild <%= @threadsperchild %> + MaxRequestsPerChild <%= @maxrequestsperchild %> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/fastcgi.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/fastcgi.conf.erb new file mode 100644 index 0000000000..8d94a23614 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/fastcgi.conf.erb @@ -0,0 +1,6 @@ +# The Fastcgi Apache module configuration file is being +# managed by Puppet and changes will be overwritten. + + AddHandler fastcgi-script .fcgi + FastCgiIpcDir "<%= @fastcgi_lib_path %>" + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/fcgid.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/fcgid.conf.erb new file mode 100644 index 0000000000..a82bc30df9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/fcgid.conf.erb @@ -0,0 +1,5 @@ + +<% @options.sort_by {|key, value| key}.each do |key, value| -%> + <%= key %> <%= value %> +<% end -%> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/info.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/info.conf.erb new file mode 100644 index 0000000000..d5288fb8c9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/info.conf.erb @@ -0,0 +1,10 @@ + + SetHandler server-info + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require ip <%= Array(@allow_from).join(" ") %> + <%- else -%> + Order deny,allow + Deny from all + Allow from <%= Array(@allow_from).join(" ") %> + <%- end -%> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/itk.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/itk.conf.erb new file mode 100644 index 0000000000..f45f2b35dd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/itk.conf.erb @@ -0,0 +1,8 @@ + + StartServers <%= @startservers %> + MinSpareServers <%= @minspareservers %> + MaxSpareServers <%= @maxspareservers %> + ServerLimit <%= @serverlimit %> + MaxClients <%= @maxclients %> + MaxRequestsPerChild <%= @maxrequestsperchild %> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/ldap.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/ldap.conf.erb new file mode 100644 index 0000000000..0019776175 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/ldap.conf.erb @@ -0,0 +1,11 @@ + + SetHandler ldap-status + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require ip 127.0.0.1 ::1 + <%- else -%> + Order deny,allow + Deny from all + Allow from 127.0.0.1 ::1 + Satisfy all + <%- end -%> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/load.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/load.erb new file mode 100644 index 0000000000..51f45edb21 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/load.erb @@ -0,0 +1,7 @@ +<% if @loadfiles -%> +<% Array(@loadfiles).each do |loadfile| -%> +LoadFile <%= loadfile %> +<% end -%> + +<% end -%> +LoadModule <%= @_id %> <%= @_path %> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/mime.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/mime.conf.erb new file mode 100644 index 0000000000..a69a424a6a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/mime.conf.erb @@ -0,0 +1,36 @@ +TypesConfig <%= @mime_types_config %> + +AddType application/x-compress .Z +AddType application/x-gzip .gz .tgz +AddType application/x-bzip2 .bz2 + +AddLanguage ca .ca +AddLanguage cs .cz .cs +AddLanguage da .dk +AddLanguage de .de +AddLanguage el .el +AddLanguage en .en +AddLanguage eo .eo +AddLanguage es .es +AddLanguage et .et +AddLanguage fr .fr +AddLanguage he .he +AddLanguage hr .hr +AddLanguage it .it +AddLanguage ja .ja +AddLanguage ko .ko +AddLanguage ltz .ltz +AddLanguage nl .nl +AddLanguage nn .nn +AddLanguage no .no +AddLanguage pl .po +AddLanguage pt .pt +AddLanguage pt-BR .pt-br +AddLanguage ru .ru +AddLanguage sv .sv +AddLanguage zh-CN .zh-cn +AddLanguage zh-TW .zh-tw + +AddHandler type-map var +AddType text/html .shtml +AddOutputFilter INCLUDES .shtml diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/mime_magic.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/mime_magic.conf.erb new file mode 100644 index 0000000000..1ce1bc3c16 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/mime_magic.conf.erb @@ -0,0 +1 @@ +MIMEMagicFile "<%= @magic_file %>" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/mpm_event.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/mpm_event.conf.erb new file mode 100644 index 0000000000..eb6f1ff5f5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/mpm_event.conf.erb @@ -0,0 +1,9 @@ + + StartServers 2 + MinSpareThreads 25 + MaxSpareThreads 75 + ThreadLimit 64 + ThreadsPerChild 25 + MaxClients 150 + MaxRequestsPerChild 0 + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/negotiation.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/negotiation.conf.erb new file mode 100644 index 0000000000..50921019bc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/negotiation.conf.erb @@ -0,0 +1,2 @@ +LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW +ForceLanguagePriority Prefer Fallback diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/nss.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/nss.conf.erb new file mode 100644 index 0000000000..a5c81752f3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/nss.conf.erb @@ -0,0 +1,228 @@ +# +# This is the Apache server configuration file providing SSL support using. +# the mod_nss plugin. It contains the configuration directives to instruct +# the server how to serve pages over an https connection. +# +# Do NOT simply read the instructions in here without understanding +# what they do. They're here only as hints or reminders. If you are unsure +# consult the online docs. You have been warned. +# + +#LoadModule nss_module modules/libmodnss.so + +# +# When we also provide SSL we have to listen to the +# standard HTTP port (see above) and to the HTTPS port +# +# Note: Configurations that use IPv6 but not IPv4-mapped addresses need two +# Listen directives: "Listen [::]:8443" and "Listen 0.0.0.0:443" +# +Listen 8443 + +## +## SSL Global Context +## +## All SSL configuration in this context applies both to +## the main server and all SSL-enabled virtual hosts. +## + +# +# Some MIME-types for downloading Certificates and CRLs +# +AddType application/x-x509-ca-cert .crt +AddType application/x-pkcs7-crl .crl + +# Pass Phrase Dialog: +# Configure the pass phrase gathering process. +# The filtering dialog program (`builtin' is a internal +# terminal dialog) has to provide the pass phrase on stdout. +<% if @passwd_file -%> +NSSPassPhraseDialog "file:<%= @passwd_file %>" +<% else -%> +NSSPassPhraseDialog builtin +<% end -%> + +# Pass Phrase Helper: +# This helper program stores the token password pins between +# restarts of Apache. +NSSPassPhraseHelper /usr/sbin/nss_pcache + +# Configure the SSL Session Cache. +# NSSSessionCacheSize is the number of entries in the cache. +# NSSSessionCacheTimeout is the SSL2 session timeout (in seconds). +# NSSSession3CacheTimeout is the SSL3/TLS session timeout (in seconds). +NSSSessionCacheSize 10000 +NSSSessionCacheTimeout 100 +NSSSession3CacheTimeout 86400 + +# +# Pseudo Random Number Generator (PRNG): +# Configure one or more sources to seed the PRNG of the SSL library. +# The seed data should be of good random quality. +# WARNING! On some platforms /dev/random blocks if not enough entropy +# is available. Those platforms usually also provide a non-blocking +# device, /dev/urandom, which may be used instead. +# +# This does not support seeding the RNG with each connection. + +NSSRandomSeed startup builtin +#NSSRandomSeed startup file:/dev/random 512 +#NSSRandomSeed startup file:/dev/urandom 512 + +# +# TLS Negotiation configuration under RFC 5746 +# +# Only renegotiate if the peer's hello bears the TLS renegotiation_info +# extension. Default off. +NSSRenegotiation off + +# Peer must send Signaling Cipher Suite Value (SCSV) or +# Renegotiation Info (RI) extension in ALL handshakes. Default: off +NSSRequireSafeNegotiation off + +## +## SSL Virtual Host Context +## + + + +# General setup for the virtual host +#DocumentRoot "/etc/httpd/htdocs" +#ServerName www.example.com:8443 +#ServerAdmin you@example.com + +# mod_nss can log to separate log files, you can choose to do that if you'd like +# LogLevel is not inherited from httpd.conf. +ErrorLog "<%= @error_log %>" +TransferLog "<%= @transfer_log %>" +LogLevel warn + +# SSL Engine Switch: +# Enable/Disable SSL for this virtual host. +NSSEngine on + +# SSL Cipher Suite: +# List the ciphers that the client is permitted to negotiate. +# See the mod_nss documentation for a complete list. + +# SSL 3 ciphers. SSL 2 is disabled by default. +NSSCipherSuite +rsa_rc4_128_md5,+rsa_rc4_128_sha,+rsa_3des_sha,-rsa_des_sha,-rsa_rc4_40_md5,-rsa_rc2_40_md5,-rsa_null_md5,-rsa_null_sha,+fips_3des_sha,-fips_des_sha,-fortezza,-fortezza_rc4_128_sha,-fortezza_null,-rsa_des_56_sha,-rsa_rc4_56_sha,+rsa_aes_128_sha,+rsa_aes_256_sha + +# SSL 3 ciphers + ECC ciphers. SSL 2 is disabled by default. +# +# Comment out the NSSCipherSuite line above and use the one below if you have +# ECC enabled NSS and mod_nss and want to use Elliptical Curve Cryptography +#NSSCipherSuite +rsa_rc4_128_md5,+rsa_rc4_128_sha,+rsa_3des_sha,-rsa_des_sha,-rsa_rc4_40_md5,-rsa_rc2_40_md5,-rsa_null_md5,-rsa_null_sha,+fips_3des_sha,-fips_des_sha,-fortezza,-fortezza_rc4_128_sha,-fortezza_null,-rsa_des_56_sha,-rsa_rc4_56_sha,+rsa_aes_128_sha,+rsa_aes_256_sha,-ecdh_ecdsa_null_sha,+ecdh_ecdsa_rc4_128_sha,+ecdh_ecdsa_3des_sha,+ecdh_ecdsa_aes_128_sha,+ecdh_ecdsa_aes_256_sha,-ecdhe_ecdsa_null_sha,+ecdhe_ecdsa_rc4_128_sha,+ecdhe_ecdsa_3des_sha,+ecdhe_ecdsa_aes_128_sha,+ecdhe_ecdsa_aes_256_sha,-ecdh_rsa_null_sha,+ecdh_rsa_128_sha,+ecdh_rsa_3des_sha,+ecdh_rsa_aes_128_sha,+ecdh_rsa_aes_256_sha,-echde_rsa_null,+ecdhe_rsa_rc4_128_sha,+ecdhe_rsa_3des_sha,+ecdhe_rsa_aes_128_sha,+ecdhe_rsa_aes_256_sha + +# SSL Protocol: +# Cryptographic protocols that provide communication security. +# NSS handles the specified protocols as "ranges", and automatically +# negotiates the use of the strongest protocol for a connection starting +# with the maximum specified protocol and downgrading as necessary to the +# minimum specified protocol that can be used between two processes. +# Since all protocol ranges are completely inclusive, and no protocol in the +# middle of a range may be excluded, the entry "NSSProtocol SSLv3,TLSv1.1" +# is identical to the entry "NSSProtocol SSLv3,TLSv1.0,TLSv1.1". +NSSProtocol SSLv3,TLSv1.0,TLSv1.1 + +# SSL Certificate Nickname: +# The nickname of the RSA server certificate you are going to use. +NSSNickname Server-Cert + +# SSL Certificate Nickname: +# The nickname of the ECC server certificate you are going to use, if you +# have an ECC-enabled version of NSS and mod_nss +#NSSECCNickname Server-Cert-ecc + +# Server Certificate Database: +# The NSS security database directory that holds the certificates and +# keys. The database consists of 3 files: cert8.db, key3.db and secmod.db. +# Provide the directory that these files exist. +NSSCertificateDatabase "<%= @httpd_dir -%>/alias" + +# Database Prefix: +# In order to be able to store multiple NSS databases in one directory +# they need unique names. This option sets the database prefix used for +# cert8.db and key3.db. +#NSSDBPrefix my-prefix- + +# Client Authentication (Type): +# Client certificate verification type. Types are none, optional and +# require. +#NSSVerifyClient none + +# +# Online Certificate Status Protocol (OCSP). +# Verify that certificates have not been revoked before accepting them. +#NSSOCSP off + +# +# Use a default OCSP responder. If enabled this will be used regardless +# of whether one is included in a client certificate. Note that the +# server certificate is verified during startup. +# +# NSSOCSPDefaultURL defines the service URL of the OCSP responder +# NSSOCSPDefaultName is the nickname of the certificate to trust to +# sign the OCSP responses. +#NSSOCSPDefaultResponder on +#NSSOCSPDefaultURL http://example.com/ocsp/status +#NSSOCSPDefaultName ocsp-nickname + +# Access Control: +# With SSLRequire you can do per-directory access control based +# on arbitrary complex boolean expressions containing server +# variable checks and other lookup directives. The syntax is a +# mixture between C and Perl. See the mod_nss documentation +# for more details. +# +#NSSRequire ( %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \ +# and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \ +# and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \ +# and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \ +# and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20 ) \ +# or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/ +# + +# SSL Engine Options: +# Set various options for the SSL engine. +# o FakeBasicAuth: +# Translate the client X.509 into a Basic Authorisation. This means that +# the standard Auth/DBMAuth methods can be used for access control. The +# user name is the `one line' version of the client's X.509 certificate. +# Note that no password is obtained from the user. Every entry in the user +# file needs this password: `xxj31ZMTZzkVA'. +# o ExportCertData: +# This exports two additional environment variables: SSL_CLIENT_CERT and +# SSL_SERVER_CERT. These contain the PEM-encoded certificates of the +# server (always existing) and the client (only existing when client +# authentication is used). This can be used to import the certificates +# into CGI scripts. +# o StdEnvVars: +# This exports the standard SSL/TLS related `SSL_*' environment variables. +# Per default this exportation is switched off for performance reasons, +# because the extraction step is an expensive operation and is usually +# useless for serving static content. So one usually enables the +# exportation for CGI and SSI requests only. +# o StrictRequire: +# This denies access when "NSSRequireSSL" or "NSSRequire" applied even +# under a "Satisfy any" situation, i.e. when it applies access is denied +# and no other module can change it. +# o OptRenegotiate: +# This enables optimized SSL connection renegotiation handling when SSL +# directives are used in per-directory context. +#NSSOptions +FakeBasicAuth +ExportCertData +CompatEnvVars +StrictRequire + + NSSOptions +StdEnvVars + + + NSSOptions +StdEnvVars + + +# Per-Server Logging: +# The home of a custom SSL log file. Use this when you want a +# compact non-error SSL logfile on a virtual host basis. +#CustomLog /home/rcrit/redhat/apache/logs/ssl_request_log \ +# "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" + + + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/pagespeed.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/pagespeed.conf.erb new file mode 100644 index 0000000000..a4d8a7220e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/pagespeed.conf.erb @@ -0,0 +1,98 @@ +ModPagespeed on + +ModPagespeedInheritVHostConfig <%= @inherit_vhost_config %> +AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html +<% if @filter_xhtml -%> +AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER application/xhtml+xml +<% end -%> +ModPagespeedFileCachePath "<%= @cache_path %>" +ModPagespeedLogDir "<%= @log_dir %>" + +<% @memache_servers.each do |server| -%> +ModPagespeedMemcachedServers <%= server -%> +<% end -%> + +ModPagespeedRewriteLevel <%= @rewrite_level -%> + +<% @disable_filters.each do |filter| -%> +ModPagespeedDisableFilters <%= filter -%> +<% end -%> + +<% @enable_filters.each do |filter| -%> +ModPagespeedEnableFilters <%= filter -%> +<% end -%> + +<% @forbid_filters.each do |filter| -%> +ModPagespeedForbidFilters <%= filter -%> +<% end -%> + +ModPagespeedRewriteDeadlinePerFlushMs <%= @rewrite_deadline_per_flush_ms %> + +<% if @additional_domains -%> +ModPagespeedDomain <%= @additional_domains -%> +<% end -%> + +ModPagespeedFileCacheSizeKb <%= @file_cache_size_kb %> +ModPagespeedFileCacheCleanIntervalMs <%= @file_cache_clean_interval_ms %> +ModPagespeedLRUCacheKbPerProcess <%= @lru_cache_per_process %> +ModPagespeedLRUCacheByteLimit <%= @lru_cache_byte_limit %> +ModPagespeedCssFlattenMaxBytes <%= @css_flatten_max_bytes %> +ModPagespeedCssInlineMaxBytes <%= @css_inline_max_bytes %> +ModPagespeedCssImageInlineMaxBytes <%= @css_image_inline_max_bytes %> +ModPagespeedImageInlineMaxBytes <%= @image_inline_max_bytes %> +ModPagespeedJsInlineMaxBytes <%= @js_inline_max_bytes %> +ModPagespeedCssOutlineMinBytes <%= @css_outline_min_bytes %> +ModPagespeedJsOutlineMinBytes <%= @js_outline_min_bytes %> + + +ModPagespeedFileCacheInodeLimit <%= @inode_limit %> +ModPagespeedImageMaxRewritesAtOnce <%= @image_max_rewrites_at_once %> + +ModPagespeedNumRewriteThreads <%= @num_rewrite_threads %> +ModPagespeedNumExpensiveRewriteThreads <%= @num_expensive_rewrite_threads %> + +ModPagespeedStatistics <%= @collect_statistics %> + + + # You may insert other "Allow from" lines to add hosts you want to + # allow to look at generated statistics. Another possibility is + # to comment out the "Order" and "Allow" options from the config + # file, to allow any client that can reach your server to examine + # statistics. This might be appropriate in an experimental setup or + # if the Apache server is protected by a reverse proxy that will + # filter URLs in some fashion. + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require ip 127.0.0.1 ::1 <%= Array(@allow_view_stats).join(" ") %> + <%- else -%> + Order allow,deny + Allow from 127.0.0.1 ::1 <%= Array(@allow_view_stats).join(" ") %> + <%- end -%> + SetHandler mod_pagespeed_statistics + + +ModPagespeedStatisticsLogging <%= @statistics_logging %> + + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require ip 127.0.0.1 ::1 <%= Array(@allow_pagespeed_console).join(" ") %> + <%- else -%> + Order allow,deny + Allow from 127.0.0.1 ::1 <%= Array(@allow_pagespeed_console).join(" ") %> + <%- end -%> + SetHandler pagespeed_console + + +ModPagespeedMessageBufferSize <%= @message_buffer_size %> + + + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require ip 127.0.0.1 ::1 <%= Array(@allow_pagespeed_message).join(" ") %> + <%- else -%> + Order allow,deny + Allow from 127.0.0.1 ::1 <%= Array(@allow_pagespeed_message).join(" ") %> + <%- end -%> + SetHandler mod_pagespeed_message + + +<% @additional_configuration.each_pair do |key, value| -%> +<%= key %> <%= value %> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/passenger.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/passenger.conf.erb new file mode 100644 index 0000000000..dd9eee3b13 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/passenger.conf.erb @@ -0,0 +1,37 @@ +# The Passanger Apache module configuration file is being +# managed by Puppet and changes will be overwritten. + + <%- if @passenger_root -%> + PassengerRoot "<%= @passenger_root %>" + <%- end -%> + <%- if @passenger_ruby -%> + PassengerRuby "<%= @passenger_ruby %>" + <%- end -%> + <%- if @passenger_default_ruby -%> + PassengerDefaultRuby "<%= @passenger_default_ruby %>" + <%- end -%> + <%- if @passenger_high_performance -%> + PassengerHighPerformance <%= @passenger_high_performance %> + <%- end -%> + <%- if @passenger_max_pool_size -%> + PassengerMaxPoolSize <%= @passenger_max_pool_size %> + <%- end -%> + <%- if @passenger_pool_idle_time -%> + PassengerPoolIdleTime <%= @passenger_pool_idle_time %> + <%- end -%> + <%- if @passenger_max_requests -%> + PassengerMaxRequests <%= @passenger_max_requests %> + <%- end -%> + <%- if @passenger_stat_throttle_rate -%> + PassengerStatThrottleRate <%= @passenger_stat_throttle_rate %> + <%- end -%> + <%- if @rack_autodetect -%> + RackAutoDetect <%= @rack_autodetect %> + <%- end -%> + <%- if @rails_autodetect -%> + RailsAutoDetect <%= @rails_autodetect %> + <%- end -%> + <%- if @passenger_use_global_queue -%> + PassengerUseGlobalQueue <%= @passenger_use_global_queue %> + <%- end -%> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/peruser.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/peruser.conf.erb new file mode 100644 index 0000000000..13c8d708db --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/peruser.conf.erb @@ -0,0 +1,12 @@ + + MinSpareProcessors <%= @minspareprocessors %> + MinProcessors <%= @minprocessors %> + MaxProcessors <%= @maxprocessors %> + MaxClients <%= @maxclients %> + MaxRequestsPerChild <%= @maxrequestsperchild %> + IdleTimeout <%= @idletimeout %> + ExpireTimeout <%= @expiretimeout %> + KeepAlive <%= @keepalive %> + Include "<%= @mod_dir %>/peruser/multiplexers/*.conf" + Include "<%= @mod_dir %>/peruser/processors/*.conf" + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/php5.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/php5.conf.erb new file mode 100644 index 0000000000..44df2ae066 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/php5.conf.erb @@ -0,0 +1,30 @@ +# +# PHP is an HTML-embedded scripting language which attempts to make it +# easy for developers to write dynamically generated webpages. +# +# +# LoadModule php5_module modules/libphp5.so +# +# +# # Use of the "ZTS" build with worker is experimental, and no shared +# # modules are supported. +# LoadModule php5_module modules/libphp5-zts.so +# + +# +# Cause the PHP interpreter to handle files with a .php extension. +# +AddHandler php5-script <%= @extensions.flatten.compact.join(' ') %> +AddType text/html .php + +# +# Add index.php to the list of files that will be served as directory +# indexes. +# +DirectoryIndex index.php + +# +# Uncomment the following line to allow PHP to pretty-print .phps +# files as PHP source code: +# +#AddType application/x-httpd-php-source .phps diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/prefork.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/prefork.conf.erb new file mode 100644 index 0000000000..aabfdf7b22 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/prefork.conf.erb @@ -0,0 +1,8 @@ + + StartServers <%= @startservers %> + MinSpareServers <%= @minspareservers %> + MaxSpareServers <%= @maxspareservers %> + ServerLimit <%= @serverlimit %> + MaxClients <%= @maxclients %> + MaxRequestsPerChild <%= @maxrequestsperchild %> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/proxy.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/proxy.conf.erb new file mode 100644 index 0000000000..5ea829eeb3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/proxy.conf.erb @@ -0,0 +1,27 @@ +# +# Proxy Server directives. Uncomment the following lines to +# enable the proxy server: +# + + # Do not enable proxying with ProxyRequests until you have secured your + # server. Open proxy servers are dangerous both to your network and to the + # Internet at large. + ProxyRequests <%= @proxy_requests %> + + <% if @proxy_requests != 'Off' or ( @allow_from and ! @allow_from.empty? ) -%> + + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require ip <%= Array(@allow_from).join(" ") %> + <%- else -%> + Order deny,allow + Deny from all + Allow from <%= Array(@allow_from).join(" ") %> + <%- end -%> + + <% end -%> + + # Enable/disable the handling of HTTP/1.1 "Via:" headers. + # ("Full" adds the server version; "Block" removes all outgoing Via: headers) + # Set to one of: Off | On | Full | Block + ProxyVia On + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/proxy_html.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/proxy_html.conf.erb new file mode 100644 index 0000000000..fea15f393f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/proxy_html.conf.erb @@ -0,0 +1,18 @@ +ProxyHTMLLinks a href +ProxyHTMLLinks area href +ProxyHTMLLinks link href +ProxyHTMLLinks img src longdesc usemap +ProxyHTMLLinks object classid codebase data usemap +ProxyHTMLLinks q cite +ProxyHTMLLinks blockquote cite +ProxyHTMLLinks ins cite +ProxyHTMLLinks del cite +ProxyHTMLLinks form action +ProxyHTMLLinks input src usemap +ProxyHTMLLinks head profileProxyHTMLLinks base href +ProxyHTMLLinks script src for + +ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \ + onmouseover onmousemove onmouseout onkeypress \ + onkeydown onkeyup onfocus onblur onload \ + onunload onsubmit onreset onselect onchange diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/reqtimeout.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/reqtimeout.conf.erb new file mode 100644 index 0000000000..9a18800da5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/reqtimeout.conf.erb @@ -0,0 +1,2 @@ +RequestReadTimeout header=20-40,minrate=500 +RequestReadTimeout body=10,minrate=500 diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/rpaf.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/rpaf.conf.erb new file mode 100644 index 0000000000..56e2398b55 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/rpaf.conf.erb @@ -0,0 +1,15 @@ +# Enable reverse proxy add forward +RPAFenable On +# RPAFsethostname will, when enabled, take the incoming X-Host header and +# update the virtual host settings accordingly. This allows to have the same +# hostnames as in the "real" configuration for the forwarding proxy. +<% if @sethostname -%> +RPAFsethostname On +<% else -%> +RPAFsethostname Off +<% end -%> +# Which IPs are forwarding requests to us +RPAFproxy_ips <%= Array(@proxy_ips).join(" ") %> +# Setting RPAFheader allows you to change the header name to parse from the +# default X-Forwarded-For to something of your choice. +RPAFheader <%= @header %> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/setenvif.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/setenvif.conf.erb new file mode 100644 index 0000000000..d31c79fe5d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/setenvif.conf.erb @@ -0,0 +1,34 @@ +# +# The following directives modify normal HTTP response behavior to +# handle known problems with browser implementations. +# +BrowserMatch "Mozilla/2" nokeepalive +BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0 +BrowserMatch "RealPlayer 4\.0" force-response-1.0 +BrowserMatch "Java/1\.0" force-response-1.0 +BrowserMatch "JDK/1\.0" force-response-1.0 + +# +# The following directive disables redirects on non-GET requests for +# a directory that does not include the trailing slash. This fixes a +# problem with Microsoft WebFolders which does not appropriately handle +# redirects for folders with DAV methods. +# Same deal with Apple's DAV filesystem and Gnome VFS support for DAV. +# +BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully +BrowserMatch "MS FrontPage" redirect-carefully +BrowserMatch "^WebDrive" redirect-carefully +BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully +BrowserMatch "^gnome-vfs/1.0" redirect-carefully +BrowserMatch "^gvfs/1" redirect-carefully +BrowserMatch "^XML Spy" redirect-carefully +BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully +BrowserMatch " Konqueror/4" redirect-carefully + + + BrowserMatch "MSIE [2-6]" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + # MSIE 7 and newer should be able to use keepalive + BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/ssl.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/ssl.conf.erb new file mode 100644 index 0000000000..24274050c2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/ssl.conf.erb @@ -0,0 +1,28 @@ + + SSLRandomSeed startup builtin + SSLRandomSeed startup file:/dev/urandom 512 + SSLRandomSeed connect builtin + SSLRandomSeed connect file:/dev/urandom 512 + + AddType application/x-x509-ca-cert .crt + AddType application/x-pkcs7-crl .crl + + SSLPassPhraseDialog builtin + SSLSessionCache "shmcb:<%= @session_cache %>" + SSLSessionCacheTimeout 300 +<% if @ssl_compression -%> + SSLCompression On +<% end -%> + <% if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Mutex <%= @ssl_mutex %> + <% else -%> + SSLMutex <%= @ssl_mutex %> + <% end -%> + SSLCryptoDevice builtin + SSLHonorCipherOrder On + SSLCipherSuite <%= @ssl_cipher %> + SSLProtocol all -SSLv2 +<% if @ssl_options -%> + SSLOptions <%= @ssl_options.compact.join(' ') %> +<% end -%> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/status.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/status.conf.erb new file mode 100644 index 0000000000..84f2e03430 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/status.conf.erb @@ -0,0 +1,16 @@ + + SetHandler server-status + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require ip <%= Array(@allow_from).join(" ") %> + <%- else -%> + Order deny,allow + Deny from all + Allow from <%= Array(@allow_from).join(" ") %> + <%- end -%> + +ExtendedStatus <%= @extended_status %> + + + # Show Proxy LoadBalancer status in mod_status + ProxyStatus On + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/suphp.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/suphp.conf.erb new file mode 100644 index 0000000000..95fbf97c78 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/suphp.conf.erb @@ -0,0 +1,19 @@ + + AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml + suPHP_AddHandler application/x-httpd-suphp + + + suPHP_Engine on + + + # By default, disable suPHP for debian packaged web applications as files + # are owned by root and cannot be executed by suPHP because of min_uid. + + suPHP_Engine off + + +# # Use a specific php config file (a dir which contains a php.ini file) +# suPHP_ConfigPath /etc/php4/cgi/suphp/ +# # Tells mod_suphp NOT to handle requests with the type . +# suPHP_RemoveHandler + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/userdir.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/userdir.conf.erb new file mode 100644 index 0000000000..add525d5ea --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/userdir.conf.erb @@ -0,0 +1,27 @@ + +<% if @disable_root -%> + UserDir disabled root +<% end -%> + UserDir <%= @dir %> + + /*/<%= @dir %>"> + AllowOverride FileInfo AuthConfig Limit Indexes + Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec + + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require all denied + <%- else -%> + Order allow,deny + Allow from all + <%- end -%> + + + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require all denied + <%- else -%> + Order allow,deny + Allow from all + <%- end -%> + + + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/worker.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/worker.conf.erb new file mode 100644 index 0000000000..597e05f8d5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/worker.conf.erb @@ -0,0 +1,10 @@ + + ServerLimit <%= @serverlimit %> + StartServers <%= @startservers %> + MaxClients <%= @maxclients %> + MinSpareThreads <%= @minsparethreads %> + MaxSpareThreads <%= @maxsparethreads %> + ThreadsPerChild <%= @threadsperchild %> + MaxRequestsPerChild <%= @maxrequestsperchild %> + ThreadLimit <%= @threadlimit %> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/wsgi.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/wsgi.conf.erb new file mode 100644 index 0000000000..18752d2c4a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/mod/wsgi.conf.erb @@ -0,0 +1,13 @@ +# The WSGI Apache module configuration file is being +# managed by Puppet an changes will be overwritten. + + <%- if @wsgi_socket_prefix -%> + WSGISocketPrefix <%= @wsgi_socket_prefix %> + <%- end -%> + <%- if @wsgi_python_home -%> + WSGIPythonHome "<%= @wsgi_python_home %>" + <%- end -%> + <%- if @wsgi_python_path -%> + WSGIPythonPath "<%= @wsgi_python_path %>" + <%- end -%> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/namevirtualhost.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/namevirtualhost.erb new file mode 100644 index 0000000000..cf767680fc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/namevirtualhost.erb @@ -0,0 +1,8 @@ +<%# NameVirtualHost should always be one of: + - * + - *: + - _default_: + - + - : +-%> +NameVirtualHost <%= @addr_port %> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/ports_header.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/ports_header.erb new file mode 100644 index 0000000000..4908db4ad3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/ports_header.erb @@ -0,0 +1,5 @@ +# ************************************ +# Listen & NameVirtualHost resources in module puppetlabs-apache +# Managed by Puppet +# ************************************ + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost.conf.erb new file mode 100644 index 0000000000..64024cfef3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost.conf.erb @@ -0,0 +1,66 @@ +# ************************************ +# Vhost template in module puppetlabs-apache +# Managed by Puppet +# ************************************ + +> + ServerName <%= @servername %> +<% if @serveradmin -%> + ServerAdmin <%= @serveradmin %> +<% end -%> + + ## Vhost docroot +<% if @virtual_docroot -%> + VirtualDocumentRoot "<%= @virtual_docroot %>" +<% else -%> + DocumentRoot "<%= @docroot %>" +<% end -%> +<%= scope.function_template(['apache/vhost/_aliases.erb']) -%> + +<%= scope.function_template(['apache/vhost/_itk.erb']) -%> + +<% if @fallbackresource -%> + FallbackResource <%= @fallbackresource %> +<% end -%> + + ## Directories, there should at least be a declaration for <%= @docroot %> +<%= scope.function_template(['apache/vhost/_directories.erb']) -%> + + ## Load additional static includes +<% Array(@additional_includes).each do |include| %> + Include "<%= include %>" +<% end %> + + ## Logging +<% if @error_log -%> + ErrorLog "<%= @error_log_destination %>" +<% end -%> +<% if @log_level -%> + LogLevel <%= @log_level %> +<% end -%> + ServerSignature Off +<% if @access_log and @_access_log_env_var -%> + CustomLog "<%= @access_log_destination %>" <%= @_access_log_format %> <%= @_access_log_env_var %> +<% elsif @access_log -%> + CustomLog "<%= @access_log_destination %>" <%= @_access_log_format %> +<% end -%> +<%= scope.function_template(['apache/vhost/_action.erb']) -%> +<%= scope.function_template(['apache/vhost/_block.erb']) -%> +<%= scope.function_template(['apache/vhost/_error_document.erb']) -%> +<%= scope.function_template(['apache/vhost/_proxy.erb']) -%> +<%= scope.function_template(['apache/vhost/_rack.erb']) -%> +<%= scope.function_template(['apache/vhost/_redirect.erb']) -%> +<%= scope.function_template(['apache/vhost/_rewrite.erb']) -%> +<%= scope.function_template(['apache/vhost/_scriptalias.erb']) -%> +<%= scope.function_template(['apache/vhost/_serveralias.erb']) -%> +<%= scope.function_template(['apache/vhost/_setenv.erb']) -%> +<%= scope.function_template(['apache/vhost/_ssl.erb']) -%> +<%= scope.function_template(['apache/vhost/_suphp.erb']) -%> +<%= scope.function_template(['apache/vhost/_php_admin.erb']) -%> +<%= scope.function_template(['apache/vhost/_header.erb']) -%> +<%= scope.function_template(['apache/vhost/_requestheader.erb']) -%> +<%= scope.function_template(['apache/vhost/_wsgi.erb']) -%> +<%= scope.function_template(['apache/vhost/_custom_fragment.erb']) -%> +<%= scope.function_template(['apache/vhost/_fastcgi.erb']) -%> +<%= scope.function_template(['apache/vhost/_suexec.erb']) -%> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_action.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_action.erb new file mode 100644 index 0000000000..8a02290595 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_action.erb @@ -0,0 +1,4 @@ +<% if @action -%> + + Action <%= @action %> /cgi-bin virtual +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_aliases.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_aliases.erb new file mode 100644 index 0000000000..5fdd76ba24 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_aliases.erb @@ -0,0 +1,12 @@ +<% if @aliases and ! @aliases.empty? -%> + ## Alias declarations for resources outside the DocumentRoot + <%- [@aliases].flatten.compact.each do |alias_statement| -%> + <%- if alias_statement["path"] != '' -%> + <%- if alias_statement["alias"] and alias_statement["alias"] != '' -%> + Alias <%= alias_statement["alias"] %> "<%= alias_statement["path"] %>" + <%- elsif alias_statement["aliasmatch"] and alias_statement["aliasmatch"] != '' -%> + AliasMatch <%= alias_statement["aliasmatch"] %> "<%= alias_statement["path"] %>" + <%- end -%> + <%- end -%> + <%- end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_block.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_block.erb new file mode 100644 index 0000000000..d0776829da --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_block.erb @@ -0,0 +1,14 @@ +<% if @block and ! @block.empty? -%> + + ## Block access statements +<% if @block.include? 'scm' -%> + # Block access to SCM directories. + + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require all denied + <%- else -%> + Deny From All + <%- end -%> + +<% end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_custom_fragment.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_custom_fragment.erb new file mode 100644 index 0000000000..973964655e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_custom_fragment.erb @@ -0,0 +1,5 @@ +<% if @custom_fragment -%> + + ## Custom fragment +<%= @custom_fragment %> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_directories.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_directories.erb new file mode 100644 index 0000000000..f4307c7618 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_directories.erb @@ -0,0 +1,171 @@ +<% if @_directories and ! @_directories.empty? -%> + <%- [@_directories].flatten.compact.each do |directory| -%> + <%- if directory['path'] and directory['path'] != '' -%> + <%- if directory['provider'] and directory['provider'].match('(directory|location|files)') -%> + <%- if /^(.*)match$/ =~ directory['provider'] -%> + <%- provider = $1.capitalize + 'Match' -%> + <%- else -%> + <%- provider = directory['provider'].capitalize -%> + <%- end -%> + <%- else -%> + <%- provider = 'Directory' -%> + <%- end -%> + <%- path = directory['path'] -%> + + <<%= provider %> "<%= path %>"> + <%- if directory['headers'] -%> + <%- Array(directory['headers']).each do |header| -%> + Header <%= header %> + <%- end -%> + <%- end -%> + <%- if directory['options'] -%> + Options <%= Array(directory['options']).join(' ') %> + <%- end -%> + <%- if provider == 'Directory' -%> + <%- if directory['index_options'] -%> + IndexOptions <%= Array(directory['index_options']).join(' ') %> + <%- end -%> + <%- if directory['index_order_default'] -%> + IndexOrderDefault <%= Array(directory['index_order_default']).join(' ') %> + <%- end -%> + <%- if directory['allow_override'] -%> + AllowOverride <%= Array(directory['allow_override']).join(' ') %> + <%- elsif provider == 'Directory' -%> + AllowOverride None + <%- end -%> + <%- end -%> + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + <%- if directory['require'] and directory['require'] != '' -%> + Require <%= Array(directory['require']).join(' ') %> + <%- else -%> + Require all granted + <%- end -%> + <%- else -%> + <%- if directory['order'] and directory['order'] != '' -%> + Order <%= Array(directory['order']).join(',') %> + <%- else -%> + Order allow,deny + <%- end -%> + <%- if directory['deny'] and directory['deny'] != '' -%> + Deny <%= directory['deny'] %> + <%- end -%> + <%- if directory['allow'] and ! [ false, 'false', '' ].include?(directory['allow']) -%> + <%- if directory['allow'].kind_of?(Array) -%> + <%- Array(directory['allow']).each do |access| -%> + Allow <%= access %> + <%- end -%> + <%- else -%> + Allow <%= directory['allow'] %> + <%- end -%> + <%- elsif [ 'from all', 'from All' ].include?(directory['deny']) -%> + <%- elsif ! directory['deny'] and [ false, 'false', '' ].include?(directory['allow']) -%> + Deny from all + <%- else -%> + Allow from all + <%- end -%> + <%- end -%> + <%- if directory['addhandlers'] and ! directory['addhandlers'].empty? -%> + <%- [directory['addhandlers']].flatten.compact.each do |addhandler| -%> + AddHandler <%= addhandler['handler'] %> <%= Array(addhandler['extensions']).join(' ') %> + <%- end -%> + <%- end -%> + <%- if directory['sethandler'] and directory['sethandler'] != '' -%> + SetHandler <%= directory['sethandler'] %> + <%- end -%> + <%- if directory['passenger_enabled'] and directory['passenger_enabled'] != '' -%> + PassengerEnabled <%= directory['passenger_enabled'] %> + <%- end -%> + <%- if directory['php_admin_flags'] and ! directory['php_admin_flags'].empty? -%> + <%- directory['php_admin_flags'].each do |flag,value| -%> + <%- value = if value =~ /true|yes|on|1/i then 'on' else 'off' end -%> + php_admin_flag <%= "#{flag} #{value}" %> + <%- end -%> + <%- end -%> + <%- if directory['php_admin_values'] and ! directory['php_admin_values'].empty? -%> + <%- directory['php_admin_values'].each do |key,value| -%> + php_admin_value <%= "#{key} #{value}" %> + <%- end -%> + <%- end -%> + <%- if directory['directoryindex'] and directory['directoryindex'] != '' -%> + DirectoryIndex <%= directory['directoryindex'] %> + <%- end -%> + <%- if directory['error_documents'] and ! directory['error_documents'].empty? -%> + <%- [directory['error_documents']].flatten.compact.each do |error_document| -%> + ErrorDocument <%= error_document['error_code'] %> <%= error_document['document'] %> + <%- end -%> + <%- end -%> + <%- if directory['auth_type'] -%> + AuthType <%= directory['auth_type'] %> + <%- end -%> + <%- if directory['auth_name'] -%> + AuthName "<%= directory['auth_name'] %>" + <%- end -%> + <%- if directory['auth_digest_algorithm'] -%> + AuthDigestAlgorithm <%= directory['auth_digest_algorithm'] %> + <%- end -%> + <%- if directory['auth_digest_domain'] -%> + AuthDigestDomain <%= Array(directory['auth_digest_domain']).join(' ') %> + <%- end -%> + <%- if directory['auth_digest_nonce_lifetime'] -%> + AuthDigestNonceLifetime <%= directory['auth_digest_nonce_lifetime'] %> + <%- end -%> + <%- if directory['auth_digest_provider'] -%> + AuthDigestProvider <%= directory['auth_digest_provider'] %> + <%- end -%> + <%- if directory['auth_digest_qop'] -%> + AuthDigestQop <%= directory['auth_digest_qop'] %> + <%- end -%> + <%- if directory['auth_digest_shmem_size'] -%> + AuthDigestShmemSize <%= directory['auth_digest_shmem_size'] %> + <%- end -%> + <%- if directory['auth_basic_authoritative'] -%> + AuthBasicAuthoritative <%= directory['auth_basic_authoritative'] %> + <%- end -%> + <%- if directory['auth_basic_fake'] -%> + AuthBasicFake <%= directory['auth_basic_fake'] %> + <%- end -%> + <%- if directory['auth_basic_provider'] -%> + AuthBasicProvider <%= directory['auth_basic_provider'] %> + <%- end -%> + <%- if directory['auth_user_file'] -%> + AuthUserFile <%= directory['auth_user_file'] %> + <%- end -%> + <%- if directory['auth_group_file'] -%> + AuthGroupFile <%= directory['auth_group_file'] %> + <%- end -%> + <%- if directory['auth_require'] -%> + Require <%= directory['auth_require'] %> + <%- end -%> + <%- if directory['fallbackresource'] -%> + FallbackResource <%= directory['fallbackresource'] %> + <%- end -%> + <%- if directory['expires_active'] -%> + ExpiresActive <%= directory['expires_active'] %> + <%- end -%> + <%- if directory['expires_default'] -%> + ExpiresDefault <%= directory['expires_default'] %> + <%- end -%> + <%- if directory['expires_by_type'] -%> + <%- Array(directory['expires_by_type']).each do |rule| -%> + ExpiresByType <%= rule %> + <%- end -%> + <%- end -%> + <%- if directory['force_type'] -%> + ForceType <%= directory['force_type'] %> + <%- end -%> + <%- if directory['ssl_options'] -%> + SSLOptions <%= Array(directory['ssl_options']).join(' ') %> + <%- end -%> + <%- if directory['suphp'] and @suphp_engine == 'on' -%> + suPHP_UserGroup <%= directory['suphp']['user'] %> <%= directory['suphp']['group'] %> + <%- end -%> + <%- if directory['fcgiwrapper'] -%> + FcgidWrapper <%= directory['fcgiwrapper']['command'] %> <%= directory['fcgiwrapper']['suffix'] %> <%= directory['fcgiwrapper']['virtual'] %> + <%- end -%> + <%- if directory['custom_fragment'] -%> + <%= directory['custom_fragment'] %> + <%- end -%> + <%= provider %>> + <%- end -%> + <%- end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_error_document.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_error_document.erb new file mode 100644 index 0000000000..654e72c676 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_error_document.erb @@ -0,0 +1,7 @@ +<% if @error_documents and ! @error_documents.empty? -%> + <%- [@error_documents].flatten.compact.each do |error_document| -%> + <%- if error_document["error_code"] != '' and error_document["document"] != '' -%> + ErrorDocument <%= error_document["error_code"] %> <%= error_document["document"] %> + <%- end -%> + <%- end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_fastcgi.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_fastcgi.erb new file mode 100644 index 0000000000..3a2baa5596 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_fastcgi.erb @@ -0,0 +1,22 @@ +<% if @fastcgi_server -%> + + FastCgiExternalServer <%= @fastcgi_server %> -socket <%= @fastcgi_socket %> +<% end -%> +<% if @fastcgi_dir -%> + + "> + Options +ExecCGI + AllowOverride All + SetHandler fastcgi-script + <%- if scope.function_versioncmp([@apache_version, '2.4']) >= 0 -%> + Require all granted + <%- else -%> + Order allow,deny + Allow From All + <%- end -%> + AuthBasicAuthoritative Off + + + AllowEncodedSlashes On + ServerSignature Off +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_header.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_header.erb new file mode 100644 index 0000000000..c0f68c8257 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_header.erb @@ -0,0 +1,10 @@ +<% if @headers and ! @headers.empty? -%> + + ## Header rules + ## as per http://httpd.apache.org/docs/2.2/mod/mod_headers.html#header + <%- Array(@headers).each do |header_statement| -%> + <%- if header_statement != '' -%> + Header <%= header_statement %> + <%- end -%> + <%- end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_itk.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_itk.erb new file mode 100644 index 0000000000..2971c7a7d0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_itk.erb @@ -0,0 +1,28 @@ +<% if @itk and ! @itk.empty? -%> + ## ITK statement + + <%- if @itk["user"] and @itk["group"] -%> + AssignUserId <%= @itk["user"] %> <%= @itk["group"] %> + <%- end -%> + <%- if @itk["assignuseridexpr"] -%> + AssignUserIdExpr <%= @itk["assignuseridexpr"] %> + <%- end -%> + <%- if @itk["assigngroupidexpr"] -%> + AssignGroupIdExpr <%= @itk["assigngroupidexpr"] %> + <%- end -%> + <%- if @itk["maxclientvhost"] -%> + MaxClientsVHost <%= @itk["maxclientvhost"] %> + <%- end -%> + <%- if @itk["nice"] -%> + NiceValue <%= @itk["nice"] %> + <%- end -%> + <%- if @kernelversion >= '3.5.0' -%> + <%- if @itk["limituidrange"] -%> + LimitUIDRange <%= @itk["limituidrange"] %> + <%- end -%> + <%- if @itk["limitgidrange"] -%> + LimitGIDRange <%= @itk["limitgidrange"] %> + <%- end -%> + <%- end -%> + +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_php_admin.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_php_admin.erb new file mode 100644 index 0000000000..59536cbc99 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_php_admin.erb @@ -0,0 +1,12 @@ +<% if @php_admin_values and not @php_admin_values.empty? -%> +<% @php_admin_values.each do |key,value| -%> + php_admin_value <%= key %> <%= value %> +<% end -%> +<% end -%> +<% if @php_admin_flags and not @php_admin_flags.empty? -%> +<% @php_admin_flags.each do |key,flag| -%> +<%# normalize flag -%> +<% if flag =~ /true|yes|on|1/i then flag = 'on' else flag = 'off' end -%> + php_admin_flag <%= key %> <%= flag %> +<% end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_proxy.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_proxy.erb new file mode 100644 index 0000000000..a1d2e52923 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_proxy.erb @@ -0,0 +1,23 @@ +<% if @proxy_dest or @proxy_pass -%> + + ## Proxy rules + ProxyRequests Off +<%- end -%> +<% if @proxy_preserve_host %> + ProxyPreserveHost On +<%- end -%> +<%- [@proxy_pass].flatten.compact.each do |proxy| -%> + ProxyPass <%= proxy['path'] %> <%= proxy['url'] %> + > + ProxyPassReverse <%= proxy['url'] %> + +<% end %> +<% if @proxy_dest -%> +<%- Array(@no_proxy_uris).each do |uri| -%> + ProxyPass <%= uri %> ! +<% end %> + ProxyPass / <%= @proxy_dest %>/ + + ProxyPassReverse <%= @proxy_dest %>/ + +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_rack.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_rack.erb new file mode 100644 index 0000000000..4a5b5f1cdc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_rack.erb @@ -0,0 +1,7 @@ +<% if @rack_base_uris -%> + + ## Enable rack +<% Array(@rack_base_uris).each do |uri| -%> + RackBaseURI <%= uri %> +<% end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_redirect.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_redirect.erb new file mode 100644 index 0000000000..e865bd9afa --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_redirect.erb @@ -0,0 +1,24 @@ +<% if @redirect_source and @redirect_dest -%> +<% @redirect_dest_a = Array(@redirect_dest) -%> +<% @redirect_source_a = Array(@redirect_source) -%> +<% @redirect_status_a = Array(@redirect_status) -%> + + ## Redirect rules +<% @redirect_source_a.each_with_index do |source, i| -%> +<% @redirect_dest_a[i] ||= @redirect_dest_a[0] -%> +<% @redirect_status_a[i] ||= @redirect_status_a[0] -%> + Redirect <%= "#{@redirect_status_a[i]} " %><%= source %> <%= @redirect_dest_a[i] %> +<% end -%> +<% end -%> + +<%- if @redirectmatch_status and @redirectmatch_regexp -%> +<% @redirectmatch_status_a = Array(@redirectmatch_status) -%> +<% @redirectmatch_regexp_a = Array(@redirectmatch_regexp) -%> + + ## RedirectMatch rules +<% @redirectmatch_status_a.each_with_index do |status, i| -%> +<% @redirectmatch_status_a[i] ||= @redirectmatch_status_a[0] -%> +<% @redirectmatch_regexp_a[i] ||= @redirectmatch_regexp_a[0] -%> + RedirectMatch <%= "#{@redirectmatch_status_a[i]} " %> <%= @redirectmatch_regexp_a[i] %> +<% end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_requestheader.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_requestheader.erb new file mode 100644 index 0000000000..9f175052b5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_requestheader.erb @@ -0,0 +1,10 @@ +<% if @request_headers and ! @request_headers.empty? -%> + + ## Request header rules + ## as per http://httpd.apache.org/docs/2.2/mod/mod_headers.html#requestheader + <%- Array(@request_headers).each do |request_statement| -%> + <%- if request_statement != '' -%> + RequestHeader <%= request_statement %> + <%- end -%> + <%- end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_rewrite.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_rewrite.erb new file mode 100644 index 0000000000..af8b45001e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_rewrite.erb @@ -0,0 +1,43 @@ +<%- if @rewrites -%> + ## Rewrite rules + RewriteEngine On + <%- if @rewrite_base -%> + RewriteBase <%= @rewrite_base %> + <%- end -%> + + <%- [@rewrites].flatten.compact.each do |rewrite_details| -%> + <%- if rewrite_details['comment'] -%> + #<%= rewrite_details['comment'] %> + <%- end -%> + <%- if rewrite_details['rewrite_base'] -%> + RewriteBase <%= rewrite_details['rewrite_base'] %> + <%- end -%> + <%- if rewrite_details['rewrite_cond'] -%> + <%- Array(rewrite_details['rewrite_cond']).each do |commands| -%> + <%- Array(commands).each do |command| -%> + RewriteCond <%= command %> + <%- end -%> + <%- end -%> + <%- end -%> + <%- Array(rewrite_details['rewrite_rule']).each do |commands| -%> + <%- Array(commands).each do |command| -%> + RewriteRule <%= command %> + <%- end -%> + + <%- end -%> + <%- end -%> +<%- end -%> +<%# reverse compatibility %> +<% if @rewrite_rule and !@rewrites -%> + ## Rewrite rules + RewriteEngine On +<% if @rewrite_base -%> + RewriteBase <%= @rewrite_base %> +<% end -%> +<% if @rewrite_cond -%> +<% Array(@rewrite_cond).each do |cond| -%> + RewriteCond <%= cond %> +<% end -%> +<% end -%> + RewriteRule <%= @rewrite_rule %> +<%- end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_scriptalias.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_scriptalias.erb new file mode 100644 index 0000000000..bb4f6b316e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_scriptalias.erb @@ -0,0 +1,24 @@ +<%- if @scriptaliases.is_a?(Array) -%> +<%- aliases = @scriptaliases -%> +<%- elsif @scriptaliases.is_a?(Hash) -%> +<%- aliases = [@scriptaliases] -%> +<%- else -%> +<%- # Nothing to do with any other data type -%> +<%- aliases = [] -%> +<%- end -%> +<%- if @scriptalias or !aliases.empty? -%> + ## Script alias directives +<%# Combine scriptalais and scriptaliases into a single data structure -%> +<%# for backward compatibility and ease of implementation -%> +<%- aliases << { 'alias' => '/cgi-bin', 'path' => @scriptalias } if @scriptalias -%> +<%- aliases.flatten.compact! -%> +<%- aliases.each do |salias| -%> + <%- if salias["path"] != '' -%> + <%- if salias["alias"] and salias["alias"] != '' -%> + ScriptAlias <%= salias['alias'] %> "<%= salias['path'] %>" + <%- elsif salias["aliasmatch"] and salias["aliasmatch"] != '' -%> + ScriptAliasMatch <%= salias['aliasmatch'] %> "<%= salias['path'] %>" + <%- end -%> + <%- end -%> +<%- end -%> +<%- end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_serveralias.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_serveralias.erb new file mode 100644 index 0000000000..278b6ddc53 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_serveralias.erb @@ -0,0 +1,7 @@ +<% if @serveraliases and ! @serveraliases.empty? -%> + + ## Server aliases +<% Array(@serveraliases).each do |serveralias| -%> + ServerAlias <%= serveralias %> +<% end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_setenv.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_setenv.erb new file mode 100644 index 0000000000..d5f9ea8450 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_setenv.erb @@ -0,0 +1,12 @@ +<% if @setenv and ! @setenv.empty? -%> + + ## SetEnv/SetEnvIf for environment variables +<% Array(@setenv).each do |envvar| -%> + SetEnv <%= envvar %> +<% end -%> +<% end -%> +<% if @setenvif and ! @setenvif.empty? -%> +<% Array(@setenvif).each do |envifvar| -%> + SetEnvIf <%= envifvar %> +<% end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_ssl.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_ssl.erb new file mode 100644 index 0000000000..03c78ef427 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_ssl.erb @@ -0,0 +1,41 @@ +<% if @ssl -%> + + ## SSL directives + SSLEngine on + SSLCertificateFile "<%= @ssl_cert %>" + SSLCertificateKeyFile "<%= @ssl_key %>" +<% if @ssl_chain -%> + SSLCertificateChainFile "<%= @ssl_chain %>" +<% end -%> + SSLCACertificatePath "<%= @ssl_certs_dir %>" +<% if @ssl_ca -%> + SSLCACertificateFile "<%= @ssl_ca %>" +<% end -%> +<% if @ssl_crl_path -%> + SSLCARevocationPath "<%= @ssl_crl_path %>" +<% end -%> +<% if @ssl_crl -%> + SSLCARevocationFile "<%= @ssl_crl %>" +<% end -%> +<% if @ssl_proxyengine -%> + SSLProxyEngine On +<% end -%> +<% if @ssl_protocol -%> + SSLProtocol <%= @ssl_protocol %> +<% end -%> +<% if @ssl_cipher -%> + SSLCipherSuite <%= @ssl_cipher %> +<% end -%> +<% if @ssl_honorcipherorder -%> + SSLHonorCipherOrder <%= @ssl_honorcipherorder %> +<% end -%> +<% if @ssl_verify_client -%> + SSLVerifyClient <%= @ssl_verify_client %> +<% end -%> +<% if @ssl_verify_depth -%> + SSLVerifyDepth <%= @ssl_verify_depth %> +<% end -%> +<% if @ssl_options -%> + SSLOptions <%= Array(@ssl_options).join(' ') %> +<% end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_suexec.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_suexec.erb new file mode 100644 index 0000000000..8a7ae0f17f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_suexec.erb @@ -0,0 +1,4 @@ +<% if @suexec_user_group -%> + + SuexecUserGroup <%= @suexec_user_group %> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_suphp.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_suphp.erb new file mode 100644 index 0000000000..9389581805 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_suphp.erb @@ -0,0 +1,11 @@ +<% if @suphp_engine == 'on' -%> +<% if @suphp_addhandler -%> + suPHP_AddHandler <%= @suphp_addhandler %> +<% end -%> +<% if @suphp_engine -%> + suPHP_Engine <%= @suphp_engine %> +<% end -%> +<% if @suphp_configpath -%> + suPHP_ConfigPath "<%= @suphp_configpath %>" +<% end -%> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_wsgi.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_wsgi.erb new file mode 100644 index 0000000000..473b223ab6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/templates/vhost/_wsgi.erb @@ -0,0 +1,24 @@ +<% if @wsgi_application_group -%> + WSGIApplicationGroup <%= @wsgi_application_group %> +<% end -%> +<% if @wsgi_daemon_process and @wsgi_daemon_process_options -%> + WSGIDaemonProcess <%= @wsgi_daemon_process %> <%= @wsgi_daemon_process_options.collect { |k,v| "#{k}=#{v}"}.sort.join(' ') %> +<% elsif @wsgi_daemon_process and !@wsgi_daemon_process_options -%> + WSGIDaemonProcess <%= @wsgi_daemon_process %> +<% end -%> +<% if @wsgi_import_script and @wsgi_import_script_options -%> + WSGIImportScript <%= @wsgi_import_script %> <%= @wsgi_import_script_options.collect { |k,v| "#{k}=#{v}"}.sort.join(' ') %> +<% end -%> +<% if @wsgi_process_group -%> + WSGIProcessGroup <%= @wsgi_process_group %> +<% end -%> +<% if @wsgi_script_aliases and ! @wsgi_script_aliases.empty? -%> + <%- @wsgi_script_aliases.each do |a, p| -%> + <%- if a != '' and p != ''-%> + WSGIScriptAlias <%= a %> "<%= p %>" + <%- end -%> + <%- end -%> +<% end -%> +<% if @wsgi_pass_authorization -%> + WSGIPassAuthorization <%= @wsgi_pass_authorization %> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/apache.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/apache.pp new file mode 100644 index 0000000000..0d4543564c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/apache.pp @@ -0,0 +1,6 @@ +include apache +include apache::mod::php +include apache::mod::cgi +include apache::mod::userdir +include apache::mod::disk_cache +include apache::mod::proxy_http diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/dev.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/dev.pp new file mode 100644 index 0000000000..805ad7e373 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/dev.pp @@ -0,0 +1 @@ +include apache::dev diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/init.pp new file mode 100644 index 0000000000..b3f9f13aac --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/init.pp @@ -0,0 +1 @@ +include apache diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/mod_load_params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/mod_load_params.pp new file mode 100644 index 0000000000..0e84c5efbf --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/mod_load_params.pp @@ -0,0 +1,11 @@ +# Tests the path and identifier parameters for the apache::mod class + +# Base class for clarity: +class { 'apache': } + + +# Exaple parameter usage: +apache::mod { 'testmod': + path => '/usr/some/path/mod_testmod.so', + id => 'testmod_custom_name', +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/mods.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/mods.pp new file mode 100644 index 0000000000..59362bd9a0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/mods.pp @@ -0,0 +1,9 @@ +## Default mods + +# Base class. Declares default vhost on port 80 and default ssl +# vhost on port 443 listening on all interfaces and serving +# $apache::docroot, and declaring our default set of modules. +class { 'apache': + default_mods => true, +} + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/mods_custom.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/mods_custom.pp new file mode 100644 index 0000000000..0ae699c73d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/mods_custom.pp @@ -0,0 +1,16 @@ +## custom mods + +# Base class. Declares default vhost on port 80 and default ssl +# vhost on port 443 listening on all interfaces and serving +# $apache::docroot, and declaring a custom set of modules. +class { 'apache': + default_mods => [ + 'info', + 'alias', + 'mime', + 'env', + 'setenv', + 'expires', + ], +} + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/php.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/php.pp new file mode 100644 index 0000000000..1d926bfb46 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/php.pp @@ -0,0 +1,4 @@ +class { 'apache': + mpm_module => 'prefork', +} +include apache::mod::php diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost.pp new file mode 100644 index 0000000000..a6c61360a7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost.pp @@ -0,0 +1,238 @@ +## Default vhosts, and custom vhosts +# NB: Please see the other vhost_*.pp example files for further +# examples. + +# Base class. Declares default vhost on port 80 and default ssl +# vhost on port 443 listening on all interfaces and serving +# $apache::docroot +class { 'apache': } + +# Most basic vhost +apache::vhost { 'first.example.com': + port => '80', + docroot => '/var/www/first', +} + +# Vhost with different docroot owner/group/mode +apache::vhost { 'second.example.com': + port => '80', + docroot => '/var/www/second', + docroot_owner => 'third', + docroot_group => 'third', + docroot_mode => '0770', +} + +# Vhost with serveradmin +apache::vhost { 'third.example.com': + port => '80', + docroot => '/var/www/third', + serveradmin => 'admin@example.com', +} + +# Vhost with ssl (uses default ssl certs) +apache::vhost { 'ssl.example.com': + port => '443', + docroot => '/var/www/ssl', + ssl => true, +} + +# Vhost with ssl and specific ssl certs +apache::vhost { 'fourth.example.com': + port => '443', + docroot => '/var/www/fourth', + ssl => true, + ssl_cert => '/etc/ssl/fourth.example.com.cert', + ssl_key => '/etc/ssl/fourth.example.com.key', +} + +# Vhost with english title and servername parameter +apache::vhost { 'The fifth vhost': + servername => 'fifth.example.com', + port => '80', + docroot => '/var/www/fifth', +} + +# Vhost with server aliases +apache::vhost { 'sixth.example.com': + serveraliases => [ + 'sixth.example.org', + 'sixth.example.net', + ], + port => '80', + docroot => '/var/www/fifth', +} + +# Vhost with alternate options +apache::vhost { 'seventh.example.com': + port => '80', + docroot => '/var/www/seventh', + options => [ + 'Indexes', + 'MultiViews', + ], +} + +# Vhost with AllowOverride for .htaccess +apache::vhost { 'eighth.example.com': + port => '80', + docroot => '/var/www/eighth', + override => 'All', +} + +# Vhost with access and error logs disabled +apache::vhost { 'ninth.example.com': + port => '80', + docroot => '/var/www/ninth', + access_log => false, + error_log => false, +} + +# Vhost with custom access and error logs and logroot +apache::vhost { 'tenth.example.com': + port => '80', + docroot => '/var/www/tenth', + access_log_file => 'tenth_vhost.log', + error_log_file => 'tenth_vhost_error.log', + logroot => '/var/log', +} + +# Vhost with a cgi-bin +apache::vhost { 'eleventh.example.com': + port => '80', + docroot => '/var/www/eleventh', + scriptalias => '/usr/lib/cgi-bin', +} + +# Vhost with a proxypass configuration +apache::vhost { 'twelfth.example.com': + port => '80', + docroot => '/var/www/twelfth', + proxy_dest => 'http://internal.example.com:8080/twelfth', + no_proxy_uris => ['/login','/logout'], +} + +# Vhost to redirect /login and /logout +apache::vhost { 'thirteenth.example.com': + port => '80', + docroot => '/var/www/thirteenth', + redirect_source => [ + '/login', + '/logout', + ], + redirect_dest => [ + 'http://10.0.0.10/login', + 'http://10.0.0.10/logout', + ], +} + +# Vhost to permamently redirect +apache::vhost { 'fourteenth.example.com': + port => '80', + docroot => '/var/www/fourteenth', + redirect_source => '/blog', + redirect_dest => 'http://blog.example.com', + redirect_status => 'permanent', +} + +# Vhost with a rack configuration +apache::vhost { 'fifteenth.example.com': + port => '80', + docroot => '/var/www/fifteenth', + rack_base_uris => ['/rackapp1', '/rackapp2'], +} + +# Vhost to redirect non-ssl to ssl +apache::vhost { 'sixteenth.example.com non-ssl': + servername => 'sixteenth.example.com', + port => '80', + docroot => '/var/www/sixteenth', + rewrites => [ + { + comment => 'redirect non-SSL traffic to SSL site', + rewrite_cond => ['%{HTTPS} off'], + rewrite_rule => ['(.*) https://%{HTTPS_HOST}%{REQUEST_URI}'], + } + ] +} +apache::vhost { 'sixteenth.example.com ssl': + servername => 'sixteenth.example.com', + port => '443', + docroot => '/var/www/sixteenth', + ssl => true, +} + +# Vhost to redirect non-ssl to ssl using old rewrite method +apache::vhost { 'sixteenth.example.com non-ssl old rewrite': + servername => 'sixteenth.example.com', + port => '80', + docroot => '/var/www/sixteenth', + rewrite_cond => '%{HTTPS} off', + rewrite_rule => '(.*) https://%{HTTPS_HOST}%{REQUEST_URI}', +} +apache::vhost { 'sixteenth.example.com ssl old rewrite': + servername => 'sixteenth.example.com', + port => '443', + docroot => '/var/www/sixteenth', + ssl => true, +} + +# Vhost to block repository files +apache::vhost { 'seventeenth.example.com': + port => '80', + docroot => '/var/www/seventeenth', + block => 'scm', +} + +# Vhost with special environment variables +apache::vhost { 'eighteenth.example.com': + port => '80', + docroot => '/var/www/eighteenth', + setenv => ['SPECIAL_PATH /foo/bin','KILROY was_here'], +} + +apache::vhost { 'nineteenth.example.com': + port => '80', + docroot => '/var/www/nineteenth', + setenvif => 'Host "^([^\.]*)\.website\.com$" CLIENT_NAME=$1', +} + +# Vhost with additional include files +apache::vhost { 'twentyieth.example.com': + port => '80', + docroot => '/var/www/twelfth', + additional_includes => ['/tmp/proxy_group_a','/tmp/proxy_group_b'], +} + +# Vhost with alias for subdomain mapped to same named directory +# http://example.com.loc => /var/www/example.com +apache::vhost { 'subdomain.loc': + vhost_name => '*', + port => '80', + virtual_docroot => '/var/www/%-2+', + docroot => '/var/www', + serveraliases => ['*.loc',], +} + +# Vhost with SSLProtocol,SSLCipherSuite, SSLHonorCipherOrder +apache::vhost { 'securedomain.com': + priority => '10', + vhost_name => 'www.securedomain.com', + port => '443', + docroot => '/var/www/secure', + ssl => true, + ssl_cert => '/etc/ssl/securedomain.cert', + ssl_key => '/etc/ssl/securedomain.key', + ssl_chain => '/etc/ssl/securedomain.crt', + ssl_protocol => '-ALL +SSLv3 +TLSv1', + ssl_cipher => 'ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM', + ssl_honorcipherorder => 'On', + add_listen => false, +} + +# Vhost with access log environment variables writing control +apache::vhost { 'twentyfirst.example.com': + port => '80', + docroot => '/var/www/twentyfirst', + access_log_env_var => 'admin', +} + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost_directories.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost_directories.pp new file mode 100644 index 0000000000..b8953ee321 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost_directories.pp @@ -0,0 +1,44 @@ +# Base class. Declares default vhost on port 80 and default ssl +# vhost on port 443 listening on all interfaces and serving +# $apache::docroot +class { 'apache': } + +# Example from README adapted. +apache::vhost { 'readme.example.net': + docroot => '/var/www/readme', + directories => [ + { + 'path' => '/var/www/readme', + 'ServerTokens' => 'prod' , + }, + { + 'path' => '/usr/share/empty', + 'allow' => 'from all', + }, + ], +} + +# location test +apache::vhost { 'location.example.net': + docroot => '/var/www/location', + directories => [ + { + 'path' => '/location', + 'provider' => 'location', + 'ServerTokens' => 'prod' + }, + ], +} + +# files test, curedly disable access to accidental backup files. +apache::vhost { 'files.example.net': + docroot => '/var/www/files', + directories => [ + { + 'path' => '(\.swp|\.bak|~)$', + 'provider' => 'filesmatch', + 'deny' => 'from all' + }, + ], +} + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost_ip_based.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost_ip_based.pp new file mode 100644 index 0000000000..dc0fa4f33b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost_ip_based.pp @@ -0,0 +1,25 @@ +## IP-based vhosts on any listen port +# IP-based vhosts respond to requests on specific IP addresses. + +# Base class. Turn off the default vhosts; we will be declaring +# all vhosts below. +class { 'apache': + default_vhost => false, +} + +# Listen on port 80 and 81; required because the following vhosts +# are not declared with a port parameter. +apache::listen { '80': } +apache::listen { '81': } + +# IP-based vhosts +apache::vhost { 'first.example.com': + ip => '10.0.0.10', + docroot => '/var/www/first', + ip_based => true, +} +apache::vhost { 'second.example.com': + ip => '10.0.0.11', + docroot => '/var/www/second', + ip_based => true, +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost_ssl.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost_ssl.pp new file mode 100644 index 0000000000..8e7a2b279e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhost_ssl.pp @@ -0,0 +1,23 @@ +## SSL-enabled vhosts +# SSL-enabled vhosts respond only to HTTPS queries. + +# Base class. Turn off the default vhosts; we will be declaring +# all vhosts below. +class { 'apache': + default_vhost => false, +} + +# Non-ssl vhost +apache::vhost { 'first.example.com non-ssl': + servername => 'first.example.com', + port => '80', + docroot => '/var/www/first', +} + +# SSL vhost at the same domain +apache::vhost { 'first.example.com ssl': + servername => 'first.example.com', + port => '443', + docroot => '/var/www/first', + ssl => true, +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhosts_without_listen.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhosts_without_listen.pp new file mode 100644 index 0000000000..e7d6cc036c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apache/tests/vhosts_without_listen.pp @@ -0,0 +1,53 @@ +## Declare ip-based and name-based vhosts +# Mixing Name-based vhost with IP-specific vhosts requires `add_listen => +# 'false'` on the non-IP vhosts + +# Base class. Turn off the default vhosts; we will be declaring +# all vhosts below. +class { 'apache': + default_vhost => false, +} + + +# Add two an IP-based vhost on 10.0.0.10, ssl and non-ssl +apache::vhost { 'The first IP-based vhost, non-ssl': + servername => 'first.example.com', + ip => '10.0.0.10', + port => '80', + ip_based => true, + docroot => '/var/www/first', +} +apache::vhost { 'The first IP-based vhost, ssl': + servername => 'first.example.com', + ip => '10.0.0.10', + port => '443', + ip_based => true, + docroot => '/var/www/first-ssl', + ssl => true, +} + +# Two name-based vhost listening on 10.0.0.20 +apache::vhost { 'second.example.com': + ip => '10.0.0.20', + port => '80', + docroot => '/var/www/second', +} +apache::vhost { 'third.example.com': + ip => '10.0.0.20', + port => '80', + docroot => '/var/www/third', +} + +# Two name-based vhosts without IPs specified, so that they will answer on either 10.0.0.10 or 10.0.0.20 . It is requried to declare +# `add_listen => 'false'` to disable declaring "Listen 80" which will conflict +# with the IP-based preceeding vhosts. +apache::vhost { 'fourth.example.com': + port => '80', + docroot => '/var/www/fourth', + add_listen => false, +} +apache::vhost { 'fifth.example.com': + port => '80', + docroot => '/var/www/fifth', + add_listen => false, +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.fixtures.yml new file mode 100644 index 0000000000..2bb941de23 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.fixtures.yml @@ -0,0 +1,7 @@ +fixtures: + repositories: + "stdlib": + "repo": "git://github.com/puppetlabs/puppetlabs-stdlib.git" + "ref": "v2.2.1" + symlinks: + "apt": "#{source_dir}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.project b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.project new file mode 100644 index 0000000000..6523c6dafa --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.project @@ -0,0 +1,23 @@ + + + apt + + + + + + org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.cloudsmith.geppetto.pp.dsl.ui.puppetNature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.puppet-lint.rc b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.puppet-lint.rc new file mode 100644 index 0000000000..f4abb47dc5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.puppet-lint.rc @@ -0,0 +1 @@ +--no-single_quote_string_with_variables-check diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.travis.yml new file mode 100644 index 0000000000..582efdf70a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/.travis.yml @@ -0,0 +1,41 @@ +--- +branches: + only: + - master +language: ruby +bundler_args: --without development +script: bundle exec rake spec SPEC_OPTS='--format documentation' +after_success: + - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release + - .forge-release/publish +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 +env: + matrix: + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.0.0" + - PUPPET_GEM_VERSION="~> 3.1.0" + - PUPPET_GEM_VERSION="~> 3.2.0" + global: + - PUBLISHER_LOGIN=puppetlabs + - secure: |- + ipB/CV1rVSTXU9ZDuzrFOlzJrRmJob36tKns2xszuH4r9s5P9qivNAngRGdV + msb69xvOlzQykM0WRF+4kJ6TZ7AbMiDI+VZ8GDtsRaU5/q3BpsvFe8aato+6 + QeyFtBG62OsosTEhGws4mqiFsPDu3dHlakuJc9zevlTuhNwbKSs= +matrix: + fast_finish: true + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.1.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 3.2.0" +notifications: + email: false diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/CHANGELOG.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/CHANGELOG.md new file mode 100644 index 0000000000..10503c9144 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/CHANGELOG.md @@ -0,0 +1,222 @@ +##2014-03-04 - Supported Release 1.4.2 +###Summary + +This is a supported release. This release tidies up 1.4.1 and re-enables +support for Ubuntu 10.04 + +####Features + +####Bugfixes +- Fix apt:ppa to include the -y Ubuntu 10.04 requires. +- Documentation changes. +- Test fixups. + +####Known Bugs + +* No known issues. + + + +##2014-02-13 1.4.1 +###Summary +This is a bugfix release. + +####Bugfixes +- Fix apt::force unable to upgrade packages from releases other than its original +- Removed a few refeneces to aptitude instead of apt-get for portability +- Removed call to getparam() due to stdlib dependency +- Correct apt::source template when architecture is provided +- Retry package installs if apt is locked +- Use root to exec in apt::ppa +- Updated tests and converted acceptance tests to beaker + +##2013-10-08 - Release 1.4.0 + +###Summary + +Minor bugfix and allow the timeout to be adjusted. + +####Features +- Add an `updates_timeout` to apt::params + +####Bugfixes +- Ensure apt::ppa can read a ppa removed by hand. + + +##2013-10-08 - Release 1.3.0 +###Summary + +This major feature in this release is the new apt::unattended_upgrades class, +allowing you to handle Ubuntu's unattended feature. This allows you to select +specific packages to automatically upgrade without any further user +involvement. + +In addition we extend our Wheezy support, add proxy support to apt:ppa and do +various cleanups and tweaks. + +####Features +- Add apt::unattended_upgrades support for Ubuntu. +- Add wheezy backports support. +- Use the geoDNS http.debian.net instead of the main debian ftp server. +- Add `options` parameter to apt::ppa in order to pass options to apt-add-repository command. +- Add proxy support for apt::ppa (uses proxy_host and proxy_port from apt). + +####Bugfixes +- Fix regsubst() calls to quote single letters (for future parser). +- Fix lint warnings and other misc cleanup. + + +##2013-07-03 - Release 1.2.0 + +####Features +- Add geppetto `.project` natures +- Add GH auto-release +- Add `apt::key::key_options` parameter +- Add complex pin support using distribution properties for `apt::pin` via new properties: + - `apt::pin::codename` + - `apt::pin::release_version` + - `apt::pin::component` + - `apt::pin::originator` + - `apt::pin::label` +- Add source architecture support to `apt::source::architecture` + +####Bugfixes +- Use apt-get instead of aptitude in apt::force +- Update default backports location +- Add dependency for required packages before apt-get update + + +##2013-06-02 - Release 1.1.1 +###Summary + +This is a bug fix release that resolves a number of issues: + +* By changing template variable usage, we remove the deprecation warnings + for Puppet 3.2.x +* Fixed proxy file removal, when proxy absent + +Some documentation, style and whitespaces changes were also merged. This +release also introduced proper rspec-puppet unit testing on Travis-CI to help +reduce regression. + +Thanks to all the community contributors below that made this patch possible. + +#### Detail Changes + +* fix minor comment type (Chris Rutter) +* whitespace fixes (Michael Moll) +* Update travis config file (William Van Hevelingen) +* Build all branches on travis (William Van Hevelingen) +* Standardize travis.yml on pattern introduced in stdlib (William Van Hevelingen) +* Updated content to conform to README best practices template (Lauren Rother) +* Fix apt::release example in readme (Brian Galey) +* add @ to variables in template (Peter Hoeg) +* Remove deprecation warnings for pin.pref.erb as well (Ken Barber) +* Update travis.yml to latest versions of puppet (Ken Barber) +* Fix proxy file removal (Scott Barber) +* Add spec test for removing proxy configuration (Dean Reilly) +* Fix apt::key listing longer than 8 chars (Benjamin Knofe) + + + + +## Release 1.1.0 +###Summary + +This release includes Ubuntu 12.10 (Quantal) support for PPAs. + +--- + +##2012-05-25 - Puppet Labs - Release 0.0.4 +###Summary + + * Fix ppa list filename when there is a period in the PPA name + * Add .pref extension to apt preferences files + * Allow preferences to be purged + * Extend pin support + + +##2012-05-04 - Puppet Labs - Release 0.0.3 +###Summary + + * only invoke apt-get update once + * only install python-software-properties if a ppa is added + * support 'ensure => absent' for all defined types + * add apt::conf + * add apt::backports + * fixed Modulefile for module tool dependency resolution + * configure proxy before doing apt-get update + * use apt-get update instead of aptitude for apt::ppa + * add support to pin release + + +##2012-03-26 - Puppet Labs - Release 0.0.2 +###Summary + +* 41cedbb (#13261) Add real examples to smoke tests. +* d159a78 (#13261) Add key.pp smoke test +* 7116c7a (#13261) Replace foo source with puppetlabs source +* 1ead0bf Ignore pkg directory. +* 9c13872 (#13289) Fix some more style violations +* 0ea4ffa (#13289) Change test scaffolding to use a module & manifest dir fixture path +* a758247 (#13289) Clean up style violations and fix corresponding tests +* 99c3fd3 (#13289) Add puppet lint tests to Rakefile +* 5148cbf (#13125) Apt keys should be case insensitive +* b9607a4 Convert apt::key to use anchors + + +##2012-03-07 - Puppet Labs - Release 0.0.1 +###Summary + +* d4fec56 Modify apt::source release parameter test +* 1132a07 (#12917) Add contributors to README +* 8cdaf85 (#12823) Add apt::key defined type and modify apt::source to use it +* 7c0d10b (#12809) $release should use $lsbdistcodename and fall back to manual input +* be2cc3e (#12522) Adjust spec test for splitting purge +* 7dc60ae (#12522) Split purge option to spare sources.list +* 9059c4e Fix source specs to test all key permutations +* 8acb202 Add test for python-software-properties package +* a4af11f Check if python-software-properties is defined before attempting to define it. +* 1dcbf3d Add tests for required_packages change +* f3735d2 Allow duplicate $required_packages +* 74c8371 (#12430) Add tests for changes to apt module +* 97ebb2d Test two sources with the same key +* 1160bcd (#12526) Add ability to reverse apt { disable_keys => true } +* 2842d73 Add Modulefile to puppet-apt +* c657742 Allow the use of the same key in multiple sources +* 8c27963 (#12522) Adding purge option to apt class +* 997c9fd (#12529) Add unit test for apt proxy settings +* 50f3cca (#12529) Add parameter to support setting a proxy for apt +* d522877 (#12094) Replace chained .with_* with a hash +* 8cf1bd0 (#12094) Remove deprecated spec.opts file +* 2d688f4 (#12094) Add rspec-puppet tests for apt +* 0fb5f78 (#12094) Replace name with path in file resources +* f759bc0 (#11953) Apt::force passes $version to aptitude +* f71db53 (#11413) Add spec test for apt::force to verify changes to unless +* 2f5d317 (#11413) Update dpkg query used by apt::force +* cf6caa1 (#10451) Add test coverage to apt::ppa +* 0dd697d include_src parameter in example; Whitespace cleanup +* b662eb8 fix typos in "repositories" +* 1be7457 Fix (#10451) - apt::ppa fails to "apt-get update" when new PPA source is added +* 864302a Set the pin priority before adding the source (Fix #10449) +* 1de4e0a Refactored as per mlitteken +* 1af9a13 Added some crazy bash madness to check if the ppa is installed already. Otherwise the manifest tries to add it on every run! +* 52ca73e (#8720) Replace Apt::Ppa with Apt::Builddep +* 5c05fa0 added builddep command. +* a11af50 added the ability to specify the content of a key +* c42db0f Fixes ppa test. +* 77d2b0d reformatted whitespace to match recommended style of 2 space indentation. +* 27ebdfc ignore swap files. +* 377d58a added smoke tests for module. +* 18f614b reformatted apt::ppa according to recommended style. +* d8a1e4e Created a params class to hold global data. +* 636ae85 Added two params for apt class +* 148fc73 Update LICENSE. +* ed2d19e Support ability to add more than one PPA +* 420d537 Add call to apt-update after add-apt-repository in apt::ppa +* 945be77 Add package definition for python-software-properties +* 71fc425 Abs paths for all commands +* 9d51cd1 Adding LICENSE +* 71796e3 Heading fix in README +* 87777d8 Typo in README +* f848bac First commit diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/Gemfile new file mode 100644 index 0000000000..1e359d07b5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/Gemfile @@ -0,0 +1,18 @@ +source ENV['GEM_SOURCE'] || 'https://rubygems.org' + +group :development, :test do + gem 'rake', :require => false + gem 'pry', :require => false + gem 'rspec-puppet', :require => false + gem 'puppet-lint', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'serverspec', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/LICENSE new file mode 100644 index 0000000000..30ce036d5e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/LICENSE @@ -0,0 +1,34 @@ +Copyright (c) 2011 Evolving Web Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +Copyright 2014 Puppet Labs + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/Modulefile new file mode 100644 index 0000000000..40a87f4ef3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/Modulefile @@ -0,0 +1,14 @@ +name 'puppetlabs-apt' +version '1.4.2' +source 'https://github.com/puppetlabs/puppetlabs-apt' +author 'Evolving Web / Puppet Labs' +license 'Apache License 2.0' +summary 'Puppet Labs Apt Module' +description 'APT Module for Puppet' +project_page 'https://github.com/puppetlabs/puppetlabs-apt' + +## Add dependencies, if any: +#dependency 'puppetlabs/stdlib', '2.x' +# The dependency should be written as above but librarian-puppet +# does not support the expression as the PMT does. +dependency 'puppetlabs/stdlib', '>= 2.2.1' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/README.md new file mode 100644 index 0000000000..ec8b4c5e49 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/README.md @@ -0,0 +1,236 @@ +apt +=== + +[](https://travis-ci.org/puppetlabs/puppetlabs-apt) + +## Description + +Provides helpful definitions for dealing with Apt. + +======= + +Overview +-------- + +The APT module provides a simple interface for managing APT source, key, and definitions with Puppet. + +Module Description +------------------ + +APT automates obtaining and installing software packages on \*nix systems. + +Setup +----- + +**What APT affects:** + +* package/service/configuration files for APT +* your system's `sources.list` file and `sources.list.d` directory + * NOTE: Setting the `purge_sources_list` and `purge_sources_list_d` parameters to 'true' will destroy any existing content that was not declared with Puppet. The default for these parameters is 'false'. +* system repositories +* authentication keys +* wget (optional) + +### Beginning with APT + +To begin using the APT module with default parameters, declare the class + + include apt + +Puppet code that uses anything from the APT module requires that the core apt class be declared/\s\+$//e + +Usage +----- + +Using the APT module consists predominantly in declaring classes that provide desired functionality and features. + +### apt + +`apt` provides a number of common resources and options that are shared by the various defined types in this module, so you MUST always include this class in your manifests. + +The parameters for `apt` are not required in general and are predominantly for development environment use-cases. + + class { 'apt': + always_apt_update => false, + disable_keys => undef, + proxy_host => false, + proxy_port => '8080', + purge_sources_list => false, + purge_sources_list_d => false, + purge_preferences_d => false, + update_timeout => undef + } + +Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content. + +If you declare your apt class with `purge_sources_list` and `purge_sources_list_d` set to 'true', Puppet will unapologetically purge any existing content it finds that wasn't declared with Puppet. + +### apt::builddep + +Installs the build depends of a specified package. + + apt::builddep { 'glusterfs-server': } + +### apt::force + +Forces a package to be installed from a specific release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. + + apt::force { 'glusterfs-server': + release => 'unstable', + version => '3.0.3', + require => Apt::Source['debian_unstable'], + } + +### apt::key + +Adds a key to the list of keys used by APT to authenticate packages. + + apt::key { 'puppetlabs': + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + + apt::key { 'jenkins': + key => 'D50582E6', + key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', + } + +Note that use of `key_source` requires wget to be installed and working. + +### apt::pin + +Adds an apt pin for a certain release. + + apt::pin { 'karmic': priority => 700 } + apt::pin { 'karmic-updates': priority => 700 } + apt::pin { 'karmic-security': priority => 700 } + +Note you can also specifying more complex pins using distribution properties. + + apt::pin { 'stable': + priority => -10, + originator => 'Debian', + release_version => '3.0', + component => 'main', + label => 'Debian' + } + +### apt::ppa + +Adds a ppa repository using `add-apt-repository`. + + apt::ppa { 'ppa:drizzle-developers/ppa': } + +### apt::release + +Sets the default apt release. This class is particularly useful when using repositories, like Debian, that are unstable in Ubuntu. + + class { 'apt::release': + release_id => 'precise', + } + +### apt::source + +Adds an apt source to `/etc/apt/sources.list.d/`. + + apt::source { 'debian_unstable': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'unstable', + repos => 'main contrib non-free', + required_packages => 'debian-keyring debian-archive-keyring', + key => '46925553', + key_server => 'subkeys.pgp.net', + pin => '-10', + include_src => true + } + +If you would like to configure your system so the source is the Puppet Labs APT repository + + apt::source { 'puppetlabs': + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + +### Testing + +The APT module is mostly a collection of defined resource types, which provide reusable logic that can be leveraged to manage APT. It does provide smoke tests for testing functionality on a target system, as well as spec tests for checking a compiled catalog against an expected set of resources. + +#### Example Test + +This test will set up a Puppet Labs apt repository. Start by creating a new smoke test in the apt module's test folder. Call it puppetlabs-apt.pp. Inside, declare a single resource representing the Puppet Labs APT source and gpg key + + apt::source { 'puppetlabs': + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + +This resource creates an apt source named puppetlabs and gives Puppet information about the repository's location and key used to sign its packages. Puppet leverages Facter to determine the appropriate release, but you can set it directly by adding the release type. + +Check your smoke test for syntax errors + + $ puppet parser validate tests/puppetlabs-apt.pp + +If you receive no output from that command, it means nothing is wrong. Then apply the code + + $ puppet apply --verbose tests/puppetlabs-apt.pp + notice: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]/ensure: defined content as '{md5}3be1da4923fb910f1102a233b77e982e' + info: /Stage[main]//Apt::Source[puppetlabs]/File[puppetlabs.list]: Scheduling refresh of Exec[puppetlabs apt update] + notice: /Stage[main]//Apt::Source[puppetlabs]/Exec[puppetlabs apt update]: Triggered 'refresh' from 1 events> + +The above example used a smoke test to easily lay out a resource declaration and apply it on your system. In production, you may want to declare your APT sources inside the classes where they’re needed. + +Implementation +-------------- + +### apt::backports + +Adds the necessary components to get backports for Ubuntu and Debian. The release name defaults to `$lsbdistcodename`. Setting this manually can cause undefined behavior (read: universe exploding). + +Limitations +----------- + +This module should work across all versions of Debian/Ubuntu and support all major APT repository management features. + +Development +------------ + +Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. + +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) + +License +------- + +The original code for this module comes from Evolving Web and was licensed under the MIT license. Code added since the fork of this module is licensed under the Apache 2.0 License like the rest of the Puppet Labs products. + +The LICENSE contains both licenses. + +Contributors +------------ + +A lot of great people have contributed to this module. A somewhat current list follows: + +* Ben Godfrey +* Branan Purvine-Riley +* Christian G. Warden +* Dan Bode +* Garrett Honeycutt +* Jeff Wallace +* Ken Barber +* Matthaus Litteken +* Matthias Pigulla +* Monty Taylor +* Peter Drake +* Reid Vandewiele +* Robert Navarro +* Ryan Coleman +* Scott McLeod +* Spencer Krum +* William Van Hevelingen +* Zach Leslie diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/Rakefile new file mode 100644 index 0000000000..6d067dc56c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/Rakefile @@ -0,0 +1,4 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.send('disable_single_quote_string_with_variables') diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/backports.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/backports.pp new file mode 100644 index 0000000000..9cfa1c0113 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/backports.pp @@ -0,0 +1,48 @@ +# This adds the necessary components to get backports for ubuntu and debian +# +# == Parameters +# +# [*release*] +# The ubuntu/debian release name. Defaults to $lsbdistcodename. Setting this +# manually can cause undefined behavior. (Read: universe exploding) +# +# == Examples +# +# include apt::backports +# +# class { 'apt::backports': +# release => 'natty', +# } +# +# == Authors +# +# Ben Hughes, I think. At least blame him if this goes wrong. +# I just added puppet doc. +# +# == Copyright +# +# Copyright 2011 Puppet Labs Inc, unless otherwise noted. +class apt::backports( + $release = $::lsbdistcodename, + $location = $apt::params::backports_location +) inherits apt::params { + + $release_real = downcase($release) + $key = $::lsbdistid ? { + 'debian' => '46925553', + 'ubuntu' => '437D05B5', + } + $repos = $::lsbdistid ? { + 'debian' => 'main contrib non-free', + 'ubuntu' => 'main universe multiverse restricted', + } + + apt::source { 'backports': + location => $location, + release => "${release_real}-backports", + repos => $repos, + key => $key, + key_server => 'pgp.mit.edu', + pin => '200', + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/builddep.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/builddep.pp new file mode 100644 index 0000000000..3294f71339 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/builddep.pp @@ -0,0 +1,16 @@ +# builddep.pp + +define apt::builddep() { + include apt::update + + exec { "apt-builddep-${name}": + command => "/usr/bin/apt-get -y --force-yes build-dep ${name}", + logoutput => 'on_failure', + notify => Exec['apt_update'], + } + + # Need anchor to provide containment for dependencies. + anchor { "apt::builddep::${name}": + require => Class['apt::update'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/conf.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/conf.pp new file mode 100644 index 0000000000..3c4cb1975c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/conf.pp @@ -0,0 +1,18 @@ +define apt::conf ( + $content, + $ensure = present, + $priority = '50' +) { + + include apt::params + + $apt_conf_d = $apt::params::apt_conf_d + + file { "${apt_conf_d}/${priority}${name}": + ensure => $ensure, + content => $content, + owner => root, + group => root, + mode => '0644', + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/debian/testing.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/debian/testing.pp new file mode 100644 index 0000000000..3a82b4f7fd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/debian/testing.pp @@ -0,0 +1,21 @@ +# testing.pp + +class apt::debian::testing { + include apt + + # deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free + # deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free + # Key: 46925553 Server: subkeys.pgp.net + # debian-keyring + # debian-archive-keyring + + apt::source { 'debian_testing': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'testing', + repos => 'main contrib non-free', + required_packages => 'debian-keyring debian-archive-keyring', + key => '46925553', + key_server => 'subkeys.pgp.net', + pin => '-10', + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/debian/unstable.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/debian/unstable.pp new file mode 100644 index 0000000000..77df94b0af --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/debian/unstable.pp @@ -0,0 +1,21 @@ +# unstable.pp + +class apt::debian::unstable { + include apt + + # deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free + # deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free + # Key: 46925553 Server: subkeys.pgp.net + # debian-keyring + # debian-archive-keyring + + apt::source { 'debian_unstable': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'unstable', + repos => 'main contrib non-free', + required_packages => 'debian-keyring debian-archive-keyring', + key => '46925553', + key_server => 'subkeys.pgp.net', + pin => '-10', + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/force.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/force.pp new file mode 100644 index 0000000000..70b7d47239 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/force.pp @@ -0,0 +1,42 @@ +# force.pp +# force a package from a specific release + +define apt::force( + $release = 'testing', + $version = false, + $timeout = 300 +) { + + $provider = $apt::params::provider + + $version_string = $version ? { + false => undef, + default => "=${version}", + } + + $release_string = $release ? { + false => undef, + default => "-t ${release}", + } + + if $version == false { + if $release == false { + $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'" + } else { + # If installed version and candidate version differ, this check returns 1 (false). + $install_check = "/usr/bin/test \$(/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1" + } + } else { + if $release == false { + $install_check = "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'" + } else { + $install_check = "/usr/bin/apt-cache policy -t ${release} ${name} | /bin/grep -q 'Installed: ${version}'" + } + } + + exec { "${provider} -y ${release_string} install ${name}${version_string}": + unless => $install_check, + logoutput => 'on_failure', + timeout => $timeout, + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/init.pp new file mode 100644 index 0000000000..364ce8cb4e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/init.pp @@ -0,0 +1,121 @@ +# Class: apt +# +# This module manages the initial configuration of apt. +# +# Parameters: +# The parameters listed here are not required in general and were +# added for use cases related to development environments. +# disable_keys - disables the requirement for all packages to be signed +# always_apt_update - rather apt should be updated on every run (intended +# for development environments where package updates are frequent) +# purge_sources_list - Accepts true or false. Defaults to false If set to +# true, Puppet will purge all unmanaged entries from sources.list +# purge_sources_list_d - Accepts true or false. Defaults to false. If set +# to true, Puppet will purge all unmanaged entries from sources.list.d +# update_timeout - Overrides the exec timeout in seconds for apt-get update. +# If not set defaults to Exec's default (300) +# +# Actions: +# +# Requires: +# puppetlabs/stdlib +# Sample Usage: +# class { 'apt': } + +class apt( + $always_apt_update = false, + $disable_keys = undef, + $proxy_host = undef, + $proxy_port = '8080', + $purge_sources_list = false, + $purge_sources_list_d = false, + $purge_preferences_d = false, + $update_timeout = undef +) { + + include apt::params + include apt::update + + validate_bool($purge_sources_list, $purge_sources_list_d, $purge_preferences_d) + + $sources_list_content = $purge_sources_list ? { + false => undef, + true => "# Repos managed by puppet.\n", + } + + if $always_apt_update == true { + Exec <| title=='apt_update' |> { + refreshonly => false, + } + } + + $root = $apt::params::root + $apt_conf_d = $apt::params::apt_conf_d + $sources_list_d = $apt::params::sources_list_d + $preferences_d = $apt::params::preferences_d + $provider = $apt::params::provider + + file { 'sources.list': + ensure => present, + path => "${root}/sources.list", + owner => root, + group => root, + mode => '0644', + content => $sources_list_content, + notify => Exec['apt_update'], + } + + file { 'sources.list.d': + ensure => directory, + path => $sources_list_d, + owner => root, + group => root, + purge => $purge_sources_list_d, + recurse => $purge_sources_list_d, + notify => Exec['apt_update'], + } + + file { 'preferences.d': + ensure => directory, + path => $preferences_d, + owner => root, + group => root, + purge => $purge_preferences_d, + recurse => $purge_preferences_d, + } + + case $disable_keys { + true: { + file { '99unauth': + ensure => present, + content => "APT::Get::AllowUnauthenticated 1;\n", + path => "${apt_conf_d}/99unauth", + } + } + false: { + file { '99unauth': + ensure => absent, + path => "${apt_conf_d}/99unauth", + } + } + undef: { } # do nothing + default: { fail('Valid values for disable_keys are true or false') } + } + + $proxy_set = $proxy_host ? { + undef => absent, + default => present + } + + file { 'configure-apt-proxy': + ensure => $proxy_set, + path => "${apt_conf_d}/proxy", + content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";", + notify => Exec['apt_update'], + } + + # Need anchor to provide containment for dependencies. + anchor { 'apt::update': + require => Class['apt::update'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/key.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/key.pp new file mode 100644 index 0000000000..c78bf658ce --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/key.pp @@ -0,0 +1,90 @@ +define apt::key ( + $key = $title, + $ensure = present, + $key_content = false, + $key_source = false, + $key_server = 'keyserver.ubuntu.com', + $key_options = false +) { + + include apt::params + + $upkey = upcase($key) + # trim the key to the last 8 chars so we can match longer keys with apt-key list too + $trimmedkey = regsubst($upkey, '^.*(.{8})$', '\1') + + if $key_content { + $method = 'content' + } elsif $key_source { + $method = 'source' + } elsif $key_server { + $method = 'server' + } + + # This is a hash of the parts of the key definition that we care about. + # It is used as a unique identifier for this instance of apt::key. It gets + # hashed to ensure that the resource name doesn't end up being pages and + # pages (e.g. in the situation where key_content is specified). + $digest = sha1("${upkey}/${key_content}/${key_source}/${key_server}/") + + # Allow multiple ensure => present for the same key to account for many + # apt::source resources that all reference the same key. + case $ensure { + present: { + + anchor { "apt::key/${title}": } + + if defined(Exec["apt::key ${upkey} absent"]) { + fail("Cannot ensure Apt::Key[${upkey}] present; ${upkey} already ensured absent") + } + + if !defined(Anchor["apt::key ${upkey} present"]) { + anchor { "apt::key ${upkey} present": } + } + + if $key_options{ + $options_string = "--keyserver-options ${key_options}" + } + else{ + $options_string = '' + } + + if !defined(Exec[$digest]) { + $digest_command = $method ? { + 'content' => "echo '${key_content}' | /usr/bin/apt-key add -", + 'source' => "wget -q '${key_source}' -O- | apt-key add -", + 'server' => "apt-key adv --keyserver '${key_server}' ${options_string} --recv-keys '${upkey}'", + } + exec { $digest: + command => $digest_command, + path => '/bin:/usr/bin', + unless => "/usr/bin/apt-key list | /bin/grep '${trimmedkey}'", + logoutput => 'on_failure', + before => Anchor["apt::key ${upkey} present"], + } + } + + Anchor["apt::key ${upkey} present"] -> Anchor["apt::key/${title}"] + + } + absent: { + + if defined(Anchor["apt::key ${upkey} present"]) { + fail("Cannot ensure Apt::Key[${upkey}] absent; ${upkey} already ensured present") + } + + exec { "apt::key ${upkey} absent": + command => "apt-key del '${upkey}'", + path => '/bin:/usr/bin', + onlyif => "apt-key list | grep '${trimmedkey}'", + user => 'root', + group => 'root', + logoutput => 'on_failure', + } + } + + default: { + fail "Invalid 'ensure' value '${ensure}' for aptkey" + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/params.pp new file mode 100644 index 0000000000..b35bb1c8d9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/params.pp @@ -0,0 +1,42 @@ +class apt::params { + $root = '/etc/apt' + $provider = '/usr/bin/apt-get' + $sources_list_d = "${root}/sources.list.d" + $apt_conf_d = "${root}/apt.conf.d" + $preferences_d = "${root}/preferences.d" + + case $::lsbdistid { + 'debian': { + case $::lsbdistcodename { + 'squeeze': { + $backports_location = 'http://backports.debian.org/debian-backports' + } + 'wheezy': { + $backports_location = 'http://ftp.debian.org/debian/' + } + default: { + $backports_location = 'http://http.debian.net/debian/' + } + } + } + 'ubuntu': { + case $::lsbdistcodename { + 'hardy','maverick','natty','oneiric','precise': { + $backports_location = 'http://us.archive.ubuntu.com/ubuntu' + $ppa_options = '-y' + } + 'lucid': { + $backports_location = 'http://us.archive.ubuntu.com/ubuntu' + $ppa_options = undef + } + default: { + $backports_location = 'http://old-releases.ubuntu.com/ubuntu' + $ppa_options = '-y' + } + } + } + default: { + fail("Unsupported osfamily (${::osfamily}) or lsbdistid (${::lsbdistid})") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/pin.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/pin.pp new file mode 100644 index 0000000000..402e79ede7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/pin.pp @@ -0,0 +1,73 @@ +# pin.pp +# pin a release in apt, useful for unstable repositories + +define apt::pin( + $ensure = present, + $explanation = "${::caller_module_name}: ${name}", + $order = '', + $packages = '*', + $priority = 0, + $release = '', # a= + $origin = '', + $version = '', + $codename = '', # n= + $release_version = '', # v= + $component = '', # c= + $originator = '', # o= + $label = '' # l= +) { + + include apt::params + + $preferences_d = $apt::params::preferences_d + + if $order != '' and !is_integer($order) { + fail('Only integers are allowed in the apt::pin order param') + } + + $pin_release_array = [ + $release, + $codename, + $release_version, + $component, + $originator, + $label] + $pin_release = join($pin_release_array, '') + + # Read the manpage 'apt_preferences(5)', especially the chapter + # 'Thea Effect of APT Preferences' to understand the following logic + # and the difference between specific and general form + if $packages != '*' { # specific form + + if ( $pin_release != '' and ( $origin != '' or $version != '' )) or + ( $origin != '' and ( $pin_release != '' or $version != '' )) or + ( $version != '' and ( $pin_release != '' or $origin != '' )) { + fail('parameters release, origin, and version are mutually exclusive') + } + + } else { # general form + + if $version != '' { + fail('parameter version cannot be used in general form') + } + + if ( $pin_release != '' and $origin != '' ) or + ( $origin != '' and $pin_release != '' ) { + fail('parmeters release and origin are mutually exclusive') + } + + } + + $path = $order ? { + '' => "${preferences_d}/${name}.pref", + default => "${preferences_d}/${order}-${name}.pref", + } + file { "${name}.pref": + ensure => $ensure, + path => $path, + owner => root, + group => root, + mode => '0644', + content => template('apt/pin.pref.erb'), + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/ppa.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/ppa.pp new file mode 100644 index 0000000000..f2629809e0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/ppa.pp @@ -0,0 +1,81 @@ +# ppa.pp + +define apt::ppa( + $release = $::lsbdistcodename, + $options = $apt::params::ppa_options, +) { + $ensure = 'present' + include apt::params + include apt::update + + $sources_list_d = $apt::params::sources_list_d + + if ! $release { + fail('lsbdistcodename fact not available: release parameter required') + } + + if $::operatingsystem != 'Ubuntu' { + fail("apt::ppa is currently supported on Ubuntu only.") + } + + $filename_without_slashes = regsubst($name, '/', '-', 'G') + $filename_without_dots = regsubst($filename_without_slashes, '\.', '_', 'G') + $filename_without_ppa = regsubst($filename_without_dots, '^ppa:', '', 'G') + $sources_list_d_filename = "${filename_without_ppa}-${release}.list" + + if $ensure == 'present' { + $package = $::lsbdistrelease ? { + /^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties', + default => 'software-properties-common', + } + + if ! defined(Package[$package]) { + package { $package: } + } + + if defined(Class[apt]) { + $proxy_host = $apt::proxy_host + $proxy_port = $apt::proxy_port + case $proxy_host { + false, '': { + $proxy_env = [] + } + default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]} + } + } else { + $proxy_env = [] + } + exec { "add-apt-repository-${name}": + environment => $proxy_env, + command => "/usr/bin/add-apt-repository ${options} ${name}", + unless => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}", + user => 'root', + logoutput => 'on_failure', + notify => Exec['apt_update'], + require => [ + File['sources.list.d'], + Package[$package], + ], + } + + file { "${sources_list_d}/${sources_list_d_filename}": + ensure => file, + require => Exec["add-apt-repository-${name}"], + } + } + else { + + file { "${sources_list_d}/${sources_list_d_filename}": + ensure => 'absent', + mode => '0644', + owner => 'root', + gruop => 'root', + notify => Exec['apt_update'], + } + } + + # Need anchor to provide containment for dependencies. + anchor { "apt::ppa::${name}": + require => Class['apt::update'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/release.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/release.pp new file mode 100644 index 0000000000..6e0a38f73f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/release.pp @@ -0,0 +1,17 @@ +# release.pp + +class apt::release ( + $release_id +) { + + include apt::params + + $root = $apt::params::root + + file { "${root}/apt.conf.d/01release": + owner => root, + group => root, + mode => '0644', + content => "APT::Default-Release \"${release_id}\";" + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/source.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/source.pp new file mode 100644 index 0000000000..bc93ad9d57 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/source.pp @@ -0,0 +1,87 @@ +# source.pp +# add an apt source + +define apt::source( + $ensure = present, + $location = '', + $release = 'UNDEF', + $repos = 'main', + $include_src = true, + $required_packages = false, + $key = false, + $key_server = 'keyserver.ubuntu.com', + $key_content = false, + $key_source = false, + $pin = false, + $architecture = undef +) { + + include apt::params + include apt::update + + $sources_list_d = $apt::params::sources_list_d + $provider = $apt::params::provider + + if $release == 'UNDEF' { + if $::lsbdistcodename == undef { + fail('lsbdistcodename fact not available: release parameter required') + } else { + $release_real = $::lsbdistcodename + } + } else { + $release_real = $release + } + + file { "${name}.list": + ensure => $ensure, + path => "${sources_list_d}/${name}.list", + owner => root, + group => root, + mode => '0644', + content => template("${module_name}/source.list.erb"), + notify => Exec['apt_update'], + } + + + if ($pin != false) { + # Get the host portion out of the url so we can pin to origin + $url_split = split($location, '/') + $host = $url_split[2] + + apt::pin { $name: + ensure => $ensure, + priority => $pin, + before => File["${name}.list"], + origin => $host, + } + } + + if ($required_packages != false) and ($ensure == 'present') { + exec { "Required packages: '${required_packages}' for ${name}": + command => "${provider} -y install ${required_packages}", + logoutput => 'on_failure', + refreshonly => true, + tries => 3, + try_sleep => 1, + subscribe => File["${name}.list"], + before => Exec['apt_update'], + } + } + + # We do not want to remove keys when the source is absent. + if ($key != false) and ($ensure == 'present') { + apt::key { "Add key: ${key} from Apt::Source ${title}": + ensure => present, + key => $key, + key_server => $key_server, + key_content => $key_content, + key_source => $key_source, + before => File["${name}.list"], + } + } + + # Need anchor to provide containment for dependencies. + anchor { "apt::source::${name}": + require => Class['apt::update'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/unattended_upgrades.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/unattended_upgrades.pp new file mode 100644 index 0000000000..b0bd8ab1e0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/unattended_upgrades.pp @@ -0,0 +1,69 @@ +# Class: apt::unattended_upgrades +# +# This class manages the unattended-upgrades package and related configuration +# files for ubuntu +# +# origins are the repositories to automatically upgrade included packages +# blacklist is a list of packages to not automatically upgrade +# update is how often to run "apt-get update" in days +# download is how often to run "apt-get upgrade --download-only" in days +# upgrade is how often to upgrade packages included in the origins list in days +# autoclean is how often to run "apt-get autoclean" in days +# +# information on the other options can be found in the 50unattended-upgrades +# file and in /etc/cron.daily/apt +# +class apt::unattended_upgrades ( + $origins = ['${distro_id}:${distro_codename}-security'], + $blacklist = [], + $update = "1", + $download = "1", + $upgrade = "1", + $autoclean = "7", + $auto_fix = true, + $minimal_steps = false, + $install_on_shutdown = false, + $mail_to = "NONE", + $mail_only_on_error = false, + $remove_unused = true, + $auto_reboot = false, + $dl_limit = "NONE", + $enable = "1", + $backup_interval = "0", + $backup_level = "3", + $max_age = "0", + $min_age = "0", + $max_size = "0", + $download_delta = "0", + $verbose = "0", +) { + include apt::params + + validate_bool( + $auto_fix, + $minimal_steps, + $install_on_shutdown, + $mail_only_on_error, + $remove_unused, + $auto_reboot + ) + + package { 'unattended-upgrades': + ensure => present, + } + + File { + ensure => file, + owner => 'root', + group => 'root', + mode => '0644', + require => Package['unattended-upgrades'], + } + + file { + '/etc/apt/apt.conf.d/50unattended-upgrades': + content => template('apt/50unattended-upgrades.erb'); + '/etc/apt/apt.conf.d/10periodic': + content => template('apt/10periodic.erb'); + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/update.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/update.pp new file mode 100644 index 0000000000..ce0b78fbdd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/manifests/update.pp @@ -0,0 +1,10 @@ +class apt::update { + include apt::params + + exec { 'apt_update': + command => "${apt::params::provider} update", + logoutput => 'on_failure', + refreshonly => true, + timeout => $apt::update_timeout, + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/metadata.json b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/metadata.json new file mode 100644 index 0000000000..f1e8663059 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/metadata.json @@ -0,0 +1,30 @@ +{ + "name": "puppetlabs-apt", + "version": "1.4.1", + "source": "https://github.com/puppetlabs/puppetlabs-apt", + "author": "Puppet Labs", + "license": "Apache-2.0", + "project_page": "https://github.com/puppetlabs/puppetlabs-apt", + "summary": "Puppet Labs Apt Module", + "operatingsystem_support": [ + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04" + ] + } + ], + "requirements": [ + { "name": "pe", "version_requirement": "3.2.x" }, + { "name": "puppet", "version_requirement": "3.x" } + ], + "dependencies": [] +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_builddep_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_builddep_spec.rb new file mode 100644 index 0000000000..1e35e4aa68 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_builddep_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper_acceptance' + +describe 'apt::builddep', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + + context 'reset' do + it 'removes packages' do + shell('apt-get -y remove znc') + shell('apt-get -y remove g++') + end + end + + context 'apt::builddep' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::builddep { 'znc': } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe 'should install g++ as a dependency' do + describe package('g++') do + it { should be_installed } + end + end + end + + context 'reset' do + it 'removes packages' do + shell('apt-get -y remove znc') + shell('apt-get -y remove g++') + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_key_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_key_spec.rb new file mode 100644 index 0000000000..9f2ba395ad --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_key_spec.rb @@ -0,0 +1,200 @@ +require 'spec_helper_acceptance' + +describe 'apt::key', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + context 'apt::key' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::key { 'puppetlabs': + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + + apt::key { 'jenkins': + key => 'D50582E6', + key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') + end + it 'finds jenkins key' do + shell('apt-key list | grep D50582E6') + end + end + end + context 'ensure' do + context 'absent' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::key { 'puppetlabs': + ensure => absent, + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + + apt::key { 'jenkins': + ensure => absent, + key => 'D50582E6', + key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe 'keys shouldnt exist' do + it 'fails' do + shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [1]) + end + it 'fails' do + shell('apt-key list | grep D50582E6', :acceptable_exit_codes => [1]) + end + end + end + end + + context 'reset' do + it 'clean up keys' do + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + shell('apt-key del D50582E6', :acceptable_exit_codes => [0,1,2]) + end + end + + context 'key options' do + context 'key_content' do + + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::key { 'puppetlabs': + key => '4BD6EC30', + key_content => '-----BEGIN PGP PUBLIC KEY BLOCK----- + Version: GnuPG v1.4.12 (GNU/Linux) + Comment: GPGTools - http://gpgtools.org + + mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b + fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg + 5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ + S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY + GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH + Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v + VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0 + Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI + wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN + NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl + f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB + tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL + ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn + AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob + pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF + eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+ + aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M + 2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ + VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU + 3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh + qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1 + IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8 + 1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp + HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN + MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+ + UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh + R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+ + N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc + kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e + lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT + DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb + kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf + DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei + BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z + XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2 + +zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU + fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH + dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4 + qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2 + 7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq + UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x + Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA + KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3 + okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7 + bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4 + 4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX + vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0 + jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y + ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD + 7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR + M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf + REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y + DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk + ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= + =a34C + -----END PGP PUBLIC KEY BLOCK----- + ', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + end + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') + end + end + + context 'key_source' do + + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::key { 'puppetlabs': + key => '4BD6EC30', + key_source => 'http://apt.puppetlabs.com/pubkey.gpg', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') + end + end + end + + context 'key_options' do + + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::key { 'puppetlabs': + key => '4BD6EC30', + key_source => 'http://apt.puppetlabs.com/pubkey.gpg', + key_options => 'debug' + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') + end + end + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_ppa_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_ppa_spec.rb new file mode 100644 index 0000000000..c11da9123b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_ppa_spec.rb @@ -0,0 +1,98 @@ +require 'spec_helper_acceptance' + +if fact('operatingsystem') == 'Ubuntu' + describe 'apt::ppa', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + + context 'reset' do + it 'removes ppa' do + shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0,1,2]) + shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*', :acceptable_exit_codes => [0,1,2]) + end + end + + context 'adding a ppa that doesnt exist' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe 'contains the source file' do + it 'contains a kernel ppa source' do + shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0]) + end + end + end + + context 'reading a removed ppa.' do + it 'setup' do + # This leaves a blank file + shell('echo > /etc/apt/sources.list.d/raravena80-collectd5-$(lsb_release -c -s).list') + end + + it 'should read it successfully' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:raravena80/collectd5': } + EOS + + apply_manifest(pp, :catch_failures => true) + end + end + + context 'reset' do + it 'removes added ppas' do + shell('rm /etc/apt/sources.list.d/canonical-kernel-team-ppa-*') + shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*') + end + end + + context 'release' do + context 'precise' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': + release => precise, + } + EOS + + shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do + it { should be_file } + end + end + end + + context 'options' do + context '-y', :unless => default[:platform].match(/10\.04/) do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': + release => precise, + options => '-y', + } + EOS + + shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/canonical-kernel-team-ppa-precise.list') do + it { should be_file } + end + end + end + + context 'reset' do + it { shell('rm -rf /etc/apt/sources.list.d/canonical-kernel-team-ppa*', :acceptable_exit_codes => [0,1,2]) } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_source_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_source_spec.rb new file mode 100644 index 0000000000..c2d076cbff --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_source_spec.rb @@ -0,0 +1,326 @@ +require 'spec_helper_acceptance' + +describe 'apt::source', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + + context 'apt::source' do + context 'ensure => present' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + shell('rm /etc/apt/sources.list.d/puppetlabs.list', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe 'key should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [0]) + end + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + end + end + + context 'ensure => absent' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => absent, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + # The key should remain -we don't delete those when deleting a source. + describe 'key should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30', :acceptable_exit_codes => [0]) + end + end + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should_not be_file } + end + end + + end + + context 'release' do + context 'test' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + release => 'precise', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + it { should contain 'deb http://apt.puppetlabs.com precise main' } + end + end + end + + context 'include_src' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + include_src => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + it { should contain 'deb-src http://apt.puppetlabs.com' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + include_src => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + it { should_not contain 'deb-src http://apt.puppetlabs.com' } + end + end + end + + context 'required_packages' do + context 'vim' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + required_packages => 'vim', + } + EOS + + shell('apt-get -y remove vim') + apply_manifest(pp, :catch_failures => true) + end + + describe package('vim') do + it { should be_installed } + end + end + end + + context 'key content' do + context 'giant key' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_content => '-----BEGIN PGP PUBLIC KEY BLOCK----- + Version: GnuPG v1.4.12 (GNU/Linux) + Comment: GPGTools - http://gpgtools.org + + mQINBEw3u0ABEAC1+aJQpU59fwZ4mxFjqNCgfZgDhONDSYQFMRnYC1dzBpJHzI6b + fUBQeaZ8rh6N4kZ+wq1eL86YDXkCt4sCvNTP0eF2XaOLbmxtV9bdpTIBep9bQiKg + 5iZaz+brUZlFk/MyJ0Yz//VQ68N1uvXccmD6uxQsVO+gx7rnarg/BGuCNaVtGwy+ + S98g8Begwxs9JmGa8pMCcSxtC7fAfAEZ02cYyrw5KfBvFI3cHDdBqrEJQKwKeLKY + GHK3+H1TM4ZMxPsLuR/XKCbvTyl+OCPxU2OxPjufAxLlr8BWUzgJv6ztPe9imqpH + Ppp3KuLFNorjPqWY5jSgKl94W/CO2x591e++a1PhwUn7iVUwVVe+mOEWnK5+Fd0v + VMQebYCXS+3dNf6gxSvhz8etpw20T9Ytg4EdhLvCJRV/pYlqhcq+E9le1jFOHOc0 + Nc5FQweUtHGaNVyn8S1hvnvWJBMxpXq+Bezfk3X8PhPT/l9O2lLFOOO08jo0OYiI + wrjhMQQOOSZOb3vBRvBZNnnxPrcdjUUm/9cVB8VcgI5KFhG7hmMCwH70tpUWcZCN + NlI1wj/PJ7Tlxjy44f1o4CQ5FxuozkiITJvh9CTg+k3wEmiaGz65w9jRl9ny2gEl + f4CR5+ba+w2dpuDeMwiHJIs5JsGyJjmA5/0xytB7QvgMs2q25vWhygsmUQARAQAB + tEdQdXBwZXQgTGFicyBSZWxlYXNlIEtleSAoUHVwcGV0IExhYnMgUmVsZWFzZSBL + ZXkpIDxpbmZvQHB1cHBldGxhYnMuY29tPokCPgQTAQIAKAUCTDe7QAIbAwUJA8Jn + AAYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQEFS3okvW7DAZaw//aLmE/eob + pXpIUVyCUWQxEvPtM/h/SAJsG3KoHN9u216ews+UHsL/7F91ceVXQQdD2e8CtYWF + eLNM0RSM9i/KM60g4CvIQlmNqdqhi1HsgGqInZ72/XLAXun0gabfC36rLww2kel+ + aMpRf58SrSuskY321NnMEJl4OsHV2hfNtAIgw2e/zm9RhoMpGKxoHZCvFhnP7u2M + 2wMq7iNDDWb6dVsLpzdlVf242zCbubPCxxQXOpA56rzkUPuJ85mdVw4i19oPIFIZ + VL5owit1SxCOxBg4b8oaMS36hEl3qtZG834rtLfcqAmqjhx6aJuJLOAYN84QjDEU + 3NI5IfNRMvluIeTcD4Dt5FCYahN045tW1Rc6s5GAR8RW45GYwQDzG+kkkeeGxwEh + qCW7nOHuwZIoVJufNhd28UFn83KGJHCQt4NBBr3K5TcY6bDQEIrpSplWSDBbd3p1 + IaoZY1WSDdP9OTVOSbsz0JiglWmUWGWCdd/CMSW/D7/3VUOJOYRDwptvtSYcjJc8 + 1UV+1zB+rt5La/OWe4UOORD+jU1ATijQEaFYxBbqBBkFboAEXq9btRQyegqk+eVp + HhzacP5NYFTMThvHuTapNytcCso5au/cMywqCgY1DfcMJyjocu4bCtrAd6w4kGKN + MUdwNDYQulHZDI+UjJInhramyngdzZLjdeGJARwEEAECAAYFAkw3wEYACgkQIVr+ + UOQUcDKvEwgAoBuOPnPioBwYp8oHVPTo/69cJn1225kfraUYGebCcrRwuoKd8Iyh + R165nXYJmD8yrAFBk8ScUVKsQ/pSnqNrBCrlzQD6NQvuIWVFegIdjdasrWX6Szj+ + N1OllbzIJbkE5eo0WjCMEKJVI/GTY2AnTWUAm36PLQC5HnSATykqwxeZDsJ/s8Rc + kd7+QN5sBVytG3qb45Q7jLJpLcJO6KYH4rz9ZgN7LzyyGbu9DypPrulADG9OrL7e + lUnsGDG4E1M8Pkgk9Xv9MRKao1KjYLD5zxOoVtdeoKEQdnM+lWMJin1XvoqJY7FT + DJk6o+cVqqHkdKL+sgsscFVQljgCEd0EgIkCHAQQAQgABgUCTPlA6QAKCRBcE9bb + kwUuAxdYD/40FxAeNCYByxkr/XRT0gFT+NCjPuqPWCM5tf2NIhSapXtb2+32WbAf + DzVfqWjC0G0RnQBve+vcjpY4/rJu4VKIDGIT8CtnKOIyEcXTNFOehi65xO4ypaei + BPSb3ip3P0of1iZZDQrNHMW5VcyL1c+PWT/6exXSGsePtO/89tc6mupqZtC05f5Z + XG4jswMF0U6Q5s3S0tG7Y+oQhKNFJS4sH4rHe1o5CxKwNRSzqccA0hptKy3MHUZ2 + +zeHzuRdRWGjb2rUiVxnIvPPBGxF2JHhB4ERhGgbTxRZ6wZbdW06BOE8r7pGrUpU + fCw/WRT3gGXJHpGPOzFAvr3Xl7VcDUKTVmIajnpd3SoyD1t2XsvJlSQBOWbViucH + dvE4SIKQ77vBLRlZIoXXVb6Wu7Vq+eQs1ybjwGOhnnKjz8llXcMnLzzN86STpjN4 + qGTXQy/E9+dyUP1sXn3RRwb+ZkdI77m1YY95QRNgG/hqh77IuWWg1MtTSgQnP+F2 + 7mfo0/522hObhdAe73VO3ttEPiriWy7tw3bS9daP2TAVbYyFqkvptkBb1OXRUSzq + UuWjBmZ35UlXjKQsGeUHlOiEh84aondF90A7gx0X/ktNIPRrfCGkHJcDu+HVnR7x + Kk+F0qb9+/pGLiT3rqeQTr8fYsb4xLHT7uEg1gVFB1g0kd+RQHzV74kCPgQTAQIA + KAIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AFAk/x5PoFCQtIMjoACgkQEFS3 + okvW7DAIKQ/9HvZyf+LHVSkCk92Kb6gckniin3+5ooz67hSr8miGBfK4eocqQ0H7 + bdtWjAILzR/IBY0xj6OHKhYP2k8TLc7QhQjt0dRpNkX+Iton2AZryV7vUADreYz4 + 4B0bPmhiE+LL46ET5IThLKu/KfihzkEEBa9/t178+dO9zCM2xsXaiDhMOxVE32gX + vSZKP3hmvnK/FdylUY3nWtPedr+lHpBLoHGaPH7cjI+MEEugU3oAJ0jpq3V8n4w0 + jIq2V77wfmbD9byIV7dXcxApzciK+ekwpQNQMSaceuxLlTZKcdSqo0/qmS2A863Y + ZQ0ZBe+Xyf5OI33+y+Mry+vl6Lre2VfPm3udgR10E4tWXJ9Q2CmG+zNPWt73U1FD + 7xBI7PPvOlyzCX4QJhy2Fn/fvzaNjHp4/FSiCw0HvX01epcersyun3xxPkRIjwwR + M9m5MJ0o4hhPfa97zibXSh8XXBnosBQxeg6nEnb26eorVQbqGx0ruu/W2m5/JpUf + REsFmNOBUbi8xlKNS5CZypH3Zh88EZiTFolOMEh+hT6s0l6znBAGGZ4m/Unacm5y + DHmg7unCk4JyVopQ2KHMoqG886elu+rm0ASkhyqBAk9sWKptMl3NHiYTRE/m9VAk + ugVIB2pi+8u84f+an4Hml4xlyijgYu05pqNvnLRyJDLd61hviLC8GYU= + =a34C + -----END PGP PUBLIC KEY BLOCK-----', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + end + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') + end + end + end + end + + context 'key_source' do + context 'http://apt.puppetlabs.com/pubkey.gpg' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + release => 'precise', + repos => 'main', + key => '4BD6EC30', + key_source => 'http://apt.puppetlabs.com/pubkey.gpg', + } + EOS + + shell('apt-key del 4BD6EC30', :acceptable_exit_codes => [0,1,2]) + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/puppetlabs.list') do + it { should be_file } + it { should contain 'deb http://apt.puppetlabs.com precise main' } + end + describe 'keys should exist' do + it 'finds puppetlabs key' do + shell('apt-key list | grep 4BD6EC30') + end + end + end + end + + context 'pin' do + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + pin => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/puppetlabs.pref') do + it { should_not be_file } + end + end + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include '::apt' + apt::source { 'puppetlabs': + ensure => present, + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + pin => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/puppetlabs.pref') do + it { should be_file } + end + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_spec.rb new file mode 100644 index 0000000000..775139145e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/apt_spec.rb @@ -0,0 +1,233 @@ +require 'spec_helper_acceptance' + +describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + + context 'reset' do + it 'fixes the sources.list' do + shell('cp /etc/apt/sources.list /tmp') + end + end + + context 'always_apt_update => true' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': always_apt_update => true } + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/apt_update/) + end + end + end + context 'always_apt_update => false' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': always_apt_update => false } + EOS + + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to_not match(/apt_update/) + end + end + end + + # disable_keys drops in a 99unauth file to ignore keys in + # other files. + context 'disable_keys => true' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': disable_keys => true } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/99unauth') do + it { should be_file } + it { should contain 'APT::Get::AllowUnauthenticated 1;' } + end + end + context 'disable_keys => false' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': disable_keys => false } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/99unauth') do + it { should_not be_file } + end + end + + # proxy_host sets the proxy to use for transfers. + # proxy_port sets the proxy port to use. + context 'proxy settings' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': + proxy_host => 'localhost', + proxy_port => '7042', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/proxy') do + it { should be_file } + it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' } + end + end + + context 'purge_sources' do + it 'creates a fake apt file' do + shell('touch /etc/apt/sources.list.d/fake.list') + shell('echo "deb fake" >> /etc/apt/sources.list') + end + it 'purge_sources_list and purge_sources_list_d => true' do + pp = <<-EOS + class { 'apt': + purge_sources_list => true, + purge_sources_list_d => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list') do + it { should_not contain 'deb fake' } + end + + describe file('/etc/apt/sources.list.d/fake.list') do + it { should_not be_file } + end + end + context 'proxy settings' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': + proxy_host => 'localhost', + proxy_port => '7042', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/proxy') do + it { should be_file } + it { should contain 'Acquire::http::Proxy "http://localhost:7042\";' } + end + end + + context 'purge_sources' do + context 'false' do + it 'creates a fake apt file' do + shell('touch /etc/apt/sources.list.d/fake.list') + shell('echo "deb fake" >> /etc/apt/sources.list') + end + it 'purge_sources_list and purge_sources_list_d => false' do + pp = <<-EOS + class { 'apt': + purge_sources_list => false, + purge_sources_list_d => false, + } + EOS + + apply_manifest(pp, :catch_failures => false) + end + + describe file('/etc/apt/sources.list') do + it { should contain 'deb fake' } + end + + describe file('/etc/apt/sources.list.d/fake.list') do + it { should be_file } + end + end + + context 'true' do + it 'creates a fake apt file' do + shell('touch /etc/apt/sources.list.d/fake.list') + shell('echo "deb fake" >> /etc/apt/sources.list') + end + it 'purge_sources_list and purge_sources_list_d => true' do + pp = <<-EOS + class { 'apt': + purge_sources_list => true, + purge_sources_list_d => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list') do + it { should_not contain 'deb fake' } + end + + describe file('/etc/apt/sources.list.d/fake.list') do + it { should_not be_file } + end + end + end + + context 'purge_preferences_d' do + context 'false' do + it 'creates a preferences file' do + shell('touch /etc/apt/preferences.d/test') + end + + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': purge_preferences_d => false } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/test') do + it { should be_file } + end + end + context 'true' do + it 'creates a preferences file' do + shell('touch /etc/apt/preferences.d/test') + end + + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': purge_preferences_d => true } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/test') do + it { should_not be_file } + end + end + end + + context 'update_timeout' do + context '5000' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': update_timeout => '5000' } + EOS + + apply_manifest(pp, :catch_failures => true) + end + end + end + + context 'reset' do + it 'fixes the sources.list' do + shell('cp /tmp/sources.list /etc/apt') + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/backports_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/backports_spec.rb new file mode 100644 index 0000000000..6d3f7f0e68 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/backports_spec.rb @@ -0,0 +1,59 @@ +require 'spec_helper_acceptance' + +codename = fact('lsbdistcodename') +case fact('operatingsystem') +when 'Ubuntu' + repos = 'main universe multiverse restricted' +when 'Debian' + repos = 'main contrib non-free' +end + +describe 'apt::backports class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + context 'defaults' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt::backports': } + EOS + + apply_manifest(pp, :catch_failures => true) + end + end + + context 'release' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt::backports': release => '#{codename}' } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/backports.list') do + it { should be_file } + it { should contain "#{codename}-backports #{repos}" } + end + end + + context 'location' do + it 'should work with no errors' do + pp = <<-EOS + class { 'apt::backports': release => 'precise', location => 'http://localhost/ubuntu' } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/sources.list.d/backports.list') do + it { should be_file } + it { should contain "deb http://localhost/ubuntu precise-backports #{repos}" } + end + end + + context 'reset' do + it 'deletes backport files' do + shell('rm -rf /etc/apt/sources.list.d/backports.list') + shell('rm -rf /etc/apt/preferences.d/backports.pref') + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/class_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/class_spec.rb new file mode 100644 index 0000000000..e5994498b9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/class_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper_acceptance' + +describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + + context 'default parameters' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + class { 'apt': } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_failures => true) + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/conf_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/conf_spec.rb new file mode 100644 index 0000000000..8a8ed63db4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/conf_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper_acceptance' + +describe 'apt::conf define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + context 'defaults' do + it 'should work with no errors' do + pp = <<-EOS + apt::conf { 'test': + content => 'test', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50test') do + it { should be_file } + it { should contain 'test' } + end + end + + context 'ensure' do + context 'absent' do + it 'should work with no errors' do + pp = <<-EOS + apt::conf { 'test': + ensure => absent, + content => 'test', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50test') do + it { should_not be_file } + end + end + end + + context 'priority' do + context '99' do + it 'should work with no errors' do + pp = <<-EOS + apt::conf { 'test': + ensure => present, + content => 'test', + priority => '99', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/99test') do + it { should be_file } + it { should contain 'test' } + end + end + end + + context 'cleanup' do + it 'deletes 99test' do + shell ('rm -rf /etc/apt/apt.conf.d/99test') + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/force_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/force_spec.rb new file mode 100644 index 0000000000..00572eae37 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/force_spec.rb @@ -0,0 +1,76 @@ +require 'spec_helper_acceptance' + +codename = fact('lsbdistcodename') + +describe 'apt::force define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + context 'defaults' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::force { 'vim': release => false, } + EOS + + shell('apt-get remove -y vim') + apply_manifest(pp, :catch_failures => true) + end + + describe package('vim') do + it { should be_installed } + end + end + + context 'release' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::force { 'vim': release => '#{codename}' } + EOS + + shell('apt-get remove -y vim') + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/apt-get -y -t #{codename} install vim/) + end + end + + describe package('vim') do + it { should be_installed } + end + end + + context 'version' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::force { 'vim': version => '1.1.1', release => false, } + EOS + + shell('apt-get remove -y vim') + apply_manifest(pp, :catch_failures => false) do |r| + expect(r.stdout).to match(/apt-get -y install vim=1.1.1/) + end + end + + describe package('vim') do + it { should_not be_installed } + end + end + + context 'timeout' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::force { 'vim': release => false, timeout => '1' } + EOS + + shell('apt-get clean') + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Error: Command exceeded timeout/) + end + end + + describe package('vim') do + it { should_not be_installed } + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/debian-70rc1-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/debian-70rc1-x64.yml new file mode 100644 index 0000000000..4b55677f4c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/debian-70rc1-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-70rc1-x64: + roles: + - master + platform: debian-70rc1-x64 + box : debian-70rc1-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/default.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000000..a5f38f784c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/default.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-server-12.04-amd64 + box : ubuntu-server-12042-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml new file mode 100644 index 0000000000..c1b8bdf8fa --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-10044-x64: + roles: + - master + platform: ubuntu-10.04-amd64 + box : ubuntu-server-10044-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 0000000000..a5f38f784c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-server-12.04-amd64 + box : ubuntu-server-12042-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/pin_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/pin_spec.rb new file mode 100644 index 0000000000..6de11748d0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/pin_spec.rb @@ -0,0 +1,266 @@ +require 'spec_helper_acceptance' + +describe 'apt::pin define', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + context 'defaults' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release a=vim-puppet' } + end + end + + context 'ensure' do + context 'present' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': ensure => present } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release a=vim-puppet' } + end + end + + context 'absent' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': ensure => absent } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should_not be_file } + end + end + end + + context 'order' do + context '99' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + order => '99', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/99-vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release a=vim-puppet' } + end + end + end + + context 'packages' do + context 'test' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + packages => 'test', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Package: test' } + it { should contain 'Pin: release a=vim-puppet' } + end + end + end + + context 'release' do + context 'testrelease' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + release => 'testrelease', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release a=testrelease' } + end + end + end + + context 'origin' do + context 'testrelease' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + origin => 'testrelease', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: origin testrelease' } + end + end + end + + context 'version' do + context '1.0.0' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + packages => 'test', + version => '1.0.0', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Package: test' } + it { should contain 'Pin: version 1.0.0' } + end + end + end + + context 'codename' do + context 'testname' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + codename => 'testname', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release n=testname' } + end + end + end + + context 'release_version' do + context '1.1.1' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + release_version => '1.1.1', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release v=1.1.1' } + end + end + end + + context 'component' do + context 'testcomponent' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + component => 'testcomponent', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release c=testcomponent' } + end + end + end + + context 'originator' do + context 'testorigin' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + originator => 'testorigin', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release o=testorigin' } + end + end + end + + context 'label' do + context 'testlabel' do + it 'should work with no errors' do + pp = <<-EOS + include apt + apt::pin { 'vim-puppet': + ensure => present, + label => 'testlabel', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/preferences.d/vim-puppet.pref') do + it { should be_file } + it { should contain 'Pin: release l=testlabel' } + end + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/release_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/release_spec.rb new file mode 100644 index 0000000000..e7467bf62d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/release_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper_acceptance' + +describe 'apt::release class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + context 'release_id' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::release': release_id => 'precise', } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/01release') do + it { should be_file } + it { should contain 'APT::Default-Release "precise";' } + end + end + + context 'reset' do + it 'cleans up' do + shell('rm -rf /etc/apt/apt.conf.d/01release') + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/unattended_upgrade_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/unattended_upgrade_spec.rb new file mode 100644 index 0000000000..6a19f4e74e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/unattended_upgrade_spec.rb @@ -0,0 +1,562 @@ +require 'spec_helper_acceptance' + +describe 'apt::unattended_upgrades class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + context 'defaults' do + it 'should work with no errors' do + pp = <<-EOS + include apt + include apt::unattended_upgrades + EOS + + # Attempted workaround for problems seen on debian with + # something holding the package database open. + #shell('killall -9 apt-get') + #shell('killall -9 dpkg') + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + end + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + end + end + + context 'origins' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + origins => ['${distro_id}:${distro_codename}-test'], + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain '${distro_id}:${distro_codename}-test' } + end + end + + context 'blacklist' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + blacklist => ['puppet'] + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'puppet' } + end + end + + context 'update' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + update => '99' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Update-Package-Lists "99";' } + end + end + + context 'download' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + download => '99' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Download-Upgradeable-Packages "99";' } + end + end + + context 'upgrade' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + upgrade => '99' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Unattended-Upgrade "99";' } + end + end + + context 'autoclean' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + autoclean => '99' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::AutocleanInterval "99";' } + end + end + + context 'auto_fix' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + auto_fix => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + auto_fix => false + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::AutoFixInterruptedDpkg "false";' } + end + end + end + + context 'minimal_steps' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + minimal_steps => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::MinimalSteps "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + minimal_steps => false + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::MinimalSteps "false";' } + end + end + end + + context 'install_on_shutdown' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + install_on_shutdown => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::InstallOnShutdown "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + install_on_shutdown => false + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::InstallOnShutdown "false";' } + end + end + end + + context 'mail_to' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + mail_to => 'test@example.com' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::Mail "test@example.com";' } + end + end + + context 'mail_only_on_error' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + mail_to => 'test@example.com', + mail_only_on_error => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::MailOnlyOnError "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + mail_to => 'test@example.com', + mail_only_on_error => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::MailOnlyOnError "false";' } + end + end + + context 'mail_to missing' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + mail_only_on_error => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should_not contain 'Unattended-Upgrade::MailOnlyOnError "true";' } + end + end + end + + context 'remove_unused' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + remove_unused => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + remove_unused => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::Remove-Unused-Dependencies "false";' } + end + end + end + + context 'auto_reboot' do + context 'true' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + auto_reboot => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::Automatic-Reboot "true";' } + end + end + + context 'false' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + auto_reboot => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Unattended-Upgrade::Automatic-Reboot "false";' } + end + end + end + + context 'dl_limit' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + dl_limit => '99' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/50unattended-upgrades') do + it { should be_file } + it { should contain 'Acquire::http::Dl-Limit "99"' } + end + end + + context 'enable' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + enable => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Enable "2"' } + end + end + + context 'backup_interval' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + backup_interval => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::BackUpArchiveInterval "2";' } + end + end + + context 'backup_level' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + backup_level => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::BackUpLevel "2";' } + end + end + + context 'max_age' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + max_age => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::MaxAge "2";' } + end + end + + context 'min_age' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + min_age => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::MinAge "2";' } + end + end + + context 'max_size' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + max_size => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::MaxSize "2";' } + end + end + + context 'download_delta' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + download_delta => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";' } + end + end + + context 'verbose' do + it 'should work with no errors' do + pp = <<-EOS + include apt + class { 'apt::unattended_upgrades': + verbose => '2' + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe file('/etc/apt/apt.conf.d/10periodic') do + it { should be_file } + it { should contain 'APT::Periodic::Verbose "2";' } + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/unsupported_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/unsupported_spec.rb new file mode 100644 index 0000000000..08dca76b84 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/acceptance/unsupported_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper_acceptance' + +describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + it 'class apt fails' do + pp = <<-EOS + class { 'apt': } + EOS + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported/i) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/apt_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/apt_spec.rb new file mode 100644 index 0000000000..080bc81760 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/apt_spec.rb @@ -0,0 +1,134 @@ +require 'spec_helper' +describe 'apt', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } + let :default_params do + { + :disable_keys => :undef, + :always_apt_update => false, + :purge_sources_list => false, + :purge_sources_list_d => false, + } + end + + [{}, + { + :disable_keys => true, + :always_apt_update => true, + :proxy_host => true, + :proxy_port => '3128', + :purge_sources_list => true, + :purge_sources_list_d => true, + }, + { + :disable_keys => false + } + ].each do |param_set| + describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do + let :param_hash do + default_params.merge(param_set) + end + + let :params do + param_set + end + + let :refresh_only_apt_update do + if param_hash[:always_apt_update] + false + else + true + end + end + + it { should contain_class("apt::params") } + + it { + if param_hash[:purge_sources_list] + should contain_file("sources.list").with({ + 'path' => "/etc/apt/sources.list", + 'ensure' => "present", + 'owner' => "root", + 'group' => "root", + 'mode' => "0644", + "content" => "# Repos managed by puppet.\n" + }) + else + should contain_file("sources.list").with({ + 'path' => "/etc/apt/sources.list", + 'ensure' => "present", + 'owner' => "root", + 'group' => "root", + 'mode' => "0644", + 'content' => nil + }) + end + } + it { + if param_hash[:purge_sources_list_d] + should create_file("sources.list.d").with({ + 'path' => "/etc/apt/sources.list.d", + 'ensure' => "directory", + 'owner' => "root", + 'group' => "root", + 'purge' => true, + 'recurse' => true, + 'notify' => 'Exec[apt_update]' + }) + else + should create_file("sources.list.d").with({ + 'path' => "/etc/apt/sources.list.d", + 'ensure' => "directory", + 'owner' => "root", + 'group' => "root", + 'purge' => false, + 'recurse' => false, + 'notify' => 'Exec[apt_update]' + }) + end + } + + it { + should contain_exec("apt_update").with({ + 'command' => "/usr/bin/apt-get update", + 'refreshonly' => refresh_only_apt_update + }) + } + + it { + if param_hash[:disable_keys] == true + should create_file("99unauth").with({ + 'content' => "APT::Get::AllowUnauthenticated 1;\n", + 'ensure' => "present", + 'path' => "/etc/apt/apt.conf.d/99unauth" + }) + elsif param_hash[:disable_keys] == false + should create_file("99unauth").with({ + 'ensure' => "absent", + 'path' => "/etc/apt/apt.conf.d/99unauth" + }) + elsif param_hash[:disable_keys] != :undef + should_not create_file("99unauth").with({ + 'path' => "/etc/apt/apt.conf.d/99unauth" + }) + end + } + describe 'when setting a proxy' do + it { + if param_hash[:proxy_host] + should contain_file('configure-apt-proxy').with( + 'path' => '/etc/apt/apt.conf.d/proxy', + 'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";", + 'notify' => "Exec[apt_update]" + ) + else + should contain_file('configure-apt-proxy').with( + 'path' => '/etc/apt/apt.conf.d/proxy', + 'notify' => 'Exec[apt_update]', + 'ensure' => 'absent' + ) + end + } + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/backports_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/backports_spec.rb new file mode 100644 index 0000000000..98ad873af5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/backports_spec.rb @@ -0,0 +1,71 @@ +require 'spec_helper' +describe 'apt::backports', :type => :class do + + describe 'when turning on backports for ubuntu karmic' do + + let :facts do + { + 'lsbdistcodename' => 'Karmic', + 'lsbdistid' => 'Ubuntu' + } + end + + it { should contain_apt__source('backports').with({ + 'location' => 'http://old-releases.ubuntu.com/ubuntu', + 'release' => 'karmic-backports', + 'repos' => 'main universe multiverse restricted', + 'key' => '437D05B5', + 'key_server' => 'pgp.mit.edu', + 'pin' => '200', + }) + } + end + + describe "when turning on backports for debian squeeze" do + + let :facts do + { + 'lsbdistcodename' => 'Squeeze', + 'lsbdistid' => 'Debian', + } + end + + it { should contain_apt__source('backports').with({ + 'location' => 'http://backports.debian.org/debian-backports', + 'release' => 'squeeze-backports', + 'repos' => 'main contrib non-free', + 'key' => '46925553', + 'key_server' => 'pgp.mit.edu', + 'pin' => '200', + }) + } + end + + describe "when turning on backports for debian squeeze but using your own mirror" do + + let :facts do + { + 'lsbdistcodename' => 'Squeeze', + 'lsbdistid' => 'Debian' + } + end + + let :location do + 'http://mirrors.example.com/debian-backports' + end + + let :params do + { 'location' => location } + end + + it { should contain_apt__source('backports').with({ + 'location' => location, + 'release' => 'squeeze-backports', + 'repos' => 'main contrib non-free', + 'key' => '46925553', + 'key_server' => 'pgp.mit.edu', + 'pin' => '200', + }) + } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/debian_testing_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/debian_testing_spec.rb new file mode 100644 index 0000000000..20487333f6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/debian_testing_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' +describe 'apt::debian::testing', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } + it { + should contain_apt__source("debian_testing").with({ + "location" => "http://debian.mirror.iweb.ca/debian/", + "release" => "testing", + "repos" => "main contrib non-free", + "required_packages" => "debian-keyring debian-archive-keyring", + "key" => "46925553", + "key_server" => "subkeys.pgp.net", + "pin" => "-10" + }) + } +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/debian_unstable_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/debian_unstable_spec.rb new file mode 100644 index 0000000000..70724f90bd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/debian_unstable_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' +describe 'apt::debian::unstable', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } + it { + should contain_apt__source("debian_unstable").with({ + "location" => "http://debian.mirror.iweb.ca/debian/", + "release" => "unstable", + "repos" => "main contrib non-free", + "required_packages" => "debian-keyring debian-archive-keyring", + "key" => "46925553", + "key_server" => "subkeys.pgp.net", + "pin" => "-10" + }) + } +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/params_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/params_spec.rb new file mode 100644 index 0000000000..2d3ec3c71a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/params_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' +describe 'apt::params', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } + let (:title) { 'my_package' } + + it { should contain_apt__params } + + # There are 4 resources in this class currently + # there should not be any more resources because it is a params class + # The resources are class[apt::params], class[main], class[settings], stage[main] + it "Should not contain any resources" do + subject.resources.size.should == 4 + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/release_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/release_spec.rb new file mode 100644 index 0000000000..e43f449d62 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/release_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' +describe 'apt::release', :type => :class do + let(:facts) { { :lsbdistid => 'Debian' } } + let (:title) { 'my_package' } + + let :param_set do + { :release_id => 'precise' } + end + + let (:params) { param_set } + + it { should contain_class("apt::params") } + + it { + should contain_file("/etc/apt/apt.conf.d/01release").with({ + "mode" => "0644", + "owner" => "root", + "group" => "root", + "content" => "APT::Default-Release \"#{param_set[:release_id]}\";" + }) + } +end + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/unattended_upgrades_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/unattended_upgrades_spec.rb new file mode 100644 index 0000000000..f5cad53a5b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/classes/unattended_upgrades_spec.rb @@ -0,0 +1,205 @@ +require 'spec_helper' +describe 'apt::unattended_upgrades', :type => :class do + let(:file_unattended) { '/etc/apt/apt.conf.d/50unattended-upgrades' } + let(:file_periodic) { '/etc/apt/apt.conf.d/10periodic' } + let(:facts) { { :lsbdistid => 'Debian' } } + + it { should contain_package("unattended-upgrades") } + + it { + should create_file("/etc/apt/apt.conf.d/50unattended-upgrades").with({ + "owner" => "root", + "group" => "root", + "mode" => "0644", + "require" => "Package[unattended-upgrades]", + }) + } + + it { + should create_file("/etc/apt/apt.conf.d/10periodic").with({ + "owner" => "root", + "group" => "root", + "mode" => "0644", + "require" => "Package[unattended-upgrades]", + }) + } + + describe "origins" do + describe "with param defaults" do + let(:params) {{ }} + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\$\{distro_id\}:\$\{distro_codename\}-security";\n\};$/) } + end + + describe "with origins => ['ubuntu:precise-security']" do + let :params do + { :origins => ['ubuntu:precise-security'] } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) } + end + end + + describe "blacklist" do + describe "with param defaults" do + let(:params) {{ }} + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) } + end + + describe "with blacklist => []" do + let :params do + { :blacklist => ['libc6', 'libc6-dev'] } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) } + end + end + + describe "with update => 2" do + let :params do + { :update => "2" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Update-Package-Lists "2";$/) } + end + + describe "with download => 2" do + let :params do + { :download => "2" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages "2";$/) } + end + + describe "with upgrade => 2" do + let :params do + { :upgrade => "2" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Unattended-Upgrade "2";$/) } + end + + describe "with autoclean => 2" do + let :params do + { :autoclean => "2" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::AutocleanInterval "2";$/) } + end + + describe "with auto_fix => false" do + let :params do + { :auto_fix => false } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::AutoFixInterruptedDpkg "false";$/) } + end + + describe "with minimal_steps => true" do + let :params do + { :minimal_steps => true } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MinimalSteps "true";$/) } + end + + describe "with install_on_shutdown => true" do + let :params do + { :install_on_shutdown => true } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) } + end + + describe "mail_to" do + describe "param defaults" do + let(:params) {{ }} + it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail /) } + it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError /) } + end + + describe "with mail_to => user@website, mail_only_on_error => true" do + let :params do + { :mail_to => "user@website", + :mail_only_on_error => true } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) } + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) } + end + end + + describe "with remove_unused => false" do + let :params do + { :remove_unused => false } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Remove-Unused-Dependencies "false";$/) } + end + + describe "with auto_reboot => true" do + let :params do + { :auto_reboot => true } + end + it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) } + end + + describe "dl_limit" do + describe "param defaults" do + let(:params) {{ }} + it { should_not contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit /) } + end + + describe "with dl_limit => 70" do + let :params do + { :dl_limit => "70" } + end + it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) } + end + end + + describe "with enable => 0" do + let :params do + { :enable => "0" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Enable "0";$/) } + end + + describe "with backup_interval => 1" do + let :params do + { :backup_interval => "1" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpArchiveInterval "1";$/) } + end + + describe "with backup_level => 0" do + let :params do + { :backup_level => "0" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::BackUpLevel "0";$/) } + end + + describe "with max_age => 1" do + let :params do + { :max_age => "1" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxAge "1";$/) } + end + + describe "with min_age => 1" do + let :params do + { :min_age => "1" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::MinAge "1";$/) } + end + + describe "with max_size => 1" do + let :params do + { :max_size => "1" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::MaxSize "1";$/) } + end + + describe "with download_delta => 2" do + let :params do + { :download_delta => "2" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Download-Upgradeable-Packages-Debdelta "2";$/) } + end + + describe "with verbose => 2" do + let :params do + { :verbose => "2" } + end + it { should contain_file(file_periodic).with_content(/^APT::Periodic::Verbose "2";$/) } + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/builddep_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/builddep_spec.rb new file mode 100644 index 0000000000..a0cbaa4cc0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/builddep_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' +describe 'apt::builddep', :type => :define do + + let(:facts) { { :lsbdistid => 'Debian' } } + let(:title) { 'my_package' } + + describe "should require apt-get update" do + it { should contain_exec("apt_update").with({ + 'command' => "/usr/bin/apt-get update", + 'refreshonly' => true + }) + } + it { should contain_anchor("apt::builddep::my_package").with({ + 'require' => 'Class[Apt::Update]', + }) + } + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/conf_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/conf_spec.rb new file mode 100644 index 0000000000..cda5900c03 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/conf_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' +describe 'apt::conf', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } + let :title do + 'norecommends' + end + + describe "when creating an apt preference" do + let :params do + { + :priority => '00', + :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" + } + end + + let :filename do + "/etc/apt/apt.conf.d/00norecommends" + end + + it { should contain_apt__conf('norecommends').with({ + 'priority' => '00', + 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" + }) + } + + it { should contain_file(filename).with({ + 'ensure' => 'present', + 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + }) + } + end + + describe "when removing an apt preference" do + let :params do + { + :ensure => 'absent', + :priority => '00', + :content => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" + } + end + + let :filename do + "/etc/apt/apt.conf.d/00norecommends" + end + + it { should contain_file(filename).with({ + 'ensure' => 'absent', + 'content' => "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + }) + } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/force_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/force_spec.rb new file mode 100644 index 0000000000..b8665e6dab --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/force_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' +describe 'apt::force', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } + let :pre_condition do + 'include apt::params' + end + + let :title do + 'my_package' + end + + let :default_params do + { + :release => 'testing', + :version => false + } + end + + describe "when using default parameters" do + let :params do + default_params + end + it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with( + :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1", + :timeout => '300' + ) } + end + + describe "when specifying false release parameter" do + let :params do + default_params.merge(:release => false) + end + it { should contain_exec("/usr/bin/apt-get -y install #{title}").with( + :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'" + ) } + end + + describe "when specifying version parameter" do + let :params do + default_params.merge(:version => '1') + end + it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=#{params[:version]}").with( + :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" + ) } + end + + describe "when specifying false release and version parameters" do + let :params do + default_params.merge( + :release => false, + :version => '1' + ) + end + it { should contain_exec("/usr/bin/apt-get -y install #{title}=1").with( + :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'" + ) } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/key_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/key_spec.rb new file mode 100644 index 0000000000..4ba7b87eae --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/key_spec.rb @@ -0,0 +1,124 @@ +require 'spec_helper' +describe 'apt::key', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } + let :title do + '8347A27F' + end + + let :default_params do + { + :key => title, + :ensure => 'present', + :key_server => "keyserver.ubuntu.com", + :key_source => false, + :key_content => false + } + end + + [{}, + { + :ensure => 'absent' + }, + { + :ensure => 'random' + }, + { + :key_source => 'ftp://ftp.example.org/key', + }, + { + :key_content => 'deadbeef', + } + ].each do |param_set| + + let :param_hash do + param_hash = default_params.merge(param_set) + param_hash[:key].upcase! if param_hash[:key] + param_hash + end + + let :params do + param_set + end + + let :digest do + str = String.new + str << param_hash[:key].to_s << '/' + str << param_hash[:key_content].to_s << '/' + str << param_hash[:key_source].to_s << '/' + str << param_hash[:key_server].to_s << '/' + Digest::SHA1.hexdigest(str) + end + + describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do + + it { + if [:present, 'present', :absent, 'absent'].include? param_hash[:ensure] + should contain_apt__params + end + } + + it { + if [:present, 'present'].include? param_hash[:ensure] + should_not contain_exec("apt::key #{param_hash[:key]} absent") + should contain_anchor("apt::key #{param_hash[:key]} present") + should contain_exec(digest).with({ + "path" => "/bin:/usr/bin", + "unless" => "/usr/bin/apt-key list | /bin/grep '#{param_hash[:key]}'" + }) + elsif [:absent, 'absent'].include? param_hash[:ensure] + should_not contain_anchor("apt::key #{param_hash[:key]} present") + should contain_exec("apt::key #{param_hash[:key]} absent").with({ + "path" => "/bin:/usr/bin", + "onlyif" => "apt-key list | grep '#{param_hash[:key]}'", + "command" => "apt-key del '#{param_hash[:key]}'" + }) + else + expect { should raise_error(Puppet::Error) } + end + } + + it { + if [:present, 'present'].include? param_hash[:ensure] + if param_hash[:key_content] + should contain_exec(digest).with({ + "command" => "echo '#{param_hash[:key_content]}' | /usr/bin/apt-key add -" + }) + elsif param_hash[:key_source] + should contain_exec(digest).with({ + "command" => "wget -q '#{param_hash[:key_source]}' -O- | apt-key add -" + }) + elsif param_hash[:key_server] + should contain_exec(digest).with({ + "command" => "apt-key adv --keyserver '#{param_hash[:key_server]}' --recv-keys '#{param_hash[:key]}'" + }) + end + end + } + + end + end + + [{ :ensure => 'present' }, { :ensure => 'absent' }].each do |param_set| + describe "should correctly handle duplicate definitions" do + + let :pre_condition do + "apt::key { 'duplicate': key => '#{title}'; }" + end + + let(:params) { param_set } + + it { + if param_set[:ensure] == 'present' + should contain_anchor("apt::key #{title} present") + should contain_apt__key(title) + should contain_apt__key("duplicate") + elsif param_set[:ensure] == 'absent' + expect { should raise_error(Puppet::Error) } + end + } + + end + end + +end + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/pin_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/pin_spec.rb new file mode 100644 index 0000000000..78a9b12690 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/pin_spec.rb @@ -0,0 +1,102 @@ +require 'spec_helper' +describe 'apt::pin', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } + let(:title) { 'my_pin' } + + let :default_params do + { + :ensure => 'present', + :order => '', + :packages => '*', + :priority => '0', + :release => nil + } + end + + [ + { :params => {}, + :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: release a=my_pin\nPin-Priority: 0\n" + }, + { + :params => { + :packages => 'apache', + :priority => '1' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" + }, + { + :params => { + :order => 50, + :packages => 'apache', + :priority => '1' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" + }, + { + :params => { + :ensure => 'absent', + :packages => 'apache', + :priority => '1' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_pin\nPin-Priority: 1\n" + }, + { + :params => { + :packages => 'apache', + :priority => '1', + :release => 'my_newpin' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=my_newpin\nPin-Priority: 1\n" + }, + { + :params => { + :packages => 'apache', + :priority => '1', + :version => '2.2.16*' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: version 2.2.16*\nPin-Priority: 1\n" + }, + { + :params => { + :priority => '1', + :origin => 'ftp.de.debian.org' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: *\nPin: origin ftp.de.debian.org\nPin-Priority: 1\n" + }, + { + :params => { + :packages => 'apache', + :priority => '1', + :release => 'stable', + :codename => 'wheezy', + :release_version => '3.0', + :component => 'main', + :originator => 'Debian', + :label => 'Debian' + }, + :content => "# my_pin\nExplanation: : my_pin\nPackage: apache\nPin: release a=stable, n=wheezy, v=3.0, c=main, o=Debian, l=Debian\nPin-Priority: 1\n" + }, + ].each do |param_set| + describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do + let :param_hash do + default_params.merge(param_set[:params]) + end + + let :params do + param_set[:params] + end + + it { should contain_class("apt::params") } + + it { should contain_file("#{title}.pref").with({ + 'ensure' => param_hash[:ensure], + 'path' => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref", + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'content' => param_set[:content], + }) + } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/ppa_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/ppa_spec.rb new file mode 100644 index 0000000000..0c3bd75ed7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/ppa_spec.rb @@ -0,0 +1,156 @@ +require 'spec_helper' +describe 'apt::ppa', :type => :define do + [ + { + :lsbdistrelease => '11.04', + :lsbdistcodename => 'natty', + :operatingsystem => 'Ubuntu', + :lsbdistid => 'Ubuntu', + :package => 'python-software-properties' + }, + { + :lsbdistrelease => '12.10', + :lsbdistcodename => 'quantal', + :operatingsystem => 'Ubuntu', + :lsbdistid => 'Ubuntu', + :package => 'software-properties-common' + }, + ].each do |platform| + context "on #{platform[:lsbdistcodename]}" do + let :facts do + { + :lsbdistrelease => platform[:lsbdistrelease], + :lsbdistcodename => platform[:lsbdistcodename], + :operatingsystem => platform[:operatingsystem], + :lsbdistid => platform[:lsbdistid], + } + end + let :release do + "#{platform[:lsbdistcodename]}" + end + let :package do + "#{platform[:package]}" + end + let :options do + "-y" + end + ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t| + describe "with title #{t}" do + let :pre_condition do + 'class { "apt": }' + end + let :title do + t + end + let :filename do + t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list" + end + + it { should contain_package("#{package}") } + + it { should contain_exec("apt_update").with( + 'command' => '/usr/bin/apt-get update', + 'refreshonly' => true + ) + } + + it { should contain_exec("add-apt-repository-#{t}").with( + 'command' => "/usr/bin/add-apt-repository #{options} #{t}", + 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", + 'require' => ["File[sources.list.d]", "Package[#{package}]"], + 'notify' => "Exec[apt_update]" + ) + } + + it { should create_file("/etc/apt/sources.list.d/#{filename}").with( + 'ensure' => 'file', + 'require' => "Exec[add-apt-repository-#{t}]" + ) + } + end + end + describe 'without a proxy defined' do + let :title do + 'rspec_ppa' + end + let :pre_condition do + 'class { "apt": + proxy_host => false + }' + end + let :filename do + "#{title}-#{release}.list" + end + + it { should contain_exec("add-apt-repository-#{title}").with( + 'environment' => [], + 'command' => "/usr/bin/add-apt-repository #{options} #{title}", + 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", + 'require' => ["File[sources.list.d]", "Package[#{package}]"], + 'notify' => "Exec[apt_update]" + ) + } + end + + describe 'behind a proxy' do + let :title do + 'rspec_ppa' + end + let :pre_condition do + 'class { "apt": + proxy_host => "user:pass@proxy", + }' + end + let :filename do + "#{title}-#{release}.list" + end + + it { should contain_exec("add-apt-repository-#{title}").with( + 'environment' => [ + "http_proxy=http://user:pass@proxy:8080", + "https_proxy=http://user:pass@proxy:8080", + ], + 'command' => "/usr/bin/add-apt-repository #{options} #{title}", + 'unless' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}", + 'require' => ["File[sources.list.d]", "Package[#{package}]"], + 'notify' => "Exec[apt_update]" + ) + } + end + end + end + + [ { :lsbdistcodename => 'natty', + :package => 'python-software-properties' }, + { :lsbdistcodename => 'quantal', + :package => 'software-properties-common'}, + ].each do |platform| + context "on #{platform[:lsbdistcodename]}" do + describe "it should not error if package['#{platform[:package]}'] is already defined" do + let :pre_condition do + 'class {"apt": }' + + 'package { "#{platform[:package]}": }->Apt::Ppa["ppa"]' + end + let :facts do + {:lsbdistcodename => '#{platform[:lsbdistcodename]}', + :operatingsystem => 'Ubuntu', + :lsbdistid => 'Ubuntu'} + end + let(:title) { "ppa" } + let(:release) { "#{platform[:lsbdistcodename]}" } + it { should contain_package('#{platform[:package]}') } + end + end + end + + describe "without Class[apt] should raise a Puppet::Error" do + let(:release) { "natty" } + let(:title) { "ppa" } + it { expect { should contain_apt__ppa(title) }.to raise_error(Puppet::Error) } + end + + describe "without release should raise a Puppet::Error" do + let(:title) { "ppa:" } + it { expect { should contain_apt__ppa(:release) }.to raise_error(Puppet::Error) } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/source_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/source_spec.rb new file mode 100644 index 0000000000..9da8b235fe --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/defines/source_spec.rb @@ -0,0 +1,167 @@ +require 'spec_helper' +describe 'apt::source', :type => :define do + let(:facts) { { :lsbdistid => 'Debian' } } + let :title do + 'my_source' + end + + let :default_params do + { + :ensure => 'present', + :location => '', + :release => 'karmic', + :repos => 'main', + :include_src => true, + :required_packages => false, + :key => false, + :key_server => 'keyserver.ubuntu.com', + :key_content => false, + :key_source => false, + :pin => false + } + end + + [{}, + { + :location => 'http://example.com', + :release => 'precise', + :repos => 'security', + :include_src => false, + :required_packages => 'apache', + :key => 'key_name', + :key_server => 'keyserver.debian.com', + :pin => '600', + :key_content => 'ABCD1234' + }, + { + :key => 'key_name', + :key_server => 'keyserver.debian.com', + :key_content => false, + }, + { + :ensure => 'absent', + :location => 'http://example.com', + :release => 'precise', + :repos => 'security', + }, + { + :release => '', + }, + { + :release => 'custom', + }, + { + :architecture => 'amd64', + } + ].each do |param_set| + describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do + let :param_hash do + default_params.merge(param_set) + end + + let :facts do + {:lsbdistcodename => 'karmic', :lsbdistid => 'Ubuntu'} + end + + let :params do + param_set + end + + let :filename do + "/etc/apt/sources.list.d/#{title}.list" + end + + let :content do + content = "# #{title}" + if param_hash[:architecture] + arch = "[arch=#{param_hash[:architecture]}] " + end + content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" + + if param_hash[:include_src] + content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n" + end + content + end + + it { should contain_apt__params } + + it { should contain_file("#{title}.list").with({ + 'ensure' => param_hash[:ensure], + 'path' => filename, + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'content' => content, + }) + } + + it { + if param_hash[:pin] + should contain_apt__pin(title).with({ + "priority" => param_hash[:pin], + "before" => "File[#{title}.list]" + }) + else + should_not contain_apt__pin(title).with({ + "priority" => param_hash[:pin], + "before" => "File[#{title}.list]" + }) + end + } + + it { + should contain_exec("apt_update").with({ + "command" => "/usr/bin/apt-get update", + "refreshonly" => true + }) + } + + it { + if param_hash[:required_packages] + should contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({ + "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}", + "subscribe" => "File[#{title}.list]", + "refreshonly" => true, + "before" => 'Exec[apt_update]', + }) + else + should_not contain_exec("Required packages: '#{param_hash[:required_packages]}' for #{title}").with({ + "command" => "/usr/bin/apt-get -y install #{param_hash[:required_packages]}", + "subscribe" => "File[#{title}.list]", + "refreshonly" => true + }) + end + } + + it { + if param_hash[:key] + should contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({ + "key" => param_hash[:key], + "ensure" => :present, + "key_server" => param_hash[:key_server], + "key_content" => param_hash[:key_content], + "key_source" => param_hash[:key_source], + "before" => "File[#{title}.list]" + }) + else + should_not contain_apt__key("Add key: #{param_hash[:key]} from Apt::Source #{title}").with({ + "key" => param_hash[:key], + "ensure" => :present, + "key_server" => param_hash[:key_server], + "key_content" => param_hash[:key_content], + "key_source" => param_hash[:key_source], + "before" => "File[#{title}.list]" + }) + end + } + end + end + describe "without release should raise a Puppet::Error" do + let(:default_params) { Hash.new } + let(:facts) { Hash.new } + it { expect { should raise_error(Puppet::Error) } } + let(:facts) { { :lsbdistcodename => 'lucid', :lsbdistid => 'Ubuntu' } } + it { should contain_apt__source(title) } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/spec_helper.rb new file mode 100644 index 0000000000..2c6f56649a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/spec_helper_acceptance.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000000..3352564ce7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/spec/spec_helper_acceptance.rb @@ -0,0 +1,33 @@ +require 'beaker-rspec' + +# Install Puppet +unless ENV['RS_PROVISION'] == 'no' + hosts.each do |host| + if host.is_pe? + install_pe + else + install_puppet + on host, "mkdir -p #{host['distmoduledir']}" + end + end +end + +UNSUPPORTED_PLATFORMS = ['RedHat','Suse','windows','AIX','Solaris'] + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + puppet_module_install(:source => proj_root, :module_name => 'apt') + hosts.each do |host| + shell('/bin/touch /etc/puppet/hiera.yaml') + shell('puppet module install puppetlabs-stdlib --version 2.2.1', { :acceptable_exit_codes => [0,1] }) + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/10periodic.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/10periodic.erb new file mode 100644 index 0000000000..5737c9ac29 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/10periodic.erb @@ -0,0 +1,12 @@ +APT::Periodic::Enable "<%= @enable %>"; +APT::Periodic::BackUpArchiveInterval "<%= @backup_interval %>"; +APT::Periodic::BackUpLevel "<%= @backup_level %>"; +APT::Periodic::MaxAge "<%= @max_age %>"; +APT::Periodic::MinAge "<%= @min_age %>"; +APT::Periodic::MaxSize "<%= @max_size %>"; +APT::Periodic::Update-Package-Lists "<%= @update %>"; +APT::Periodic::Download-Upgradeable-Packages "<%= @download %>"; +APT::Periodic::Download-Upgradeable-Packages-Debdelta "<%= @download_delta %>"; +APT::Periodic::Unattended-Upgrade "<%= @upgrade %>"; +APT::Periodic::AutocleanInterval "<%= @autoclean %>"; +APT::Periodic::Verbose "<%= @verbose %>"; diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/50unattended-upgrades.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/50unattended-upgrades.erb new file mode 100644 index 0000000000..4df0f74401 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/50unattended-upgrades.erb @@ -0,0 +1,53 @@ +// Automatically upgrade packages from these (origin:archive) pairs +Unattended-Upgrade::Allowed-Origins { +<% @origins.each do |origin| -%> + "<%= origin %>"; +<% end -%> +}; + +// List of packages to not update +Unattended-Upgrade::Package-Blacklist { +<% @blacklist.each do |package| -%> + "<%= package %>"; +<% end -%> +}; + +// This option allows you to control if on a unclean dpkg exit +// unattended-upgrades will automatically run +// dpkg --force-confold --configure -a +// The default is true, to ensure updates keep getting installed +Unattended-Upgrade::AutoFixInterruptedDpkg "<%= @auto_fix %>"; + +// Split the upgrade into the smallest possible chunks so that +// they can be interrupted with SIGUSR1. This makes the upgrade +// a bit slower but it has the benefit that shutdown while a upgrade +// is running is possible (with a small delay) +Unattended-Upgrade::MinimalSteps "<%= @minimal_steps %>"; + +// Install all unattended-upgrades when the machine is shuting down +// instead of doing it in the background while the machine is running +// This will (obviously) make shutdown slower +Unattended-Upgrade::InstallOnShutdown "<%= @install_on_shutdown %>"; + +// Send email to this address for problems or packages upgrades +// If empty or unset then no email is sent, make sure that you +// have a working mail setup on your system. A package that provides +// 'mailx' must be installed. +<% if @mail_to != "NONE" %>Unattended-Upgrade::Mail "<%= @mail_to %>";<% end %> + +// Set this value to "true" to get emails only on errors. Default +// is to always send a mail if Unattended-Upgrade::Mail is set +<% if @mail_to != "NONE" %>Unattended-Upgrade::MailOnlyOnError "<%= @mail_only_on_error %>";<% end %> + +// Do automatic removal of new unused dependencies after the upgrade +// (equivalent to apt-get autoremove) +Unattended-Upgrade::Remove-Unused-Dependencies "<%= @remove_unused %>"; + +// Automatically reboot *WITHOUT CONFIRMATION* if a +// the file /var/run/reboot-required is found after the upgrade +Unattended-Upgrade::Automatic-Reboot "<%= @auto_reboot %>"; + + +// Use apt bandwidth limit feature, this example limits the download +// speed to 70kb/sec +<% if @dl_limit != "NONE" %>Acquire::http::Dl-Limit "<%= @dl_limit %>";<% end %> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/pin.pref.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/pin.pref.erb new file mode 100644 index 0000000000..eed0c10db6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/pin.pref.erb @@ -0,0 +1,22 @@ +<%- +@pin = "release a=#{@name}" # default value +if @pin_release.length > 0 + options = [] + options.push("a=#{@release}") if @release.length > 0 + options.push("n=#{@codename}") if @codename.length > 0 + options.push("v=#{@release_version}") if @release_version.length > 0 + options.push("c=#{@component}") if @component.length > 0 + options.push("o=#{@originator}") if @originator.length > 0 + options.push("l=#{@label}") if @label.length > 0 + @pin = "release #{options.join(', ')}" +elsif @version.length > 0 + @pin = "version #{@version}" +elsif @origin.length > 0 + @pin = "origin #{@origin}" +end +-%> +# <%= @name %> +Explanation: <%= @explanation %> +Package: <%= @packages %> +Pin: <%= @pin %> +Pin-Priority: <%= @priority %> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/source.list.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/source.list.erb new file mode 100644 index 0000000000..9946966ee5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/templates/source.list.erb @@ -0,0 +1,5 @@ +# <%= @name %> +deb <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> +<%- if @include_src then -%> +deb-src <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %> +<%- end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/builddep.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/builddep.pp new file mode 100644 index 0000000000..8b4f796408 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/builddep.pp @@ -0,0 +1,2 @@ +class { 'apt': } +apt::builddep{ 'glusterfs-server': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/debian/testing.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/debian/testing.pp new file mode 100644 index 0000000000..8245b3a337 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/debian/testing.pp @@ -0,0 +1,2 @@ +class { 'apt': } +class { 'apt::debian::testing': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/debian/unstable.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/debian/unstable.pp new file mode 100644 index 0000000000..8605179295 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/debian/unstable.pp @@ -0,0 +1,2 @@ +class { 'apt': } +class { 'apt::debian::unstable': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/force.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/force.pp new file mode 100644 index 0000000000..59ad8f1b57 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/force.pp @@ -0,0 +1,17 @@ +# force.pp + +# force a package from a specific release +apt::force { 'package1': + release => 'backports', +} + +# force a package to be a specific version +apt::force { 'package2': + version => '1.0.0-1', +} + +# force a package from a specific release to be a specific version +apt::force { 'package3': + release => 'sid', + version => '2.0.0-1', +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/init.pp new file mode 100644 index 0000000000..abc75afa25 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/init.pp @@ -0,0 +1 @@ +class { 'apt': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/key.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/key.pp new file mode 100644 index 0000000000..79e0e1b749 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/key.pp @@ -0,0 +1,6 @@ +# Declare Apt key for apt.puppetlabs.com source +apt::key { 'puppetlabs': + key => '4BD6EC30', + key_server => 'pgp.mit.edu', + key_options => 'http-proxy="http://proxyuser:proxypass@example.org:3128"', +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/params.pp new file mode 100644 index 0000000000..5ddf3c6551 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/params.pp @@ -0,0 +1 @@ +include apt::params diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/pin.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/pin.pp new file mode 100644 index 0000000000..6a9024c234 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/pin.pp @@ -0,0 +1,5 @@ +# pin a release in apt, useful for unstable repositories +apt::pin { 'foo': + packages => '*', + priority => 0, +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/ppa.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/ppa.pp new file mode 100644 index 0000000000..e728f6f10f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/ppa.pp @@ -0,0 +1,4 @@ +class { 'apt': } + +# Example declaration of an Apt PPA +apt::ppa{ 'ppa:openstack-ppa/bleeding-edge': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/release.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/release.pp new file mode 100644 index 0000000000..823f5861fa --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/release.pp @@ -0,0 +1,4 @@ +class { 'apt': } +class { 'apt::release': + release_id => 'karmic' +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/source.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/source.pp new file mode 100644 index 0000000000..c20b59662a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/source.pp @@ -0,0 +1,29 @@ +# Declare the apt class to manage /etc/apt/sources.list and /etc/sources.list.d +class { 'apt': } + +# Install the puppetlabs apt source +# Release is automatically obtained from lsbdistcodename fact if available. +apt::source { 'puppetlabs': + location => 'http://apt.puppetlabs.com', + repos => 'main', + key => '4BD6EC30', + key_server => 'pgp.mit.edu', +} + +# test two sources with the same key +apt::source { 'debian_testing': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'testing', + repos => 'main contrib non-free', + key => '46925553', + key_server => 'subkeys.pgp.net', + pin => '-10', +} +apt::source { 'debian_unstable': + location => 'http://debian.mirror.iweb.ca/debian/', + release => 'unstable', + repos => 'main contrib non-free', + key => '46925553', + key_server => 'subkeys.pgp.net', + pin => '-10', +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/unattended_upgrades.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/unattended_upgrades.pp new file mode 100644 index 0000000000..3b9b49eb72 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/apt/tests/unattended_upgrades.pp @@ -0,0 +1 @@ +include apt::unattended_upgrades diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/.travis.yml new file mode 100644 index 0000000000..788946406c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/.travis.yml @@ -0,0 +1,26 @@ +language: ruby +rvm: + - "1.8.7" +# life with later versions of ruby gets interesting with 2.6..so lets +# ignore them for now +# - "1.9.2" +# - "1.9.3" +# - ruby-head ..that doesnt work. would be nice to do "current" + +env: +#find versions here https://rubygems.org/gems/puppet/versions +# spec_helper pretty much fails on these earlier versions. +# - PUPPET_VERSION=0.24.5 +# - PUPPET_VERSION=0.25.5 + - PUPPET_VERSION=2.6.18 + - PUPPET_VERSION=2.7.21 + - PUPPET_VERSION=3.1.1 + + +before_script: + - cd beanstalkd + - bundle install + - bundle show + +script: + - bundle exec rake diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/Gemfile new file mode 100644 index 0000000000..c9aabd4b8c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/Gemfile @@ -0,0 +1,12 @@ +source 'https://rubygems.org' + +puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7'] + + +gem 'rake' +gem 'rspec-expectations' +gem 'rspec' +gem 'facter' +gem 'puppet', puppetversion +gem 'rspec-puppet' +gem 'puppetlabs_spec_helper' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/README.md new file mode 100644 index 0000000000..6abbcb7fb2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/README.md @@ -0,0 +1,68 @@ +puppet-beanstalkd +================= +[](https://travis-ci.org/keen99/puppet-beanstalkd) + +puppet module for managing beanstalkd, a simple and fast work queue - https://github.com/kr/beanstalkd + + +## Supported OSes + +redhat/centos and debian/ubuntu currently. Please PR updates for others! + +Requires packages (rpm, etc) with traditional init scripts supported by service{} for your OS. + + +## Basic Usage + +Drop the beanstalkd directory into your modules tree and realize the define: + + beanstalkd::config{"my beanstalk install": } + +## Optional parameters + + listenaddress => '0.0.0.0', + listenport => '13000', + maxjobsize => '65535', + maxconnections => '1024', + binlogdir => '/var/lib/beanstalkd/binlog', # set empty ( '' ) to disable binlog + binlogfsync => undef, + binlogsize => '10485760', + ensure => 'running', # running, stopped, absent + packageversion => 'latest', # latest, present, or specific version + packagename => undef, # override package name + servicename => undef # override service name + + + + + +## Tests + +To run unit tests, cd into beanstalkd and execute "run-tests.sh" + +Requires ruby and bundler, everything else should get installed by the test. + +``` +$$ puppet-beanstalkd/beanstalkd# ./run-tests.sh +Using rake (10.0.4) +Using diff-lcs (1.2.4) +Using facter (1.7.0) +Using json_pure (1.7.7) +Using hiera (1.2.1) +Using metaclass (0.0.1) +Using mocha (0.13.3) +Using puppet (3.1.1) +Using rspec-core (2.13.1) +Using rspec-expectations (2.13.0) +Using rspec-mocks (2.13.1) +Using rspec (2.13.0) +Using rspec-puppet (0.1.6) +Using puppetlabs_spec_helper (0.4.1) +Using bundler (1.1.4) +Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. +/usr/bin/ruby1.9.1 -S rspec spec/defines/config_spec.rb +................... + +Finished in 0.84772 seconds +19 examples, 0 failures +``` diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/Rakefile new file mode 100644 index 0000000000..f6d5a0c463 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/Rakefile @@ -0,0 +1,10 @@ +require 'rake' + +require 'rspec/core/rake_task' + +task :default => [:spec] + + +RSpec::Core::RakeTask.new(:spec) do |t| + t.pattern = 'spec/*/*_spec.rb' +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/manifests/init.pp new file mode 100644 index 0000000000..fc57ab851a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/manifests/init.pp @@ -0,0 +1,124 @@ + +# usage: +# +# beanstalkd::config { name: +# listenaddress => '0.0.0.0', +# listenport => '13000', +# maxjobsize => '65535', +# maxconnections => '1024', +# binlogdir => '/var/lib/beanstalkd/binlog', +# binlogfsync => undef, +# binlogsize => '10485760', +# ensure => 'running', # running, stopped, absent +# packageversion => 'latest', # latest, present, or specific version +# packagename => undef, # override package name +# servicename => undef # override service name +# } + + +define beanstalkd::config ( # name + $listenaddress = '0.0.0.0', + $listenport = '13000', + $maxjobsize = '65535', + $maxconnections = '1024', # results in open file limit + $binlogdir = '/var/lib/beanstalkd/binlog', # set empty ( '' ) to disable binlog + $binlogfsync = undef, # unset = no explicit fsync + $binlogsize = '10485760', + # + $ensure = 'running', # running, stopped, absent + $packageversion = 'latest', # latest, present, or specific version + $packagename = undef, # got your own custom package? override the default name/service here. + $servicename = undef +) { + + case $::operatingsystem { + ubuntu, debian: { + $defaultpackagename = 'beanstalkd' + $defaultservicename = 'beanstalkd' + $user = 'beanstalkd' + $configfile = '/etc/default/beanstalkd' + $configtemplate = "${module_name}/debian/beanstalkd_default.erb" # please create me! + $hasstatus = 'true' + $restart = '/etc/init.d/beanstalkd restart' + } + centos, redhat: { + $defaultpackagename = 'beanstalkd' + $defaultservicename = 'beanstalkd' + $user = 'beanstalkd' + $configfile = '/etc/sysconfig/beanstalkd' + $configtemplate = "${module_name}/redhat/beanstalkd_sysconfig.erb" + $hasstatus = 'true' + $restart = '/etc/init.d/beanstalkd restart' + } + # TODO: add more OS support! + default: { + fail("ERROR [${module_name}]: I don't know how to manage this OS: ${::operatingsystem}") + } + } + + # simply the users experience for running/stopped/absent, and use ensure to cover those bases + case $ensure { + absent: { + $ourpackageversion = 'absent' + $serviceenable = 'false' + $serviceensure = 'stopped' + $fileensure = 'absent' + } + running: { + $serviceenable = 'true' + $serviceensure = 'running' + $fileensure = 'present' + } + stopped: { + $serviceenable = 'false' + $serviceensure = 'stopped' + $fileensure = 'present' + } + default: { + fail("ERROR [${module_name}]: enable must be one of: running stopped absent") + } + } + + # for packageversion, use what's configured unless we're set (which should only be in the absent case..) + if ! $ourpackageversion { + $ourpackageversion = $packageversion + } + + # for service and package name - if we've specified one, use it. else use the default + if $packagename == undef { + $ourpackagename = $defaultpackagename + } else { + $ourpackagename = $packagename + } + + if $servicename == undef { + $ourservicename = $defaultservicename + } else { + $ourservicename = $servicename + } + + package { $ourpackagename: + ensure => $ourpackageversion + } + + service { $ourservicename: + enable => $serviceenable, + ensure => $serviceensure, + hasstatus => $hasstatus, + restart => $restart, + subscribe => [ + Package[$ourpackagename], + File[$configfile] + ], + } + + file { $configfile: + content => template($configtemplate), + owner => 'root', + group => 'root', + mode => 0644, + ensure => $fileensure, + require => Package[$ourpackagename], + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/run-tests.sh b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/run-tests.sh new file mode 100755 index 0000000000..89896b94fb --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/run-tests.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +bundle="bundle" +gotbundle=0 +for i in $(echo "$PATH" | tr ":" " ") + do + if [ -e $i/$bundle ] + then + gotbundle=1 + break + fi +done +if [ $gotbundle = 0 ] + then + echo "ERROR: please install 'bundler' for ruby from http://gembundler.com/ and make sure '$bundle' is in your path" + exit 1 +fi + +$bundle install || exit $? +$bundle exec rake || exit $? diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/defines/config_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/defines/config_spec.rb new file mode 100644 index 0000000000..e70c3fe40f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/defines/config_spec.rb @@ -0,0 +1,80 @@ +require 'spec_helper' + + +describe 'beanstalkd::config' do + let (:title) {'a title is required'} + + #basic OS support testing + context "on Debian" do + let (:facts) { { :operatingsystem => 'debian' } } + it { should contain_package('beanstalkd').with_ensure('latest') } + it { should contain_service('beanstalkd').with_ensure('running') } + end + context "on redhat" do + let (:facts) { { :operatingsystem => 'debian' } } + it { should contain_package('beanstalkd').with_ensure('latest') } + it { should contain_service('beanstalkd').with_ensure('running') } + end + context "on ubuntu" do + let (:facts) { { :operatingsystem => 'ubuntu' } } + it { should contain_package('beanstalkd').with_ensure('latest') } + it { should contain_service('beanstalkd').with_ensure('running') } + end + context "on centos" do + let (:facts) { { :operatingsystem => 'centos' } } + it { should contain_package('beanstalkd').with_ensure('latest') } + it { should contain_service('beanstalkd').with_ensure('running') } + end + context "on unsupported OS" do + let (:facts) { { :operatingsystem => 'unsupported' } } + it { expect { raise_error(Puppet::Error) } } + end + + #now lets test our various parameters - for the most part this shouldn't care what OS it is + #if your OS support needs more specific testing, do it! + + #ensure testing - remember this does both service and packages, so test both + context "on redhat, ensure absent" do + let (:facts) { { :operatingsystem => 'redhat' } } + let(:params) { { :ensure => 'absent' } } + it { should contain_package('beanstalkd').with_ensure('absent') } + it { should contain_service('beanstalkd').with_ensure('stopped') } + end + context "on redhat, ensure running" do + let (:facts) { { :operatingsystem => 'redhat' } } + let(:params) { { :ensure => 'running' } } + it { should contain_package('beanstalkd').with_ensure('latest') } + it { should contain_service('beanstalkd').with_ensure('running') } + end + context "on redhat, ensure stopped" do + let (:facts) { { :operatingsystem => 'redhat' } } + let(:params) { { :ensure => 'stopped' } } + it { should contain_package('beanstalkd').with_ensure('latest') } + it { should contain_service('beanstalkd').with_ensure('stopped') } + end + context "on redhat, ensure broken" do + let (:facts) { { :operatingsystem => 'redhat' } } + let(:params) { { :ensure => 'broken' } } + it { expect { raise_error(Puppet::Error) } } + end + + #custom package/service names + context "on redhat, servicename testbeans" do + let (:facts) { { :operatingsystem => 'redhat' } } + let(:params) { { :servicename => 'testbeans' } } + it { should contain_service('testbeans').with_ensure('running') } + end + context "on redhat, packagename testbeans" do + let (:facts) { { :operatingsystem => 'redhat' } } + let(:params) { { :packagename => 'testbeans' } } + it { should contain_package('testbeans').with_ensure('latest') } + end + #and custom version + context "on redhat, package version" do + let (:facts) { { :operatingsystem => 'redhat' } } + let(:params) { { :packageversion => 'testversion' } } + it { should contain_package('beanstalkd').with_ensure('testversion') } + end + + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/manifests/site.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/manifests/site.pp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/modules/beanstalkd/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/modules/beanstalkd/manifests/init.pp new file mode 100644 index 0000000000..fc57ab851a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/modules/beanstalkd/manifests/init.pp @@ -0,0 +1,124 @@ + +# usage: +# +# beanstalkd::config { name: +# listenaddress => '0.0.0.0', +# listenport => '13000', +# maxjobsize => '65535', +# maxconnections => '1024', +# binlogdir => '/var/lib/beanstalkd/binlog', +# binlogfsync => undef, +# binlogsize => '10485760', +# ensure => 'running', # running, stopped, absent +# packageversion => 'latest', # latest, present, or specific version +# packagename => undef, # override package name +# servicename => undef # override service name +# } + + +define beanstalkd::config ( # name + $listenaddress = '0.0.0.0', + $listenport = '13000', + $maxjobsize = '65535', + $maxconnections = '1024', # results in open file limit + $binlogdir = '/var/lib/beanstalkd/binlog', # set empty ( '' ) to disable binlog + $binlogfsync = undef, # unset = no explicit fsync + $binlogsize = '10485760', + # + $ensure = 'running', # running, stopped, absent + $packageversion = 'latest', # latest, present, or specific version + $packagename = undef, # got your own custom package? override the default name/service here. + $servicename = undef +) { + + case $::operatingsystem { + ubuntu, debian: { + $defaultpackagename = 'beanstalkd' + $defaultservicename = 'beanstalkd' + $user = 'beanstalkd' + $configfile = '/etc/default/beanstalkd' + $configtemplate = "${module_name}/debian/beanstalkd_default.erb" # please create me! + $hasstatus = 'true' + $restart = '/etc/init.d/beanstalkd restart' + } + centos, redhat: { + $defaultpackagename = 'beanstalkd' + $defaultservicename = 'beanstalkd' + $user = 'beanstalkd' + $configfile = '/etc/sysconfig/beanstalkd' + $configtemplate = "${module_name}/redhat/beanstalkd_sysconfig.erb" + $hasstatus = 'true' + $restart = '/etc/init.d/beanstalkd restart' + } + # TODO: add more OS support! + default: { + fail("ERROR [${module_name}]: I don't know how to manage this OS: ${::operatingsystem}") + } + } + + # simply the users experience for running/stopped/absent, and use ensure to cover those bases + case $ensure { + absent: { + $ourpackageversion = 'absent' + $serviceenable = 'false' + $serviceensure = 'stopped' + $fileensure = 'absent' + } + running: { + $serviceenable = 'true' + $serviceensure = 'running' + $fileensure = 'present' + } + stopped: { + $serviceenable = 'false' + $serviceensure = 'stopped' + $fileensure = 'present' + } + default: { + fail("ERROR [${module_name}]: enable must be one of: running stopped absent") + } + } + + # for packageversion, use what's configured unless we're set (which should only be in the absent case..) + if ! $ourpackageversion { + $ourpackageversion = $packageversion + } + + # for service and package name - if we've specified one, use it. else use the default + if $packagename == undef { + $ourpackagename = $defaultpackagename + } else { + $ourpackagename = $packagename + } + + if $servicename == undef { + $ourservicename = $defaultservicename + } else { + $ourservicename = $servicename + } + + package { $ourpackagename: + ensure => $ourpackageversion + } + + service { $ourservicename: + enable => $serviceenable, + ensure => $serviceensure, + hasstatus => $hasstatus, + restart => $restart, + subscribe => [ + Package[$ourpackagename], + File[$configfile] + ], + } + + file { $configfile: + content => template($configtemplate), + owner => 'root', + group => 'root', + mode => 0644, + ensure => $fileensure, + require => Package[$ourpackagename], + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/modules/beanstalkd/templates/debian/beanstalkd_default.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/modules/beanstalkd/templates/debian/beanstalkd_default.erb new file mode 100644 index 0000000000..c532f47bd8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/modules/beanstalkd/templates/debian/beanstalkd_default.erb @@ -0,0 +1,123 @@ +#!/bin/sh +##based loosely on my sysconfig and initd scripts from centos, but tweaked to work without having to +##hack up the debian init script. -keen99 4/2013 + +<% if @maxconnections -%> +BEANSTALKD_MAXCONNECTIONS=<%= @maxconnections %> +<% else -%> +#use default ulimit +#BEANSTALKD_MAXCONNECTIONS=1024 +<% end -%> + + +BEANSTALKD_ADDR=<%= @listenaddress %> +BEANSTALKD_PORT=<%= @listenport %> +BEANSTALKD_USER=<%= @user %> + +# Job size is left to the default. Uncomment and set it +# to a value to have it take affect. +<% if @maxjobsize -%> +BEANSTALKD_MAX_JOB_SIZE=<%= @maxjobsize %> +<% else -%> +#use default +#BEANSTALKD_MAX_JOB_SIZE=65535 +<% end -%> + +# Using the binlog is off by default. +# +# The direcory to house the binlog. +<% if @binlogdir -%> +BEANSTALKD_BINLOG_DIR=<%= @binlogdir %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_DIR=/var/lib/beanstalkd/binlog +<% end -%> + +# fsync the binlog at most once every N milliseconds. +# setting this to 0 means 'always fsync'. If this is unset, +# and the binlog is used, then no explicit fsync is ever +# performed. That is, the -F option is used. +<% if @binlogfsync -%> +BEANSTALKD_BINLOG_FSYNC_PERIOD=<%= @bbinlogfsync %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_FSYNC_PERIOD= +<% end -%> + +# The size of each binlog file. This is rounded +# up to the nearest 512 byte boundary. +<% if @binlogsize -%> +BEANSTALKD_BINLOG_SIZE=<%= @binlogsize %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_SIZE=10485760 +<% end -%> + + + + +##the debian init script leaves everything to be desired. so lets put our setup logic here. + +case "$1" in + start|restart|force-reload|reload) + exec=$DAEMON + [ -x $exec ] || exit 5 + + # if not running, start it up here, usually something like "daemon $exec" + options="-l ${BEANSTALKD_ADDR} -p ${BEANSTALKD_PORT} -u ${BEANSTALKD_USER}" + if [ "${BEANSTALKD_MAX_JOB_SIZE}" != "" ]; then + options="${options} -z ${BEANSTALKD_MAX_JOB_SIZE}" + fi + + if [ "${BEANSTALKD_BINLOG_DIR}" != "" ]; then + if [ ! -d "${BEANSTALKD_BINLOG_DIR}" ]; then + echo "Creating binlog directory (${BEANSTALKD_BINLOG_DIR})" + mkdir -p ${BEANSTALKD_BINLOG_DIR} && chown ${BEANSTALKD_USER}:${BEANSTALKD_USER} ${BEANSTALKD_BINLOG_DIR} + fi + options="${options} -b ${BEANSTALKD_BINLOG_DIR}" + if [ "${BEANSTALKD_BINLOG_FSYNC_PERIOD}" != "" ]; then + options="${options} -f ${BEANSTALKD_BINLOG_FSYNC_PERIOD}" + else + options="${options} -F" + fi + if [ "${BEANSTALKD_BINLOG_SIZE}" != "" ]; then + options="${options} -s ${BEANSTALKD_BINLOG_SIZE}" + fi + + ##1.4.6 at least is prone to leave a lock file around after shutting down + ##this breaks startup after upgrade to 1.5, so work around this + ##unknown if this happens w/o binlog enabled... + #check for stale lock file in binlog + if [ -e "${BEANSTALKD_BINLOG_DIR}/lock" ] + then + if ! ps xa| grep -v grep | grep -q $exec + then + echo "found old lock file and beanstalk isn't running - deleting it" + rm -f ${BEANSTALKD_BINLOG_DIR}/lock + fi + fi + fi + + if [ -n "${BEANSTALKD_MAXCONNECTIONS}" ]; then + #increase open files ulimit to support higher concurrent connections + echo "increasing open file limit to $BEANSTALKD_MAXCONNECTIONS" + ulimit -n $BEANSTALKD_MAXCONNECTIONS + fi + + DAEMON_OPTS="-l $BEANSTALKD_LISTEN_ADDR -p $BEANSTALKD_LISTEN_PORT" + DAEMON_OPTS="$options" + + ;; + *) + #nothing, please keep moving + ;; +esac + + + +DAEMONUSER=$BEANSTALKD_USER + + +## Uncomment to enable startup during boot. +START=yes + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/modules/beanstalkd/templates/redhat/beanstalkd_sysconfig.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/modules/beanstalkd/templates/redhat/beanstalkd_sysconfig.erb new file mode 100644 index 0000000000..6e3bb422ec --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/fixtures/modules/beanstalkd/templates/redhat/beanstalkd_sysconfig.erb @@ -0,0 +1,56 @@ +# System configuration for the beanstalkd daemon + +# Available options correspond to the options to the +# beanstalkd commandline. + +<% if @maxconnections -%> +BEANSTALKD_MAXCONNECTIONS=<%= @maxconnections %> +<% else -%> +#use default ulimit +#BEANSTALKD_MAXCONNECTIONS=1024 +<% end -%> + + +BEANSTALKD_ADDR=<%= @listenaddress %> +BEANSTALKD_PORT=<%= @listenport %> +BEANSTALKD_USER=<%= @user %> + +# Job size is left to the default. Uncomment and set it +# to a value to have it take affect. +<% if @maxjobsize -%> +BEANSTALKD_MAX_JOB_SIZE=<%= @maxjobsize %> +<% else -%> +#use default +#BEANSTALKD_MAX_JOB_SIZE=65535 +<% end -%> + +# Using the binlog is off by default. +# +# The direcory to house the binlog. +<% if @binlogdir -%> +BEANSTALKD_BINLOG_DIR=<%= @binlogdir %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_DIR=/var/lib/beanstalkd/binlog +<% end -%> + +# fsync the binlog at most once every N milliseconds. +# setting this to 0 means 'always fsync'. If this is unset, +# and the binlog is used, then no explicit fsync is ever +# performed. That is, the -F option is used. +<% if @binlogfsync -%> +BEANSTALKD_BINLOG_FSYNC_PERIOD=<%= @bbinlogfsync %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_FSYNC_PERIOD= +<% end -%> + +# The size of each binlog file. This is rounded +# up to the nearest 512 byte boundary. +<% if @binlogsize -%> +BEANSTALKD_BINLOG_SIZE=<%= @binlogsize %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_SIZE=10485760 +<% end -%> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/spec_helper.rb new file mode 100644 index 0000000000..d3923f8306 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/spec/spec_helper.rb @@ -0,0 +1,8 @@ +require 'rspec-puppet' + +fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) + +RSpec.configure do |c| + c.module_path = File.join(fixture_path, 'modules') + c.manifest_dir = File.join(fixture_path, 'manifests') +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/templates/debian/beanstalkd_default.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/templates/debian/beanstalkd_default.erb new file mode 100644 index 0000000000..c532f47bd8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/templates/debian/beanstalkd_default.erb @@ -0,0 +1,123 @@ +#!/bin/sh +##based loosely on my sysconfig and initd scripts from centos, but tweaked to work without having to +##hack up the debian init script. -keen99 4/2013 + +<% if @maxconnections -%> +BEANSTALKD_MAXCONNECTIONS=<%= @maxconnections %> +<% else -%> +#use default ulimit +#BEANSTALKD_MAXCONNECTIONS=1024 +<% end -%> + + +BEANSTALKD_ADDR=<%= @listenaddress %> +BEANSTALKD_PORT=<%= @listenport %> +BEANSTALKD_USER=<%= @user %> + +# Job size is left to the default. Uncomment and set it +# to a value to have it take affect. +<% if @maxjobsize -%> +BEANSTALKD_MAX_JOB_SIZE=<%= @maxjobsize %> +<% else -%> +#use default +#BEANSTALKD_MAX_JOB_SIZE=65535 +<% end -%> + +# Using the binlog is off by default. +# +# The direcory to house the binlog. +<% if @binlogdir -%> +BEANSTALKD_BINLOG_DIR=<%= @binlogdir %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_DIR=/var/lib/beanstalkd/binlog +<% end -%> + +# fsync the binlog at most once every N milliseconds. +# setting this to 0 means 'always fsync'. If this is unset, +# and the binlog is used, then no explicit fsync is ever +# performed. That is, the -F option is used. +<% if @binlogfsync -%> +BEANSTALKD_BINLOG_FSYNC_PERIOD=<%= @bbinlogfsync %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_FSYNC_PERIOD= +<% end -%> + +# The size of each binlog file. This is rounded +# up to the nearest 512 byte boundary. +<% if @binlogsize -%> +BEANSTALKD_BINLOG_SIZE=<%= @binlogsize %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_SIZE=10485760 +<% end -%> + + + + +##the debian init script leaves everything to be desired. so lets put our setup logic here. + +case "$1" in + start|restart|force-reload|reload) + exec=$DAEMON + [ -x $exec ] || exit 5 + + # if not running, start it up here, usually something like "daemon $exec" + options="-l ${BEANSTALKD_ADDR} -p ${BEANSTALKD_PORT} -u ${BEANSTALKD_USER}" + if [ "${BEANSTALKD_MAX_JOB_SIZE}" != "" ]; then + options="${options} -z ${BEANSTALKD_MAX_JOB_SIZE}" + fi + + if [ "${BEANSTALKD_BINLOG_DIR}" != "" ]; then + if [ ! -d "${BEANSTALKD_BINLOG_DIR}" ]; then + echo "Creating binlog directory (${BEANSTALKD_BINLOG_DIR})" + mkdir -p ${BEANSTALKD_BINLOG_DIR} && chown ${BEANSTALKD_USER}:${BEANSTALKD_USER} ${BEANSTALKD_BINLOG_DIR} + fi + options="${options} -b ${BEANSTALKD_BINLOG_DIR}" + if [ "${BEANSTALKD_BINLOG_FSYNC_PERIOD}" != "" ]; then + options="${options} -f ${BEANSTALKD_BINLOG_FSYNC_PERIOD}" + else + options="${options} -F" + fi + if [ "${BEANSTALKD_BINLOG_SIZE}" != "" ]; then + options="${options} -s ${BEANSTALKD_BINLOG_SIZE}" + fi + + ##1.4.6 at least is prone to leave a lock file around after shutting down + ##this breaks startup after upgrade to 1.5, so work around this + ##unknown if this happens w/o binlog enabled... + #check for stale lock file in binlog + if [ -e "${BEANSTALKD_BINLOG_DIR}/lock" ] + then + if ! ps xa| grep -v grep | grep -q $exec + then + echo "found old lock file and beanstalk isn't running - deleting it" + rm -f ${BEANSTALKD_BINLOG_DIR}/lock + fi + fi + fi + + if [ -n "${BEANSTALKD_MAXCONNECTIONS}" ]; then + #increase open files ulimit to support higher concurrent connections + echo "increasing open file limit to $BEANSTALKD_MAXCONNECTIONS" + ulimit -n $BEANSTALKD_MAXCONNECTIONS + fi + + DAEMON_OPTS="-l $BEANSTALKD_LISTEN_ADDR -p $BEANSTALKD_LISTEN_PORT" + DAEMON_OPTS="$options" + + ;; + *) + #nothing, please keep moving + ;; +esac + + + +DAEMONUSER=$BEANSTALKD_USER + + +## Uncomment to enable startup during boot. +START=yes + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/templates/redhat/beanstalkd_sysconfig.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/templates/redhat/beanstalkd_sysconfig.erb new file mode 100644 index 0000000000..6e3bb422ec --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/beanstalkd/templates/redhat/beanstalkd_sysconfig.erb @@ -0,0 +1,56 @@ +# System configuration for the beanstalkd daemon + +# Available options correspond to the options to the +# beanstalkd commandline. + +<% if @maxconnections -%> +BEANSTALKD_MAXCONNECTIONS=<%= @maxconnections %> +<% else -%> +#use default ulimit +#BEANSTALKD_MAXCONNECTIONS=1024 +<% end -%> + + +BEANSTALKD_ADDR=<%= @listenaddress %> +BEANSTALKD_PORT=<%= @listenport %> +BEANSTALKD_USER=<%= @user %> + +# Job size is left to the default. Uncomment and set it +# to a value to have it take affect. +<% if @maxjobsize -%> +BEANSTALKD_MAX_JOB_SIZE=<%= @maxjobsize %> +<% else -%> +#use default +#BEANSTALKD_MAX_JOB_SIZE=65535 +<% end -%> + +# Using the binlog is off by default. +# +# The direcory to house the binlog. +<% if @binlogdir -%> +BEANSTALKD_BINLOG_DIR=<%= @binlogdir %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_DIR=/var/lib/beanstalkd/binlog +<% end -%> + +# fsync the binlog at most once every N milliseconds. +# setting this to 0 means 'always fsync'. If this is unset, +# and the binlog is used, then no explicit fsync is ever +# performed. That is, the -F option is used. +<% if @binlogfsync -%> +BEANSTALKD_BINLOG_FSYNC_PERIOD=<%= @bbinlogfsync %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_FSYNC_PERIOD= +<% end -%> + +# The size of each binlog file. This is rounded +# up to the nearest 512 byte boundary. +<% if @binlogsize -%> +BEANSTALKD_BINLOG_SIZE=<%= @binlogsize %> +<% else -%> +#use default +#BEANSTALKD_BINLOG_SIZE=10485760 +<% end -%> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/.fixtures.yml new file mode 100644 index 0000000000..c0123415c7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/.fixtures.yml @@ -0,0 +1,5 @@ +fixtures: + repositories: + git: "git://github.com/puppetlabs/puppetlabs-git" + symlinks: + composer: "#{source_dir}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/.travis.yml new file mode 100644 index 0000000000..033f11dd3d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/.travis.yml @@ -0,0 +1,13 @@ +language: ruby +rvm: + - 1.9.3 +before_script: +after_script: +script: "bundle exec rake spec" +env: + - PUPPET_VERSION=2.7.23 + - PUPPET_VERSION=3.0.2 + - PUPPET_VERSION=3.2.4 + - PUPPET_VERSION=3.3.0 +notifications: + email: false diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/CHANGELOG.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/CHANGELOG.md new file mode 100644 index 0000000000..bd8105b127 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/CHANGELOG.md @@ -0,0 +1,133 @@ +v1.2.1 +====== +f44b7e5 Now also supports Amazon Linux (RedHat) + +9341805 Now `suhosin_enabled` parameter is correctly documented. + +v1.2.0 +====== +66b071a (HEAD, tag: 1.2.0, master) Bumping version to 1.2.0 + +166ec87 Updated README.md + +626ee43 (origin/master, origin/HEAD) Updated CHANGELOG format + +1364058 Moved CHANGELOG to markdown format + +6f21dcb Updated LICENSE file + +6209eb8 Added CHANGELOG file + +6307d5a Add parameter 'php_bin' to override name or path of php binary + +9e484e9 (origin/rspec_head_fixes, rspec_head_fixes) just match on errorname, not specific exception + +db4176e update specs for latest rspec-puppet 1.0.1+ + +v1.1.1 +====== +17b2309 (tag: 1.1.1) Update Modulefile + +d848038 Used puppetlabs/git >= 0.0.2 + +0d75cff doc updates for 1.1.0 release + +v1.1.0 +====== +3b46e4d (tag: 1.1.0) bumping version to 1.1.0 for refreshonly and user features + +5290e8e support setting exec user for project and exec + +6af1e25 ignore puppet module package folder + +c2106ec Add refreshonly parameter to exec + +v1.0.1 +====== +fb1fd04 (tag: 1.0.1) Bumped version to 1.0.1 + +bf43913 (origin/deprecated_erb_variables) fix deprecated variables in the exec erb template + +342b898 (origin/documentation_refactor) document refactor, add spec test information + +3677acc adding tests for new suhosin_enable param and Debian family + +de86c0d Only run augeas commands if suhosin is enabled + +v1.0.0 +====== +f5d214a (tag: 1.0.0) Bumping version to 1.0.0 + +12589bf fixes for travis-ci building + +5279b92 spec testing using rspec-puppet + +3069608 documentation updates for composer_home and previous PRs + +b5faa45 add a composer_home fact and use it to set up environment + +v0.1.1 +====== +dbc0c74 Bumping version to 0.1.1 + +b4833d6 no-custom-installers is deprecated in favor of no-plugins + +acdc73c dry up the composer binary download code + +41f3a7b CentOS isn't actually an $::osfamily value + +d54c0db PHP binary is provided by php-cli on RHEL systems + +v0.1.0 +====== +1e8f9f1 (tag: 0.1.0) Adding License file. + +523c28f (igalic/option-names, igalic-option-names) update readme with the new options + +3d2ddda double-negating option names is confusing + +be518cf (igalic/style, igalic-style) Fix puppet lint complaints + +4050077 There's no need for these files to be executable + +522e93c Updated temp path. + +bf0f9e7 Support centos/redhat + +f45e9de Support redhat/centos + +920d1ca Support redhat/centos + +v0.0.6 +====== +78643ef (tag: 0.0.6) Bumping version to 0.0.6 + +0fbfb53 Fixing bug where global path is overwritten by local scope. + +v0.0.5 +====== +ee4e49b (tag: 0.0.5) Bumping version to 0.0.5 + +17ca5ee Added varaible composer path to exec calls. + +v0.0.4 +====== +e94be5e (tag: 0.0.4) Bumping version to 0.0.4 + +a27e45f Fixed dry_run parameter + +28cfee8 Adding version parameter to project task README + +v0.0.3 +====== +4787b24 Bumping version to 0.0.3 + +4ee9547 (tag: 0.0.3) Fixing type in exec manifest. + +v0.0.2 +====== +974d2ad (tag: 0.0.2) Bumping version to 0.0.2 + +667eb18 Fixed README + +925aa97 Fixed Modulefile. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/Gemfile new file mode 100644 index 0000000000..992fecaab8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/Gemfile @@ -0,0 +1,17 @@ +#ruby=1.9.3@puppet-composer + +if ENV.key?('PUPPET_VERSION') + puppetversion = "= #{ENV['PUPPET_VERSION']}" +else + puppetversion = ['>= 2.7'] +end + +source 'https://rubygems.org' + +ruby '1.9.3' + +gem 'puppet', puppetversion +gem 'puppetlabs_spec_helper' +gem 'rspec-puppet', :github => 'rodjek/rspec-puppet', :ref => '03e94422fb9bbdd950d5a0bec6ead5d76e06616b' +gem 'mocha' +gem 'puppet-lint' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/LICENSE new file mode 100644 index 0000000000..3cff480369 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013 - 2014 Thomas Ploch + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/Modulefile new file mode 100644 index 0000000000..b1a9c8c49d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/Modulefile @@ -0,0 +1,8 @@ +name 'tPl0ch-composer' +version '1.2.1' +dependency 'puppetlabs/git', '>= 0.0.2' +summary "This module provides the 'Composer' PHP dependency manager." +description "This module installs the 'Composer' PHP dependency manager and provides some custom types to create, update + and install projects. Until now the Debian and Redhat OS families are supported." +project_page "https://github.com/tPl0ch/puppet-composer" +author "tPl0ch - Thomas Ploch " diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/README.md new file mode 100644 index 0000000000..c142e258f0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/README.md @@ -0,0 +1,155 @@ +# Composer Puppet Module + +[](https://travis-ci.org/tPl0ch/puppet-composer) + +## Description + +The `puppet-composer` module installs the latest version of Composer from http://getcomposer.org. Composer is a dependency manager for PHP. + +## Supported Platforms + +* `Debian` +* `Redhat` +* `Centos` +* `Amazon Linux` + +## Installation + +#### Puppet Forge +We recommend installing using the Puppet Forge as it automatically satisfies dependencies. + + puppet module install --target-dir=/your/path/to/modules tPl0ch-composer + +#### Installation via git submodule +You can also install as a git submodule and handle the dependencies manually. See the [Dependencies](#dependencies) section below. + + git submodule add git://github.com/tPl0ch/puppet-composer.git modules/composer + +## Dependencies + +This module requires the following Puppet modules: + +* [`puppetlabs-git`](https://github.com/puppetlabs/puppetlabs-git/) + +And additional (for puppet version lower than 3.0.0) you need: + +* [`libaugeas`](http://augeas.net/) (For automatically updating php.ini settings for suhosin patch) + +## Usage +To install the `composer` binary globally in `/usr/local/bin` you only need to declare the `composer` class. We try to set some sane defaults. There are also a number of parameters you can tweak should the defaults not be sufficient. + +### Simple Include +To install the binary with the defaults you just need to include the following in your manifests: + + include composer + +### Full Include +Alternatively, you can set a number of options by declaring the class with parameters: + +```puppet +class { 'composer': + target_dir => '/usr/local/bin', + composer_file => 'composer', # could also be 'composer.phar' + download_method => 'curl', # or 'wget' + logoutput => false, + tmp_path => '/tmp', + php_package => 'php5-cli', + curl_package => 'curl', + wget_package => 'wget', + composer_home => '/root', + php_bin => 'php', # could also i.e. be 'php -d "apc.enable_cli=0"' for more fine grained control + suhosin_enabled => true, +} +``` + +### Creating Projects + +The `composer::project` definition provides a way to create projects in a target directory. + +```puppet +composer::project { 'silex': + project_name => 'fabpot/silex-skeleton', # REQUIRED + target_dir => '/vagrant/silex', # REQUIRED + version => '2.1.x-dev', # Some valid version string + prefer_source => true, + stability => 'dev', # Minimum stability setting + keep_vcs => false, # Keep the VCS information + dev => true, # Install dev dependencies + repository_url => 'http://repo.example.com', # Custom repository URL + user => undef, # Set the user to run as +} +``` + +#### Updating Packages + +The `composer::exec` definition provides a more generic wrapper arround composer `update` and `install` commands. The following example will update the `silex/silex` and `symfony/browser-kit` packages in the `/vagrant/silex` directory. You can omit `packages` to update the entire project. + +```puppet +composer::exec { 'silex-update': + cmd => 'update', # REQUIRED + cwd => '/vagrant/silex', # REQUIRED + packages => ['silex/silex', 'symfony/browser-kit'], # leave empty or omit to update whole project + prefer_source => false, # Only one of prefer_source or prefer_dist can be true + prefer_dist => false, # Only one of prefer_source or prefer_dist can be true + dry_run => false, # Just simulate actions + custom_installers => false, # No custom installers + scripts => false, # No script execution + interaction => false, # No interactive questions + optimize => false, # Optimize autoloader + dev => false, # Install dev dependencies + user => undef, # Set the user to run as + refreshonly => false, # Only run on refresh +} +``` + +#### Installing Packages + +We support the `install` command in addition to `update`. The install command will ignore the `packages` parameter and the following example is the equivalent to running `composer install` in the `/vagrant/silex` directory. + +```puppet +composer::exec { 'silex-install': + cmd => 'install', # REQUIRED + cwd => '/vagrant/silex', # REQUIRED + prefer_source => false, + prefer_dist => false, + dry_run => false, # Just simulate actions + custom_installers => false, # No custom installers + scripts => false, # No script execution + interaction => false, # No interactive questions + optimize => false, # Optimize autoloader + dev => false, # Install dev dependencies +} +``` + +## Development + +We have `rspec-puppet` and Travis CI setup for the project. To run the spec tests locally you need `bundler` installed: + +``` +gem install bundler +``` + +Then you can install the required gems: + +``` +bundle install +``` + +Finally, the tests can be run: + +``` +rake spec +``` + +## Contributing + +We welcome everyone to help develop this module. To contribute: + +* Fork this repository +* Add features and spec tests for them +* Commit to feature named branch +* Open a pull request outlining your changes and the reasoning for them + +## Todo + +* Add a `composer::require` type diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/Rakefile new file mode 100644 index 0000000000..1a388518f2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/Rakefile @@ -0,0 +1,2 @@ +require 'puppet-lint/tasks/puppet-lint' +require 'puppetlabs_spec_helper/rake_tasks' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/lib/facter/composer_home.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/lib/facter/composer_home.rb new file mode 100644 index 0000000000..b815cfa404 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/lib/facter/composer_home.rb @@ -0,0 +1,5 @@ +Facter.add(:composer_home) do + setcode do + ENV['HOME'] + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/exec.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/exec.pp new file mode 100644 index 0000000000..82039e8557 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/exec.pp @@ -0,0 +1,55 @@ +# == Type: composer::exec +# +# Either installs from composer.json or updates project or specific packages +# +# === Authors +# +# Thomas Ploch +# +# === Copyright +# +# Copyright 2013 Thomas Ploch +# +define composer::exec ( + $cmd, + $cwd, + $packages = [], + $prefer_source = false, + $prefer_dist = false, + $dry_run = false, + $custom_installers = false, + $scripts = false, + $optimize = false, + $interaction = false, + $dev = false, + $logoutput = false, + $verbose = false, + $refreshonly = false, + $user = undef, +) { + require composer + require git + + Exec { + path => "/bin:/usr/bin/:/sbin:/usr/sbin:${composer::target_dir}", + environment => "COMPOSER_HOME=${composer::composer_home}", + user => $user, + } + + if $cmd != 'install' and $cmd != 'update' { + fail("Only types 'install' and 'update' are allowed, ${cmd} given") + } + + if $prefer_source and $prefer_dist { + fail('Only one of \$prefer_source or \$prefer_dist can be true.') + } + + $command = "${composer::php_bin} ${composer::target_dir}/${composer::composer_file} ${cmd}" + + exec { "composer_update_${title}": + command => template('composer/exec.erb'), + cwd => $cwd, + logoutput => $logoutput, + refreshonly => $refreshonly + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/init.pp new file mode 100644 index 0000000000..5b3a431921 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/init.pp @@ -0,0 +1,156 @@ +# == Class: composer +# +# The parameters for the composer class and corresponding definitions +# +# === Parameters +# +# Document parameters here. +# +# [*target_dir*] +# The target dir that composer should be installed to. +# Defaults to ```/usr/local/bin```. +# +# [*composer_file*] +# The name of the composer binary, which will reside in ```target_dir```. +# +# [*download_method*] +# Either ```curl``` or ```wget```. +# +# [*logoutput*] +# If the output should be logged. Defaults to FALSE. +# +# [*tmp_path*] +# Where the composer.phar file should be temporarily put. +# +# [*php_package*] +# The Package name of tht PHP CLI package. +# +# [*curl_package*] +# The name of the curl package to override the default set in the +# composer::params class. +# +# [*wget_package*] +# The name of the wget package to override the default set in the +# composer::params class. +# +# [*composer_home*] +# Folder to use as the COMPOSER_HOME environment variable. Default comes +# from our composer::params class which derives from our own $composer_home +# fact. The fact returns the current users $HOME environment variable. +# +# [*php_bin*] +# The name or path of the php binary to override the default set in the +# composer::params class. +# +# === Authors +# +# Thomas Ploch +# +class composer( + $target_dir = $composer::params::target_dir, + $composer_file = $composer::params::composer_file, + $download_method = $composer::params::download_method, + $logoutput = $composer::params::logoutput, + $tmp_path = $composer::params::tmp_path, + $php_package = $composer::params::php_package, + $curl_package = $composer::params::curl_package, + $wget_package = $composer::params::wget_package, + $composer_home = $composer::params::composer_home, + $php_bin = $composer::params::php_bin, + $suhosin_enabled = $composer::params::suhosin_enabled +) inherits composer::params { + + Exec { path => "/bin:/usr/bin/:/sbin:/usr/sbin:${target_dir}" } + + if defined(Package[$php_package]) == false { + package { $php_package: ensure => present, } + } + + # download composer + case $download_method { + 'curl': { + $download_command = "curl -s http://getcomposer.org/installer | ${composer::php_bin}" + $download_require = $suhosin_enabled ? { + true => [ Package['curl', $php_package], Augeas['allow_url_fopen', 'whitelist_phar'] ], + false => [ Package['curl', $php_package] ] + } + $method_package = $curl_package + } + 'wget': { + $download_command = 'wget http://getcomposer.org/composer.phar -O composer.phar' + $download_require = $suhosin_enabled ? { + true => [ Package['wget', $php_package], Augeas['allow_url_fopen', 'whitelist_phar'] ], + false => [ Package['wget', $php_package] ] + } + $method_package = $wget_package + } + default: { + fail("The param download_method ${download_method} is not valid. Please set download_method to curl or wget.") + } + } + + if defined(Package[$method_package]) == false { + package { $method_package: ensure => present, } + } + + exec { 'download_composer': + command => $download_command, + cwd => $tmp_path, + require => $download_require, + creates => "${tmp_path}/composer.phar", + logoutput => $logoutput, + } + + # check if directory exists + file { $target_dir: + ensure => directory, + } + + # move file to target_dir + file { "${target_dir}/${composer_file}": + ensure => present, + source => "${tmp_path}/composer.phar", + require => [ Exec['download_composer'], File[$target_dir] ], + mode => 0755, + } + + if $suhosin_enabled { + case $family { + + 'Redhat','Centos': { + + # set /etc/php5/cli/php.ini/suhosin.executor.include.whitelist = phar + augeas { 'whitelist_phar': + context => '/files/etc/suhosin.ini/suhosin', + changes => 'set suhosin.executor.include.whitelist phar', + require => Package[$php_package], + } + + # set /etc/cli/php.ini/PHP/allow_url_fopen = On + augeas{ 'allow_url_fopen': + context => '/files/etc/php.ini/PHP', + changes => 'set allow_url_fopen On', + require => Package[$php_package], + } + + } + 'Debian': { + + # set /etc/php5/cli/php.ini/suhosin.executor.include.whitelist = phar + augeas { 'whitelist_phar': + context => '/files/etc/php5/conf.d/suhosin.ini/suhosin', + changes => 'set suhosin.executor.include.whitelist phar', + require => Package[$php_package], + } + + # set /etc/php5/cli/php.ini/PHP/allow_url_fopen = On + augeas{ 'allow_url_fopen': + context => '/files/etc/php5/cli/php.ini/PHP', + changes => 'set allow_url_fopen On', + require => Package[$php_package], + } + + } + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/params.pp new file mode 100644 index 0000000000..54f752a43f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/params.pp @@ -0,0 +1,53 @@ +# == Class: composer::params +# +# The parameters for the composer class and corresponding definitions +# +# === Authors +# +# Thomas Ploch +# Andrew Johnstone +# +# === Copyright +# +# Copyright 2013 Thomas Ploch +# +class composer::params { + $composer_home = $::composer_home + + # Support Amazon Linux which is supported by RedHat family + if $::osfamily == 'Linux' and $::operatingsystem == 'Amazon' { + $family = 'RedHat' + } else { + $family = $::osfamily + } + + case $family { + 'Debian': { + $target_dir = '/usr/local/bin' + $composer_file = 'composer' + $download_method = 'curl' + $logoutput = false + $tmp_path = '/tmp' + $php_package = 'php5-cli' + $curl_package = 'curl' + $wget_package = 'wget' + $php_bin = 'php' + $suhosin_enabled = true + } + 'RedHat', 'Centos': { + $target_dir = '/usr/local/bin' + $composer_file = 'composer' + $download_method = 'curl' + $logoutput = false + $tmp_path = '/tmp' + $php_package = 'php-cli' + $curl_package = 'curl' + $wget_package = 'wget' + $php_bin = 'php' + $suhosin_enabled = true + } + default: { + fail("Unsupported platform: ${family}") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/project.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/project.pp new file mode 100644 index 0000000000..594f67f1ba --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/manifests/project.pp @@ -0,0 +1,96 @@ +# == Type: composer::project +# +# Installs a given project with composer create-project +# +# === Parameters +# +# Document parameters here. +# +# [*target_dir*] +# The target dir that composer should be installed to. +# Defaults to ```/usr/local/bin```. +# +# [*composer_file*] +# The name of the composer binary, which will reside in ```target_dir```. +# +# [*download_method*] +# Either ```curl``` or ```wget```. +# +# [*logoutput*] +# If the output should be logged. Defaults to FALSE. +# +# [*tmp_path*] +# Where the composer.phar file should be temporarily put. +# +# [*php_package*] +# The Package name of the PHP CLI package. +# +# [*user*] +# The user name to exec the composer commands as. Default is undefined. +# +# === Authors +# +# Thomas Ploch +# +# === Copyright +# +# Copyright 2013 Thomas Ploch +# +define composer::project( + $project_name, + $target_dir, + $version = undef, + $dev = false, + $prefer_source = false, + $stability = 'dev', + $repository_url = undef, + $keep_vcs = false, + $tries = 3, + $timeout = 1200, + $user = undef, +) { + require git + require composer + + Exec { + path => "/bin:/usr/bin/:/sbin:/usr/sbin:${composer::target_dir}", + environment => "COMPOSER_HOME=${composer::composer_home}", + user => $user, + } + + $exec_name = "composer_create_project_${title}" + $base_command = "${composer::php_bin} ${composer::target_dir}/${composer::composer_file} --stability=${stability}" + $end_command = "${project_name} ${target_dir}" + + $dev_arg = $dev ? { + true => ' --dev', + default => '', + } + + $vcs = $keep_vcs? { + true => ' --keep-vcs', + default => '', + } + + $repo = $repository_url? { + undef => '', + default => " --repository-url=${repository_url}", + } + + $pref_src = $prefer_source? { + true => ' --prefer-source', + false => '' + } + + $v = $version? { + undef => '', + default => " ${version}", + } + + exec { $exec_name: + command => "${base_command}${dev_arg}${repo}${pref_src}${vcs} create-project ${end_command}${v}", + tries => $tries, + timeout => $timeout, + creates => $target_dir, + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/classes/composer_params_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/classes/composer_params_spec.rb new file mode 100644 index 0000000000..914de7111f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/classes/composer_params_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe 'composer::params' do + ['RedHat', 'Debian', 'Linux'].each do |osfamily| + context "on #{osfamily} operating system family" do + let(:facts) { { + :osfamily => osfamily, + :operatingsystem => 'Amazon', + } } + + it { should compile } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/classes/composer_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/classes/composer_spec.rb new file mode 100644 index 0000000000..a34e335e7a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/classes/composer_spec.rb @@ -0,0 +1,116 @@ +require 'spec_helper' + +describe 'composer' do + ['RedHat', 'Debian', 'Linux'].each do |osfamily| + case osfamily + when 'RedHat' + php_package = 'php-cli' + php_context = '/files/etc/php.ini/PHP' + suhosin_context = '/files/etc/suhosin.ini/suhosin' + when 'Linux' + php_package = 'php-cli' + php_context = '/files/etc/php.ini/PHP' + suhosin_context = '/files/etc/suhosin.ini/suhosin' + when 'Debian' + php_package = 'php5-cli' + php_context = '/files/etc/php5/cli/php.ini/PHP' + suhosin_context = '/files/etc/php5/conf.d/suhosin.ini/suhosin' + else + php_package = 'php-cli' + php_context = '/files/etc/php.ini/PHP' + suhosin_context = '/files/etc/suhosin.ini/suhosin' + end + + context "on #{osfamily} operating system family" do + let(:facts) { { + :osfamily => osfamily, + :operatingsystem => 'Amazon' + } } + + it { should contain_class('composer::params') } + + it { + should contain_exec('download_composer').with({ + :command => 'curl -s http://getcomposer.org/installer | php', + :cwd => '/tmp', + :creates => '/tmp/composer.phar', + :logoutput => false, + }) + } + + it { + should contain_augeas('whitelist_phar').with({ + :context => suhosin_context, + :changes => 'set suhosin.executor.include.whitelist phar', + }) + } + + it { + should contain_augeas('allow_url_fopen').with({ + :context => php_context, + :changes => 'set allow_url_fopen On', + }) + } + + context 'with default parameters' do + it 'should compile' do + compile + end + + it { should contain_package(php_package).with_ensure('present') } + it { should contain_package('curl').with_ensure('present') } + it { should contain_file('/usr/local/bin').with_ensure('directory') } + + it { + should contain_file('/usr/local/bin/composer').with({ + :source => 'present', + :source => '/tmp/composer.phar', + :mode => '0755', + }) + } + end + + context "on invalid operating system family" do + let(:facts) { { + :osfamily => 'Invalid', + :operatingsystem => 'Amazon' + } } + + it 'should not compile' do + expect { should compile }.to raise_error(/Unsupported platform: Invalid/) + end + end + + context 'with custom parameters' do + let(:params) { { + :target_dir => '/you_sir/lowcal/been', + :php_package => 'php8-cli', + :composer_file => 'compozah', + :curl_package => 'kerl', + :php_bin => 'pehpe', + :suhosin_enabled => false, + } } + + it 'should compile' do + compile + end + + it { should contain_package('php8-cli').with_ensure('present') } + it { should contain_package('kerl').with_ensure('present') } + it { should contain_file('/you_sir/lowcal/been').with_ensure('directory') } + + it { + should contain_file('/you_sir/lowcal/been/compozah').with({ + :source => 'present', + :source => '/tmp/composer.phar', + :mode => '0755', + }) + } + + it { should_not contain_augeas('whitelist_phar') } + it { should_not contain_augeas('allow_url_fopen') } + + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/defines/composer_exec_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/defines/composer_exec_spec.rb new file mode 100644 index 0000000000..36a062f406 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/defines/composer_exec_spec.rb @@ -0,0 +1,65 @@ +require 'spec_helper' + +describe 'composer::exec' do + ['RedHat', 'Debian'].each do |osfamily| + context "on #{osfamily} operating system family" do + let(:facts) { { + :osfamily => osfamily, + } } + + context 'using install command' do + it { should contain_class('git') } + it { should contain_class('composer') } + + let(:title) { 'myproject' } + let(:params) { { + :cmd => 'install', + :cwd => '/my/awesome/project', + :user => 'linus', + } } + + it { + should contain_exec('composer_update_myproject').with({ + :command => %r{php /usr/local/bin/composer install --no-plugins --no-scripts --no-interaction}, + :cwd => '/my/awesome/project', + :user => 'linus', + :logoutput => false, + }) + } + end + + context 'using update command' do + it { should contain_class('git') } + it { should contain_class('composer') } + + let(:title) { 'yourpr0ject' } + let(:params) { { + :cmd => 'update', + :cwd => '/just/in/time', + :packages => ['package1', 'packageinf'], + :logoutput => true, + } } + + it { + should contain_exec('composer_update_yourpr0ject').without_user.with({ + :command => %r{php /usr/local/bin/composer update --no-plugins --no-scripts --no-interaction package1 packageinf}, + :cwd => '/just/in/time', + :logoutput => true, + }) + } + end + end + end + + context 'on unsupported operating system family' do + let(:facts) { { + :osfamily => 'Darwin', + } } + + let(:title) { 'someproject' } + + it 'should not compile' do + expect { should compile }.to raise_error(/Unsupported platform: Darwin/) + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/defines/composer_project_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/defines/composer_project_spec.rb new file mode 100644 index 0000000000..624f911156 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/defines/composer_project_spec.rb @@ -0,0 +1,61 @@ +require 'spec_helper' + +describe 'composer::project' do + ['RedHat', 'Debian'].each do |osfamily| + context "on #{osfamily} operating system family" do + let(:facts) { { + :osfamily => osfamily, + } } + + context 'with default params' do + let(:title) { 'myproject' } + let(:params) { { + :project_name => 'projectzzz', + :target_dir => '/my/subpar/project', + } } + + it { should contain_class('git') } + it { should contain_class('composer') } + + it { + should contain_exec('composer_create_project_myproject').without_user.with({ + :command => "php /usr/local/bin/composer --stability=dev create-project projectzzz /my/subpar/project", + :tries => 3, + :timeout => 1200, + :creates => '/my/subpar/project', + }) + } + end + + context 'with all custom params' do + let(:title) { 'whoadawg' } + let(:params) { { + :project_name => 'whoadawg99', + :target_dir => '/my/mediocre/project', + :version => '0.0.8', + :dev => true, + :prefer_source => true, + :stability => 'dev', + :repository_url => 'git@github.com:trollface/whoadawg.git', + :keep_vcs => true, + :tries => 2, + :timeout => 600, + :user => 'mrploch', + } } + + it { should contain_class('git') } + it { should contain_class('composer') } + + it { + should contain_exec('composer_create_project_whoadawg').with({ + :command => %r{php /usr/local/bin/composer --stability=dev --dev --repository-url=git@github.com:trollface/whoadawg.git --prefer-source --keep-vcs create-project whoadawg99 /my/mediocre/project 0.0.8}, + :tries => 2, + :timeout => 600, + :creates => '/my/mediocre/project', + :user => 'mrploch', + }) + } + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/fixtures/manifests/site.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/fixtures/manifests/site.pp new file mode 100644 index 0000000000..d669ee3889 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/fixtures/manifests/site.pp @@ -0,0 +1,8 @@ +node default { + include composer + + composer::exec {'ohai': + cmd => 'install', + cwd => '/some/cool/dir', + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/spec.opts b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/spec.opts new file mode 100644 index 0000000000..22420e39c6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/spec.opts @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace \ No newline at end of file diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/spec_helper.rb new file mode 100644 index 0000000000..2c6f56649a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/templates/exec.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/templates/exec.erb new file mode 100644 index 0000000000..960002f94c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/templates/exec.erb @@ -0,0 +1,17 @@ +<%= @command -%> +<% if @prefer_source %> --prefer-source<% end -%> +<% if @prefer_dist %> --prefer-dist<% end -%> +<% unless @custom_installers %> --no-plugins<% end -%> +<% unless @scripts %> --no-scripts<% end -%> +<% unless @interaction %> --no-interaction<% end -%> +<% if @dev %> --dev<% end -%> +<% if @verbose %> -v<% end -%> +<% if @dry_run %> --dry-run<% end -%> +<% if @cmd == 'update' -%> + <%- if @packages -%> + <%- @packages.each do |package| -%> + <%= ' ' + package -%> + <%- end -%> + <%- end -%> +<% end -%> + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/tests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/tests/init.pp new file mode 100644 index 0000000000..36afe85fa2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/tests/init.pp @@ -0,0 +1,11 @@ +# The baseline for module testing used by Puppet Labs is that each manifest +# should have a corresponding test manifest that declares that class or defined +# type. +# +# Tests are then run by using puppet apply --noop (to check for compilation errors +# and view a log of events) or by fully applying the test in a virtual environment +# (to compare the resulting system state to the desired state). +# +# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html +# +include composer diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/tests/project.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/tests/project.pp new file mode 100644 index 0000000000..6208a5eede --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/composer/tests/project.pp @@ -0,0 +1,23 @@ +# The baseline for module testing used by Puppet Labs is that each manifest +# should have a corresponding test manifest that declares that class or defined +# type. +# +# Tests are then run by using puppet apply --noop (to check for compilation errors +# and view a log of events) or by fully applying the test in a virtual environment +# (to compare the resulting system state to the desired state). +# +# Learn more about module testing here: http://docs.puppetlabs.com/guides/tests_smoke.html +# + +composer::project { 'my_first_test': + project_name => 'fabpot/silex-skeleton', + target_dir => '/tmp/first_test', +} + +composer::project { 'my_second_test': + project_name => 'fabpot/silex-skeleton', + target_dir => '/tmp/second_test', + prefer_source => true, + stability => 'dev', +} + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/.fixtures.yml new file mode 100644 index 0000000000..dc6b41f836 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/.fixtures.yml @@ -0,0 +1,7 @@ +fixtures: + repositories: + 'stdlib': + repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git' + ref: '4.0.0' + symlinks: + 'concat': '#{source_dir}' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/.gitattributes b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/.gitattributes new file mode 100644 index 0000000000..2e05fd47de --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/.gitattributes @@ -0,0 +1 @@ +*.sh eol=lf diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/.travis.yml new file mode 100644 index 0000000000..4e72cd4cf9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/.travis.yml @@ -0,0 +1,40 @@ +--- +branches: + only: + - master +language: ruby +bundler_args: --without development +script: bundle exec rake spec SPEC_OPTS='--format documentation' +# work around RubyGems 2.2.0 breaking ruby 1.8.7 +# https://github.com/rubygems/rubygems/pull/763 +# https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125 +before_install: + - gem update --system 2.1.11 + - gem --version +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 +env: + matrix: + - PUPPET_GEM_VERSION="2.7.3" FACTER_GEM_VERSION="1.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - PUPPET_GEM_VERSION="~> 3.0" +matrix: + fast_finish: true + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="2.7.3" FACTER_GEM_VERSION="1.6.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="2.7.3" FACTER_GEM_VERSION="1.6.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" +notifications: + email: false diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/CHANGELOG b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/CHANGELOG new file mode 100644 index 0000000000..c66b922d44 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/CHANGELOG @@ -0,0 +1,127 @@ +2014-05-14 1.1.0 + +Summary + +This release is primarily a bugfix release since 1.1.0-rc1. + +Features: +- Improved testing, with tests moved to beaker + +Bugfixes: +- No longer attempts to set fragment owner and mode on Windows +- Fix numeric sorting +- Fix incorrect quoting +- Fix newlines + +2014-01-03 1.1.0-rc1 + +Summary: + +This release of concat was 90% written by Joshua Hoblitt, and the module team +would like to thank him for the huge amount of work he put into this release. + +This module deprecates a bunch of old parameters and usage patterns, modernizes +much of the manifest code, simplifies a whole bunch of logic and makes +improvements to almost all parts of the module. + +The other major feature is windows support, courtesy of luisfdez, with an +alternative version of the concat bash script in ruby. We've attempted to +ensure that there are no backwards incompatible changes, all users of 1.0.0 +should be able to use 1.1.0 without any failures, but you may find deprecation +warnings and we'll be aggressively moving for a 2.0 to remove those too. + +For further information on deprecations, please read: +https://github.com/puppetlabs/puppetlabs-concat/blob/master/README.md#api-deprecations + +Removed: +- Puppet 0.24 support. +- Filebucket backup of all file resources except the target concatenated file. +- Default owner/user/group values. +- Purging of long unused /usr/local/bin/concatfragments.sh + +Features: +- Windows support via a ruby version of the concat bash script. +- Huge amount of acceptance testing work added. +- Documentation (README) completely rewritten. +- New parameters in concat: + - `ensure`: Controls if the file should be present/absent at all. +- Remove requirement to include concat::setup in manifests. +- Made `gnu` parameter deprecated. +- Added parameter validation. + +Bugfixes: +- Ensure concat::setup runs before concat::fragment in all cases. +- Pluginsync references updated for modern Puppet. +- Fix incorrect group parameter. +- Use $owner instead of $id to avoid confusion with $::id +- Compatibility fixes for Puppet 2.7/ruby 1.8.7 +- Use LC_ALL=C instead of LANG=C +- Always exec the concatfragments script as root when running as root. +- Syntax and other cleanup changes. + +2013-08-09 1.0.0 + +Summary: + +Many new features and bugfixes in this release, and if you're a heavy concat +user you should test carefully before upgrading. The features should all be +backwards compatible but only light testing has been done from our side before +this release. + +Features: +- New parameters in concat: + - `replace`: specify if concat should replace existing files. + - `ensure_newline`: controls if fragments should contain a newline at the end. +- Improved README documentation. +- Add rspec:system tests (rake spec:system to test concat) + +Bugfixes +- Gracefully handle \n in a fragment resource name. +- Adding more helpful message for 'pluginsync = true' +- Allow passing `source` and `content` directly to file resource, rather than +defining resource defaults. +- Added -r flag to read so that filenames with \ will be read correctly. +- sort always uses LANG=C. +- Allow WARNMSG to contain/start with '#'. +- Replace while-read pattern with for-do in order to support Solaris. + +CHANGELOG: +- 2010/02/19 - initial release +- 2010/03/12 - add support for 0.24.8 and newer + - make the location of sort configurable + - add the ability to add shell comment based warnings to + top of files + - add the ablity to create empty files +- 2010/04/05 - fix parsing of WARN and change code style to match rest + of the code + - Better and safer boolean handling for warn and force + - Don't use hard coded paths in the shell script, set PATH + top of the script + - Use file{} to copy the result and make all fragments owned + by root. This means we can chnage the ownership/group of the + resulting file at any time. + - You can specify ensure => "/some/other/file" in concat::fragment + to include the contents of a symlink into the final file. +- 2010/04/16 - Add more cleaning of the fragment name - removing / from the $name +- 2010/05/22 - Improve documentation and show the use of ensure => +- 2010/07/14 - Add support for setting the filebucket behavior of files +- 2010/10/04 - Make the warning message configurable +- 2010/12/03 - Add flags to make concat work better on Solaris - thanks Jonathan Boyett +- 2011/02/03 - Make the shell script more portable and add a config option for root group +- 2011/06/21 - Make base dir root readable only for security +- 2011/06/23 - Set base directory using a fact instead of hardcoding it +- 2011/06/23 - Support operating as non privileged user +- 2011/06/23 - Support dash instead of bash or sh +- 2011/07/11 - Better solaris support +- 2011/12/05 - Use fully qualified variables +- 2011/12/13 - Improve Nexenta support +- 2012/04/11 - Do not use any GNU specific extensions in the shell script +- 2012/03/24 - Comply to community style guides +- 2012/05/23 - Better errors when basedir isnt set +- 2012/05/31 - Add spec tests +- 2012/07/11 - Include concat::setup in concat improving UX +- 2012/08/14 - Puppet Lint improvements +- 2012/08/30 - The target path can be different from the $name +- 2012/08/30 - More Puppet Lint cleanup +- 2012/09/04 - RELEASE 0.2.0 +- 2012/12/12 - Added (file) $replace parameter to concat diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/Gemfile new file mode 100644 index 0000000000..56b977598c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/Gemfile @@ -0,0 +1,20 @@ +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +group :development, :test do + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false + gem 'puppet-lint', :require => false + gem 'serverspec', :require => false + gem 'pry', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/LICENSE new file mode 100644 index 0000000000..6a9e9a194b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/LICENSE @@ -0,0 +1,14 @@ + Copyright 2012 R.I.Pienaar + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/Modulefile new file mode 100644 index 0000000000..ea9ef2c3e3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/Modulefile @@ -0,0 +1,9 @@ +name 'puppetlabs-concat' +version '1.1.0' +source 'git://github.com/puppetlabs/puppetlabs-concat.git' +author 'Puppetlabs' +license 'Apache 2.0' +summary 'Concat module' +description 'Concat module' +project_page 'http://github.com/puppetlabs/puppetlabs-concat' +dependency 'puppetlabs/stdlib', '>= 4.0.0' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/README.md new file mode 100644 index 0000000000..60eca38300 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/README.md @@ -0,0 +1,441 @@ +#Concat + +[](https://travis-ci.org/puppetlabs/puppetlabs-concat) + +####Table of Contents + +1. [Overview](#overview) +2. [Module Description - What the module does and why it is useful](#module-description) +3. [Setup - The basics of getting started with concat](#setup) + * [What concat affects](#what-concat-affects) + * [Setup requirements](#setup-requirements) + * [Beginning with concat](#beginning-with-concat) +4. [Usage - Configuration options and additional functionality](#usage) + * [API _deprecations_](#api-deprecations) +5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) +5. [Limitations - OS compatibility, etc.](#limitations) +6. [Development - Guide for contributing to the module](#development) + +##Overview + +This module constructs files from multiple fragments in an ordered way. + +##Module Description + +This module lets you use many concat::fragment{} resources throughout +your modules to construct a single file at the end. It does this through +a shell (or ruby) script and a temporary holding space for the fragments. + +##Setup + +###What concat affects + +* Installs concatfragments.[sh|rb] based on platform. +* Adds a concat/ directory into Puppets `vardir`. + +###Beginning with concat + +To start using concat you need to create: + +* A concat{} resource for the final file. +* One or more concat::fragment{}'s. + +A minimal example might be: + +```puppet +concat { '/tmp/file': + ensure => present, +} + +concat::fragment { 'tmpfile': + target => '/tmp/file' + content => 'test contents', + order => '01' +} +``` + +##Usage + +Please be aware that there have been a number of [API +_deprecations_](#api-deprecations). + +If you wanted a /etc/motd file that listed all the major modules +on the machine. And that would be maintained automatically even +if you just remove the include lines for other modules you could +use code like below, a sample /etc/motd would be: + + +Puppet modules on this server: + + -- Apache + -- MySQL + + +Local sysadmins can also append to the file by just editing /etc/motd.local +their changes will be incorporated into the puppet managed motd. + +```puppet +class motd { + $motd = '/etc/motd' + + concat { $motd: + owner => 'root', + group => 'root', + mode => '0644' + } + + concat::fragment{ 'motd_header': + target => $motd, + content => "\nPuppet modules on this server:\n\n", + order => '01' + } + + # local users on the machine can append to motd by just creating + # /etc/motd.local + concat::fragment{ 'motd_local': + target => $motd, + source => '/etc/motd.local', + order => '15' + } +} + +# used by other modules to register themselves in the motd +define motd::register($content="", $order=10) { + if $content == "" { + $body = $name + } else { + $body = $content + } + + concat::fragment{ "motd_fragment_$name": + target => '/etc/motd', + order => $order, + content => " -- $body\n" + } +} +``` + +To use this you'd then do something like: + +```puppet +class apache { + include apache::install, apache::config, apache::service + + motd::register{ 'Apache': } +} +``` + +##Reference + +###Classes + +####Public classes + +####Private classes +* `concat::setup`: Sets up the concat script/directories. + +###Parameters + +###Defines + +####concat + +#####`ensure` +Controls if the combined file is present or absent. + +######Example +- ensure => present +- ensure => absent + +#####`path` +Controls the destination of the file to create. + +######Example +- path => '/tmp/filename' + +#####`owner` +Set the owner of the combined file. + +######Example +- owner => 'root' + +#####`group` +Set the group of the combined file. + +######Example +- group => 'root' + +#####`mode` +Set the mode of the combined file. + +######Example +- mode => '0644' + +#####`warn` +Determine if a warning message should be added at the top of the file to let +users know it was autogenerated by Puppet. + +######Example +- warn => true +- warn => false + +#####`warn_message` +Set the contents of the warning message. + +######Example +- warn_message => 'This file is autogenerated!' + +#####`force` +Determine if empty files are allowed when no fragments were added. + +######Example +- force => true +- force => false + +#####`backup` +Controls the filebucket behavior used for the file. + +######Example +- backup => 'puppet' + +#####`replace` +Controls if Puppet should replace the destination file if it already exists. + +######Example +- replace => true +- replace => false + +#####`order` +Controls the way in which the shell script chooses to sort the files. It's +rare you'll need to adjust this. + +######Allowed Values +- order => 'alpha' +- order => 'numeric' + +#####`ensure_newline` +Ensure there's a newline at the end of the fragments. + +######Example +- ensure_newline => true +- ensure_newline => false + +####concat::fragment + +#####`target` +Choose the destination file of the fragment. + +######Example +- target => '/tmp/testfile' + +#####`content` +Create the content of the fragment. + +######Example +- content => 'test file contents' + +#####`source` +Find the sources within Puppet of the fragment. + +######Example +- source => 'puppet:///modules/test/testfile' +- source => ['puppet:///modules/test/1', 'puppet:///modules/test/2'] + +#####`order` +Order the fragments. + +######Example +- order => '01' + +#####`ensure` +Control the file of fragment created. + +######Example +- ensure => 'present' +- ensure => 'absent' +- ensure => 'file' +- ensure => 'directory' + +#####`mode` +Set the mode of the fragment. + +######Example +- mode => '0644' + +#####`owner` +Set the owner of the fragment. + +######Example +- owner => 'root' + +#####`group` +Set the group of the fragment. + +######Example +- group => 'root' + +#####`backup` +Control the filebucket behavior for the fragment. + +######Example +- backup => 'puppet' + +### API _deprecations_ + +#### Since version `1.0.0` + +##### `concat{}` `warn` parameter + +```puppet +concat { '/tmp/file': + ensure => present, + warn => 'true', # generates stringified boolean value warning +} +``` + +Using stringified Boolean values as the `warn` parameter to `concat` is +deprecated, generates a catalog compile time warning, and will be silently +treated as the concatenated file header/warning message in a future release. + +The following strings are considered a stringified Boolean value: + + * `'true'` + * `'yes'` + * `'on'` + * `'false'` + * `'no'` + * `'off'` + +Please migrate to using the Puppet DSL's native [Boolean data +type](http://docs.puppetlabs.com/puppet/3/reference/lang_datatypes.html#booleans). + +##### `concat{}` `gnu` parameter + +```puppet +concat { '/tmp/file': + ensure => present, + gnu => $foo, # generates deprecation warning +} +``` + +The `gnu` parameter to `concat` is deprecated, generates a catalog compile time +warning, and has no effect. This parameter will be removed in a future +release. + +Note that this parameter was silently ignored in the `1.0.0` release. + +##### `concat::fragment{}` `ensure` parameter + +```puppet +concat::fragment { 'cpuinfo': + ensure => '/proc/cpuinfo', # generates deprecation warning + target => '/tmp/file', +} +``` + +Passing a value other than `'present'` or `'absent'` as the `ensure` parameter +to `concat::fragment` is deprecated and generates a catalog compile time +warning. The warning will become a catalog compilation failure in a future +release. + +This type emulates the Puppet core `file` type's disfavored [`ensure` +semantics](http://docs.puppetlabs.com/references/latest/type.html#file-attribute-ensure) +of treating a file path as a directive to create a symlink. This feature is +problematic in several ways. It copies an API semantic of another type that is +both frowned upon and not generally well known. It's behavior may be +surprising in that the target concatenated file will not be a symlink nor is +there any common file system that has a concept of a section of a plain file +being symbolically linked to another file. Additionally, the behavior is +generally inconsistent with most Puppet types in that a missing source file +will be silently ignored. + +If you want to use the content of a file as a fragment please use the `source` +parameter. + +##### `concat::fragment{}` `mode/owner/group` parameters + +```puppet +concat::fragment { 'foo': + target => '/tmp/file', + content => 'foo', + mode => $mode, # generates deprecation warning + owner => $owner, # generates deprecation warning + group => $group, # generates deprecation warning +} +``` + +The `mode` parameter to `concat::fragment` is deprecated, generates a catalog compile time warning, and has no effect. + +The `owner` parameter to `concat::fragment` is deprecated, generates a catalog +compile time warning, and has no effect. + +The `group` parameter to `concat::fragment` is deprecated, generates a catalog +compile time warning, and has no effect. + +These parameters had no user visible effect in version `1.0.0` and will be +removed in a future release. + +##### `concat::fragment{}` `backup` parameter + +```puppet +concat::fragment { 'foo': + target => '/tmp/file', + content => 'foo', + backup => 'bar', # generates deprecation warning +} +``` + +The `backup` parameter to `concat::fragment` is deprecated, generates a catalog +compile time warning, and has no effect. It will be removed in a future +release. + +In the `1.0.0` release this parameter controlled file bucketing of the file +fragment. Bucketting the fragment(s) is redundant with bucketting the final +concatenated file and this feature has been removed. + +##### `class { 'concat::setup': }` + +```puppet +include concat::setup # generates deprecation warning + +class { 'concat::setup: } # generates deprecation warning +``` + +The `concat::setup` class is deprecated as a public API of this module and +should no longer be directly included in the manifest. This class may be +removed in a future release. + +##### Parameter validation + +While not an API depreciation, users should be aware that all public parameters +in this module are now validated for at least variable type. This may cause +validation errors in a manifest that was previously silently misbehaving. + +##Limitations + +This module has been tested on: + +* RedHat Enterprise Linux (and Centos) 5/6 +* Debian 6/7 +* Ubuntu 12.04 + +Testing on other platforms has been light and cannot be guaranteed. + +#Development + +Puppet Labs modules on the Puppet Forge are open projects, and community +contributions are essential for keeping them great. We can’t access the +huge number of platforms and myriad of hardware, software, and deployment +configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our +modules work in your environment. There are a few guidelines that we need +contributors to follow so that we can have a chance of keeping on top of things. + +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) + +###Contributors + +The list of contributors can be found at: + +https://github.com/puppetlabs/puppetlabs-concat/graphs/contributors diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/Rakefile new file mode 100644 index 0000000000..23aea87de2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/Rakefile @@ -0,0 +1,5 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_quoted_booleans') diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/files/concatfragments.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/files/concatfragments.rb new file mode 100755 index 0000000000..73fd7f9b2d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/files/concatfragments.rb @@ -0,0 +1,137 @@ +# Script to concat files to a config file. +# +# Given a directory like this: +# /path/to/conf.d +# |-- fragments +# | |-- 00_named.conf +# | |-- 10_domain.net +# | `-- zz_footer +# +# The script supports a test option that will build the concat file to a temp location and +# use /usr/bin/cmp to verify if it should be run or not. This would result in the concat happening +# twice on each run but gives you the option to have an unless option in your execs to inhibit rebuilds. +# +# Without the test option and the unless combo your services that depend on the final file would end up +# restarting on each run, or in other manifest models some changes might get missed. +# +# OPTIONS: +# -o The file to create from the sources +# -d The directory where the fragments are kept +# -t Test to find out if a build is needed, basically concats the files to a temp +# location and compare with what's in the final location, return codes are designed +# for use with unless on an exec resource +# -w Add a shell style comment at the top of the created file to warn users that it +# is generated by puppet +# -f Enables the creation of empty output files when no fragments are found +# -n Sort the output numerically rather than the default alpha sort +# +# the command: +# +# concatfragments.rb -o /path/to/conffile.cfg -d /path/to/conf.d +# +# creates /path/to/conf.d/fragments.concat and copies the resulting +# file to /path/to/conffile.cfg. The files will be sorted alphabetically +# pass the -n switch to sort numerically. +# +# The script does error checking on the various dirs and files to make +# sure things don't fail. +require 'optparse' +require 'fileutils' + +settings = { + :outfile => "", + :workdir => "", + :test => false, + :force => false, + :warn => "", + :sortarg => "" +} + +OptionParser.new do |opts| + opts.banner = "Usage: #{$0} [options]" + opts.separator "Specific options:" + + opts.on("-o", "--outfile OUTFILE", String, "The file to create from the sources") do |o| + settings[:outfile] = o + end + + opts.on("-d", "--workdir WORKDIR", String, "The directory where the fragments are kept") do |d| + settings[:workdir] = d + end + + opts.on("-t", "--test", "Test to find out if a build is needed") do + settings[:test] = true + end + + opts.separator "Other options:" + opts.on("-w", "--warn WARNMSG", String, + "Add a shell style comment at the top of the created file to warn users that it is generated by puppet") do |w| + settings[:warn] = w + end + + opts.on("-f", "--force", "Enables the creation of empty output files when no fragments are found") do + settings[:force] = true + end + + opts.on("-n", "--sort", "Sort the output numerically rather than the default alpha sort") do + settings[:sortarg] = "-n" + end +end.parse! + +# do we have -o? +raise 'Please specify an output file with -o' unless !settings[:outfile].empty? + +# do we have -d? +raise 'Please specify fragments directory with -d' unless !settings[:workdir].empty? + +# can we write to -o? +if File.file?(settings[:outfile]) + if !File.writable?(settings[:outfile]) + raise "Cannot write to #{settings[:outfile]}" + end +else + if !File.writable?(File.dirname(settings[:outfile])) + raise "Cannot write to dirname #{File.dirname(settings[:outfile])} to create #{settings[:outfile]}" + end +end + +# do we have a fragments subdir inside the work dir? +if !File.directory?(File.join(settings[:workdir], "fragments")) && !File.executable?(File.join(settings[:workdir], "fragments")) + raise "Cannot access the fragments directory" +end + +# are there actually any fragments? +if (Dir.entries(File.join(settings[:workdir], "fragments")) - %w{ . .. }).empty? + if !settings[:force] + raise "The fragments directory is empty, cowardly refusing to make empty config files" + end +end + +Dir.chdir(settings[:workdir]) + +if settings[:warn].empty? + File.open("fragments.concat", 'w') {|f| f.write("") } +else + File.open("fragments.concat", 'w') {|f| f.write("#{settings[:warn]}\n") } +end + +# find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir +open('fragments.concat', 'a') do |f| + Dir.entries("fragments").sort.each{ |entry| + if File.file?(File.join("fragments", entry)) + f << File.read(File.join("fragments", entry)) + end + } +end + +if !settings[:test] + # This is a real run, copy the file to outfile + FileUtils.cp 'fragments.concat', settings[:outfile] +else + # Just compare the result to outfile to help the exec decide + if FileUtils.cmp 'fragments.concat', settings[:outfile] + exit 0 + else + exit 1 + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/files/concatfragments.sh b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/files/concatfragments.sh new file mode 100755 index 0000000000..7e6b0f5c56 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/files/concatfragments.sh @@ -0,0 +1,140 @@ +#!/bin/sh + +# Script to concat files to a config file. +# +# Given a directory like this: +# /path/to/conf.d +# |-- fragments +# | |-- 00_named.conf +# | |-- 10_domain.net +# | `-- zz_footer +# +# The script supports a test option that will build the concat file to a temp location and +# use /usr/bin/cmp to verify if it should be run or not. This would result in the concat happening +# twice on each run but gives you the option to have an unless option in your execs to inhibit rebuilds. +# +# Without the test option and the unless combo your services that depend on the final file would end up +# restarting on each run, or in other manifest models some changes might get missed. +# +# OPTIONS: +# -o The file to create from the sources +# -d The directory where the fragments are kept +# -t Test to find out if a build is needed, basically concats the files to a temp +# location and compare with what's in the final location, return codes are designed +# for use with unless on an exec resource +# -w Add a shell style comment at the top of the created file to warn users that it +# is generated by puppet +# -f Enables the creation of empty output files when no fragments are found +# -n Sort the output numerically rather than the default alpha sort +# +# the command: +# +# concatfragments.sh -o /path/to/conffile.cfg -d /path/to/conf.d +# +# creates /path/to/conf.d/fragments.concat and copies the resulting +# file to /path/to/conffile.cfg. The files will be sorted alphabetically +# pass the -n switch to sort numerically. +# +# The script does error checking on the various dirs and files to make +# sure things don't fail. + +OUTFILE="" +WORKDIR="" +TEST="" +FORCE="" +WARN="" +SORTARG="" +ENSURE_NEWLINE="" + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +## Well, if there's ever a bad way to do things, Nexenta has it. +## http://nexenta.org/projects/site/wiki/Personalities +unset SUN_PERSONALITY + +while getopts "o:s:d:tnw:fl" options; do + case $options in + o ) OUTFILE=$OPTARG;; + d ) WORKDIR=$OPTARG;; + n ) SORTARG="-n";; + w ) WARNMSG="$OPTARG";; + f ) FORCE="true";; + t ) TEST="true";; + l ) ENSURE_NEWLINE="true";; + * ) echo "Specify output file with -o and fragments directory with -d" + exit 1;; + esac +done + +# do we have -o? +if [ "x${OUTFILE}" = "x" ]; then + echo "Please specify an output file with -o" + exit 1 +fi + +# do we have -d? +if [ "x${WORKDIR}" = "x" ]; then + echo "Please fragments directory with -d" + exit 1 +fi + +# can we write to -o? +if [ -f "${OUTFILE}" ]; then + if [ ! -w "${OUTFILE}" ]; then + echo "Cannot write to ${OUTFILE}" + exit 1 + fi +else + if [ ! -w `dirname "${OUTFILE}"` ]; then + echo "Cannot write to `dirname \"${OUTFILE}\"` to create ${OUTFILE}" + exit 1 + fi +fi + +# do we have a fragments subdir inside the work dir? +if [ ! -d "${WORKDIR}/fragments" ] && [ ! -x "${WORKDIR}/fragments" ]; then + echo "Cannot access the fragments directory" + exit 1 +fi + +# are there actually any fragments? +if [ ! "$(ls -A """${WORKDIR}/fragments""")" ]; then + if [ "x${FORCE}" = "x" ]; then + echo "The fragments directory is empty, cowardly refusing to make empty config files" + exit 1 + fi +fi + +cd "${WORKDIR}" + +if [ "x${WARNMSG}" = "x" ]; then + : > "fragments.concat" +else + printf '%s\n' "$WARNMSG" > "fragments.concat" +fi + +# find all the files in the fragments directory, sort them numerically and concat to fragments.concat in the working dir +IFS_BACKUP=$IFS +IFS=' +' +for fragfile in `find fragments/ -type f -follow -print0 | xargs -0 -n1 basename | LC_ALL=C sort ${SORTARG}` +do + cat "fragments/$fragfile" >> "fragments.concat" + # Handle newlines. + if [ "x${ENSURE_NEWLINE}" != "x" ]; then + echo >> "fragments.concat" + fi +done +IFS=$IFS_BACKUP + +if [ "x${TEST}" = "x" ]; then + # This is a real run, copy the file to outfile + cp fragments.concat "${OUTFILE}" + RETVAL=$? +else + # Just compare the result to outfile to help the exec decide + cmp "${OUTFILE}" fragments.concat + RETVAL=$? +fi + +exit $RETVAL diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/lib/facter/concat_basedir.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/lib/facter/concat_basedir.rb new file mode 100644 index 0000000000..bfac07102d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/lib/facter/concat_basedir.rb @@ -0,0 +1,11 @@ +# == Fact: concat_basedir +# +# A custom fact that sets the default location for fragments +# +# "${::vardir}/concat/" +# +Facter.add("concat_basedir") do + setcode do + File.join(Puppet[:vardir],"concat") + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/manifests/fragment.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/manifests/fragment.pp new file mode 100644 index 0000000000..40baadd234 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/manifests/fragment.pp @@ -0,0 +1,121 @@ +# == Define: concat::fragment +# +# Puts a file fragment into a directory previous setup using concat +# +# === Options: +# +# [*target*] +# The file that these fragments belong to +# [*content*] +# If present puts the content into the file +# [*source*] +# If content was not specified, use the source +# [*order*] +# By default all files gets a 10_ prefix in the directory you can set it to +# anything else using this to influence the order of the content in the file +# [*ensure*] +# Present/Absent or destination to a file to include another file +# [*mode*] +# Deprecated +# [*owner*] +# Deprecated +# [*group*] +# Deprecated +# [*backup*] +# Deprecated +# +define concat::fragment( + $target, + $content = undef, + $source = undef, + $order = 10, + $ensure = undef, + $mode = undef, + $owner = undef, + $group = undef, + $backup = undef +) { + validate_string($target) + validate_string($content) + if !(is_string($source) or is_array($source)) { + fail('$source is not a string or an Array.') + } + validate_string($order) + if $mode { + warning('The $mode parameter to concat::fragment is deprecated and has no effect') + } + if $owner { + warning('The $owner parameter to concat::fragment is deprecated and has no effect') + } + if $group { + warning('The $group parameter to concat::fragment is deprecated and has no effect') + } + if $backup { + warning('The $backup parameter to concat::fragment is deprecated and has no effect') + } + if $ensure == undef { + $_ensure = getparam(Concat[$target], 'ensure') + } else { + if ! ($ensure in [ 'present', 'absent' ]) { + warning('Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.') + } + $_ensure = $ensure + } + + include concat::setup + + $safe_name = regsubst($name, '[/:\n]', '_', 'GM') + $safe_target_name = regsubst($target, '[/:\n]', '_', 'GM') + $concatdir = $concat::setup::concatdir + $fragdir = "${concatdir}/${safe_target_name}" + $fragowner = $concat::setup::fragment_owner + $fragmode = $concat::setup::fragment_mode + + # The file type's semantics are problematic in that ensure => present will + # not over write a pre-existing symlink. We are attempting to provide + # backwards compatiblity with previous concat::fragment versions that + # supported the file type's ensure => /target syntax + + # be paranoid and only allow the fragment's file resource's ensure param to + # be file, absent, or a file target + $safe_ensure = $_ensure ? { + '' => 'file', + undef => 'file', + 'file' => 'file', + 'present' => 'file', + 'absent' => 'absent', + default => $_ensure, + } + + # if it looks line ensure => /target syntax was used, fish that out + if ! ($_ensure in ['', 'present', 'absent', 'file' ]) { + $ensure_target = $_ensure + } else { + $ensure_target = undef + } + + # the file type's semantics only allows one of: ensure => /target, content, + # or source + if ($ensure_target and $source) or + ($ensure_target and $content) or + ($source and $content) { + fail('You cannot specify more than one of $content, $source, $ensure => /target') + } + + if ! ($content or $source or $ensure_target) { + crit('No content, source or symlink specified') + } + + # punt on group ownership until some point in the distant future when $::gid + # can be relied on to be present + file { "${fragdir}/fragments/${order}_${safe_name}": + ensure => $safe_ensure, + owner => $fragowner, + mode => $fragmode, + source => $source, + content => $content, + backup => false, + alias => "concat_fragment_${name}", + notify => Exec["concat_${target}"] + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/manifests/init.pp new file mode 100644 index 0000000000..91d82ebd3e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/manifests/init.pp @@ -0,0 +1,232 @@ +# == Define: concat +# +# Sets up so that you can use fragments to build a final config file, +# +# === Options: +# +# [*ensure*] +# Present/Absent +# [*path*] +# The path to the final file. Use this in case you want to differentiate +# between the name of a resource and the file path. Note: Use the name you +# provided in the target of your fragments. +# [*owner*] +# Who will own the file +# [*group*] +# Who will own the file +# [*mode*] +# The mode of the final file +# [*force*] +# Enables creating empty files if no fragments are present +# [*warn*] +# Adds a normal shell style comment top of the file indicating that it is +# built by puppet +# [*force*] +# [*backup*] +# Controls the filebucketing behavior of the final file and see File type +# reference for its use. Defaults to 'puppet' +# [*replace*] +# Whether to replace a file that already exists on the local system +# [*order*] +# [*ensure_newline*] +# [*gnu*] +# Deprecated +# +# === Actions: +# * Creates fragment directories if it didn't exist already +# * Executes the concatfragments.sh script to build the final file, this +# script will create directory/fragments.concat. Execution happens only +# when: +# * The directory changes +# * fragments.concat != final destination, this means rebuilds will happen +# whenever someone changes or deletes the final file. Checking is done +# using /usr/bin/cmp. +# * The Exec gets notified by something else - like the concat::fragment +# define +# * Copies the file over to the final destination using a file resource +# +# === Aliases: +# +# * The exec can notified using Exec["concat_/path/to/file"] or +# Exec["concat_/path/to/directory"] +# * The final file can be referenced as File["/path/to/file"] or +# File["concat_/path/to/file"] +# +define concat( + $ensure = 'present', + $path = $name, + $owner = undef, + $group = undef, + $mode = '0644', + $warn = false, + $force = false, + $backup = 'puppet', + $replace = true, + $order = 'alpha', + $ensure_newline = false, + $gnu = undef +) { + validate_re($ensure, '^present$|^absent$') + validate_absolute_path($path) + validate_string($owner) + validate_string($group) + validate_string($mode) + if ! (is_string($warn) or $warn == true or $warn == false) { + fail('$warn is not a string or boolean') + } + validate_bool($force) + validate_string($backup) + validate_bool($replace) + validate_re($order, '^alpha$|^numeric$') + validate_bool($ensure_newline) + if $gnu { + warning('The $gnu parameter to concat is deprecated and has no effect') + } + + include concat::setup + + $safe_name = regsubst($name, '[/:]', '_', 'G') + $concatdir = $concat::setup::concatdir + $fragdir = "${concatdir}/${safe_name}" + $concat_name = 'fragments.concat.out' + $script_command = $concat::setup::script_command + $default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.' + $bool_warn_message = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release' + + case $warn { + true: { + $warn_message = $default_warn_message + } + 'true', 'yes', 'on': { + warning($bool_warn_message) + $warn_message = $default_warn_message + } + false: { + $warn_message = '' + } + 'false', 'no', 'off': { + warning($bool_warn_message) + $warn_message = '' + } + default: { + $warn_message = $warn + } + } + + $warnmsg_escaped = regsubst($warn_message, '\'', '\'\\\'\'', 'G') + $warnflag = $warnmsg_escaped ? { + '' => '', + default => "-w '${warnmsg_escaped}'" + } + + $forceflag = $force ? { + true => '-f', + false => '', + } + + $orderflag = $order ? { + 'numeric' => '-n', + 'alpha' => '', + } + + $newlineflag = $ensure_newline ? { + true => '-l', + false => '', + } + + File { + backup => false, + } + + if $ensure == 'present' { + file { $fragdir: + ensure => directory, + mode => '0750', + } + + file { "${fragdir}/fragments": + ensure => directory, + mode => '0750', + force => true, + ignore => ['.svn', '.git', '.gitignore'], + notify => Exec["concat_${name}"], + purge => true, + recurse => true, + } + + file { "${fragdir}/fragments.concat": + ensure => present, + mode => '0640', + } + + file { "${fragdir}/${concat_name}": + ensure => present, + mode => '0640', + } + + file { $name: + ensure => present, + owner => $owner, + group => $group, + mode => $mode, + replace => $replace, + path => $path, + alias => "concat_${name}", + source => "${fragdir}/${concat_name}", + backup => $backup, + } + + # remove extra whitespace from string interpolation to make testing easier + $command = strip(regsubst("${script_command} -o \"${fragdir}/${concat_name}\" -d \"${fragdir}\" ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G')) + + # if puppet is running as root, this exec should also run as root to allow + # the concatfragments.sh script to potentially be installed in path that + # may not be accessible by a target non-root owner. + exec { "concat_${name}": + alias => "concat_${fragdir}", + command => $command, + notify => File[$name], + subscribe => File[$fragdir], + unless => "${command} -t", + path => $::path, + require => [ + File[$fragdir], + File["${fragdir}/fragments"], + File["${fragdir}/fragments.concat"], + ], + } + } else { + file { [ + $fragdir, + "${fragdir}/fragments", + "${fragdir}/fragments.concat", + "${fragdir}/${concat_name}" + ]: + ensure => absent, + force => true, + } + + file { $path: + ensure => absent, + backup => $backup, + } + + $absent_exec_command = $::kernel ? { + 'windows' => 'cmd.exe /c exit 0', + default => 'true', + } + + $absent_exec_path = $::kernel ? { + 'windows' => $::path, + default => '/bin:/usr/bin', + } + + exec { "concat_${name}": + alias => "concat_${fragdir}", + command => $absent_exec_command, + path => $absent_exec_path + } + } +} + +# vim:sw=2:ts=2:expandtab:textwidth=79 diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/manifests/setup.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/manifests/setup.pp new file mode 100644 index 0000000000..17674003ce --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/manifests/setup.pp @@ -0,0 +1,58 @@ +# === Class: concat::setup +# +# Sets up the concat system. This is a private class. +# +# [$concatdir] +# is where the fragments live and is set on the fact concat_basedir. +# Since puppet should always manage files in $concatdir and they should +# not be deleted ever, /tmp is not an option. +# +# It also copies out the concatfragments.sh file to ${concatdir}/bin +# +class concat::setup { + if $caller_module_name != $module_name { + warning("${name} is deprecated as a public API of the ${module_name} module and should no longer be directly included in the manifest.") + } + + if $::concat_basedir { + $concatdir = $::concat_basedir + } else { + fail ('$concat_basedir not defined. Try running again with pluginsync=true on the [master] and/or [main] section of your node\'s \'/etc/puppet/puppet.conf\'.') + } + + # owner and mode of fragment files (on windows owner and access rights should be inherited from concatdir and not explicitly set to avoid problems) + $fragment_owner = $osfamily ? { 'windows' => undef, default => $::id } + $fragment_mode = $osfamily ? { 'windows' => undef, default => '0640' } + + $script_name = $::kernel ? { + 'windows' => 'concatfragments.rb', + default => 'concatfragments.sh' + } + + $script_path = "${concatdir}/bin/${script_name}" + + $script_owner = $osfamily ? { 'windows' => undef, default => $::id } + + $script_mode = $osfamily ? { 'windows' => undef, default => '0755' } + + $script_command = $::kernel ? { + 'windows' => "ruby.exe ${script_path}", + default => $script_path + } + + File { + backup => false, + } + + file { $script_path: + ensure => file, + owner => $script_owner, + mode => $script_mode, + source => "puppet:///modules/concat/${script_name}", + } + + file { [ $concatdir, "${concatdir}/bin" ]: + ensure => directory, + mode => '0755', + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/backup_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/backup_spec.rb new file mode 100644 index 0000000000..7b2858d8e9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/backup_spec.rb @@ -0,0 +1,101 @@ +require 'spec_helper_acceptance' + +describe 'concat backup parameter' do + context '=> puppet' do + before :all do + shell('rm -rf /tmp/concat') + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'old contents' > /tmp/concat/file") + end + + pp = <<-EOS + concat { '/tmp/concat/file': + backup => 'puppet', + } + concat::fragment { 'new file': + target => '/tmp/concat/file', + content => 'new contents', + } + EOS + + it 'applies the manifest twice with "Filebucketed" stdout and no stderr' do + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stderr).to eq("") + expect(r.stdout).to match(/Filebucketed \/tmp\/concat\/file to puppet with sum 0140c31db86293a1a1e080ce9b91305f/) # sum is for file contents of 'old contents' + end + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new contents' } + end + end + + context '=> .backup' do + before :all do + shell('rm -rf /tmp/concat') + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'old contents' > /tmp/concat/file") + end + + pp = <<-EOS + concat { '/tmp/concat/file': + backup => '.backup', + } + concat::fragment { 'new file': + target => '/tmp/concat/file', + content => 'new contents', + } + EOS + + # XXX Puppet doesn't mention anything about filebucketing with a given + # extension like .backup + it 'applies the manifest twice no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new contents' } + end + describe file('/tmp/concat/file.backup') do + it { should be_file } + it { should contain 'old contents' } + end + end + + # XXX The backup parameter uses validate_string() and thus can't be the + # boolean false value, but the string 'false' has the same effect in Puppet 3 + context "=> 'false'" do + before :all do + shell('rm -rf /tmp/concat') + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'old contents' > /tmp/concat/file") + end + + pp = <<-EOS + concat { '/tmp/concat/file': + backup => '.backup', + } + concat::fragment { 'new file': + target => '/tmp/concat/file', + content => 'new contents', + } + EOS + + it 'applies the manifest twice with no "Filebucketed" stdout and no stderr' do + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stderr).to eq("") + expect(r.stdout).to_not match(/Filebucketed/) + end + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new contents' } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/concat_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/concat_spec.rb new file mode 100644 index 0000000000..89919cc53b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/concat_spec.rb @@ -0,0 +1,204 @@ +require 'spec_helper_acceptance' + +describe 'basic concat test' do + + shared_examples 'successfully_applied' do |pp| + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file("#{default['puppetvardir']}/concat") do + it { should be_directory } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 755 } + end + describe file("#{default['puppetvardir']}/concat/bin") do + it { should be_directory } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 755 } + end + describe file("#{default['puppetvardir']}/concat/bin/concatfragments.sh") do + it { should be_file } + it { should be_owned_by 'root' } + #it { should be_grouped_into 'root' } + it { should be_mode 755 } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file") do + it { should be_directory } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 750 } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments") do + it { should be_directory } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 750 } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat") do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments.concat.out") do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + end + end + + context 'owner/group root' do + pp = <<-EOS + concat { '/tmp/concat/file': + owner => 'root', + group => 'root', + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + EOS + + it_behaves_like 'successfully_applied', pp + + describe file('/tmp/concat/file') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 644 } + it { should contain '1' } + it { should contain '2' } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + end + end + + context 'owner/group non-root' do + before(:all) do + shell "groupadd -g 64444 bob" + shell "useradd -u 42 -g 64444 bob" + end + after(:all) do + shell "userdel bob" + end + + pp=" + concat { '/tmp/concat/file': + owner => 'bob', + group => 'bob', + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + " + + it_behaves_like 'successfully_applied', pp + + describe file('/tmp/concat/file') do + it { should be_file } + it { should be_owned_by 'bob' } + it { should be_grouped_into 'bob' } + it { should be_mode 644 } + it { should contain '1' } + it { should contain '2' } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/01_1") do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + it { should contain '1' } + end + describe file("#{default['puppetvardir']}/concat/_tmp_concat_file/fragments/02_2") do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + it { should be_mode 640 } + it { should contain '2' } + end + end + + context 'ensure' do + context 'works when set to present with path set' do + pp=" + concat { 'file': + ensure => present, + path => '/tmp/concat/file', + mode => '0644', + } + concat::fragment { '1': + target => 'file', + content => '1', + order => '01', + } + " + + it_behaves_like 'successfully_applied', pp + + describe file('/tmp/concat/file') do + it { should be_file } + it { should be_mode 644 } + it { should contain '1' } + end + end + context 'works when set to absent with path set' do + pp=" + concat { 'file': + ensure => absent, + path => '/tmp/concat/file', + mode => '0644', + } + concat::fragment { '1': + target => 'file', + content => '1', + order => '01', + } + " + + # Can't used shared examples as this will always trigger the exec when + # absent is set. + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should_not be_file } + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/deprecation_warnings_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/deprecation_warnings_spec.rb new file mode 100644 index 0000000000..f139d818c6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/deprecation_warnings_spec.rb @@ -0,0 +1,230 @@ +require 'spec_helper_acceptance' + +describe 'deprecation warnings' do + + shared_examples 'has_warning'do |pp, w| + it 'applies the manifest twice with a stderr regex' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/#{Regexp.escape(w)}/m) + expect(apply_manifest(pp, :catch_changes => true).stderr).to match(/#{Regexp.escape(w)}/m) + end + end + + context 'concat gnu parameter' do + pp = <<-EOS + concat { '/tmp/concat/file': + gnu => 'foo', + } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'bar', + } + EOS + w = 'The $gnu parameter to concat is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'concat warn parameter =>' do + ['true', 'yes', 'on'].each do |warn| + context warn do + pp = <<-EOS + concat { '/tmp/concat/file': + warn => '#{warn}', + } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'bar', + } + EOS + w = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release' + + it_behaves_like 'has_warning', pp, w + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain 'bar' } + end + end + end + + ['false', 'no', 'off'].each do |warn| + context warn do + pp = <<-EOS + concat { '/tmp/concat/file': + warn => '#{warn}', + } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'bar', + } + EOS + w = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release' + + it_behaves_like 'has_warning', pp, w + + describe file('/tmp/concat/file') do + it { should be_file } + it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain 'bar' } + end + end + end + end + + context 'concat::fragment ensure parameter' do + context 'target file exists' do + before(:all) do + shell("/bin/echo 'file1 contents' > /tmp/concat/file1") + end + after(:all) do + # XXX this test may leave behind a symlink in the fragment directory + # which could cause warnings and/or breakage from the subsequent tests + # unless we clean it up. + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + ensure => '/tmp/concat/file1', + } + EOS + w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.' + + it_behaves_like 'has_warning', pp, w + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'file1 contents' } + end + + describe 'the fragment can be changed from a symlink to a plain file' do + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'new content', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new content' } + it { should_not contain 'file1 contents' } + end + end + end # target file exists + + context 'target does not exist' do + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + ensure => '/tmp/concat/file1', + } + EOS + w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated. If you want to use the content of a file as a fragment please use the $source parameter.' + + it_behaves_like 'has_warning', pp, w + + describe file('/tmp/concat/file') do + it { should be_file } + end + + describe 'the fragment can be changed from a symlink to a plain file' do + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'new content', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'new content' } + end + end + end # target file exists + + end # concat::fragment ensure parameter + + context 'concat::fragment mode parameter' do + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'bar', + mode => 'bar', + } + EOS + w = 'The $mode parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'concat::fragment owner parameter' do + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'bar', + owner => 'bar', + } + EOS + w = 'The $owner parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'concat::fragment group parameter' do + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'bar', + group => 'bar', + } + EOS + w = 'The $group parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'concat::fragment backup parameter' do + pp = <<-EOS + concat { '/tmp/concat/file': } + concat::fragment { 'foo': + target => '/tmp/concat/file', + content => 'bar', + backup => 'bar', + } + EOS + w = 'The $backup parameter to concat::fragment is deprecated and has no effect' + + it_behaves_like 'has_warning', pp, w + end + + context 'include concat::setup' do + pp = <<-EOS + include concat::setup + EOS + w = 'concat::setup is deprecated as a public API of the concat module and should no longer be directly included in the manifest.' + + it_behaves_like 'has_warning', pp, w + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/empty_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/empty_spec.rb new file mode 100644 index 0000000000..09995282a3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/empty_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper_acceptance' + +describe 'concat force empty parameter' do + context 'should run successfully' do + pp = <<-EOS + concat { '/tmp/concat/file': + owner => root, + group => root, + mode => '0644', + force => true, + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should_not contain '1\n2' } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/fragment_source_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/fragment_source_spec.rb new file mode 100644 index 0000000000..3afd53430d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/fragment_source_spec.rb @@ -0,0 +1,134 @@ +require 'spec_helper_acceptance' + +describe 'concat::fragment source' do + context 'should read file fragments from local system' do + before(:all) do + shell("/bin/echo 'file1 contents' > /tmp/concat/file1") + shell("/bin/echo 'file2 contents' > /tmp/concat/file2") + end + + pp = <<-EOS + concat { '/tmp/concat/foo': } + + concat::fragment { '1': + target => '/tmp/concat/foo', + source => '/tmp/concat/file1', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string1 contents', + } + concat::fragment { '3': + target => '/tmp/concat/foo', + source => '/tmp/concat/file2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain 'file1 contents' } + it { should contain 'string1 contents' } + it { should contain 'file2 contents' } + end + end # should read file fragments from local system + + context 'should create files containing first match only.' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + shell("/bin/echo 'file1 contents' > /tmp/concat/file1") + shell("/bin/echo 'file2 contents' > /tmp/concat/file2") + end + + pp = <<-EOS + concat { '/tmp/concat/result_file1': + owner => root, + group => root, + mode => '0644', + } + concat { '/tmp/concat/result_file2': + owner => root, + group => root, + mode => '0644', + } + concat { '/tmp/concat/result_file3': + owner => root, + group => root, + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/concat/result_file1', + source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], + order => '01', + } + concat::fragment { '2': + target => '/tmp/concat/result_file2', + source => [ '/tmp/concat/file2', '/tmp/concat/file1' ], + order => '01', + } + concat::fragment { '3': + target => '/tmp/concat/result_file3', + source => [ '/tmp/concat/file1', '/tmp/concat/file2' ], + order => '01', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + describe file('/tmp/concat/result_file1') do + it { should be_file } + it { should contain 'file1 contents' } + it { should_not contain 'file2 contents' } + end + describe file('/tmp/concat/result_file2') do + it { should be_file } + it { should contain 'file2 contents' } + it { should_not contain 'file1 contents' } + end + describe file('/tmp/concat/result_file3') do + it { should be_file } + it { should contain 'file1 contents' } + it { should_not contain 'file2 contents' } + end + end + + context 'should fail if no match on source.' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + shell('/bin/rm -rf /tmp/concat/fail_no_source /tmp/concat/nofilehere /tmp/concat/nothereeither') + end + + pp = <<-EOS + concat { '/tmp/concat/fail_no_source': + owner => root, + group => root, + mode => '0644', + } + + concat::fragment { '1': + target => '/tmp/concat/fail_no_source', + source => [ '/tmp/concat/nofilehere', '/tmp/concat/nothereeither' ], + order => '01', + } + EOS + + it 'applies the manifest with resource failures' do + apply_manifest(pp, :expect_failures => true) + end + describe file('/tmp/concat/fail_no_source') do + #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack. + it { should_not be_file } + it { should_not be_directory } + end + end +end + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/newline_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/newline_spec.rb new file mode 100644 index 0000000000..1e989df2ab --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/newline_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper_acceptance' + +describe 'concat ensure_newline parameter' do + context '=> false' do + pp = <<-EOS + concat { '/tmp/concat/file': + ensure_newline => false, + } + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '12' } + end + end + + context '=> true' do + pp = <<-EOS + concat { '/tmp/concat/file': + ensure_newline => true, + } + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + #XXX ensure_newline => true causes changes on every run because the files + #are modified in place. + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain "1\n2\n" } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/aix-71-vcloud.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/aix-71-vcloud.yml new file mode 100644 index 0000000000..f0ae87a5c8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/aix-71-vcloud.yml @@ -0,0 +1,19 @@ +HOSTS: + pe-aix-71-acceptance: + roles: + - master + - dashboard + - database + - agent + - default + platform: aix-7.1-power + hypervisor: aix + ip: pe-aix-71-acceptance.delivery.puppetlabs.net +CONFIG: + type: pe + nfs_server: NONE + consoleport: 443 + datastore: instance0 + folder: Delivery/Quality Assurance/Enterprise/Dynamic + resourcepool: delivery/Quality Assurance/Enterprise/Dynamic + pooling_api: http://vcloud.delivery.puppetlabs.net/ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/centos-59-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/centos-59-x64.yml new file mode 100644 index 0000000000..2ad90b86aa --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/centos-59-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-59-x64: + roles: + - master + platform: el-5-x86_64 + box : centos-59-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/centos-64-x64-pe.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/centos-64-x64-pe.yml new file mode 100644 index 0000000000..7d9242f1b9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/centos-64-x64-pe.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-64-x64: + roles: + - master + - database + - dashboard + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: pe diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/centos-64-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/centos-64-x64.yml new file mode 100644 index 0000000000..05540ed8c5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/centos-64-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/debian-607-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/debian-607-x64.yml new file mode 100644 index 0000000000..4c8be42d03 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/debian-607-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-607-x64: + roles: + - master + platform: debian-6-amd64 + box : debian-607-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/debian-70rc1-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/debian-70rc1-x64.yml new file mode 100644 index 0000000000..19181c123d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/debian-70rc1-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-70rc1-x64: + roles: + - master + platform: debian-7-amd64 + box : debian-70rc1-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/debian-73-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/debian-73-x64.yml new file mode 100644 index 0000000000..3e6a3a9ddd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/debian-73-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + debian-73-x64.localhost: + roles: + - master + platform: debian-7-amd64 + box : debian-73-x64-virtualbox-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + log_level: debug + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/default.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000000..ae812b0aef --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/default.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64.localdomain: + roles: + - master + platform: el-6-x86_64 + box : centos-65-x64-virtualbox-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/fedora-18-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/fedora-18-x64.yml new file mode 100644 index 0000000000..1361649830 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/fedora-18-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + fedora-18-x64: + roles: + - master + platform: fedora-18-x86_64 + box : fedora-18-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/sles-11-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/sles-11-x64.yml new file mode 100644 index 0000000000..41abe2135e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/sles-11-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + sles-11-x64.local: + roles: + - master + platform: sles-11-x64 + box : sles-11sp1-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/sles-11sp1-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/sles-11sp1-x64.yml new file mode 100644 index 0000000000..554c37a505 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/sles-11sp1-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + sles-11sp1-x64: + roles: + - master + platform: sles-11-x86_64 + box : sles-11sp1-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml new file mode 100644 index 0000000000..5ca1514e40 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-10044-x64: + roles: + - master + platform: ubuntu-10.04-amd64 + box : ubuntu-server-10044-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 0000000000..d065b304f8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-12.04-amd64 + box : ubuntu-server-12042-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 0000000000..cba1cd04c2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,11 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-amd64 + box : puppetlabs/ubuntu-14.04-64-nocm + box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm + hypervisor : vagrant +CONFIG: + log_level : debug + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/order_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/order_spec.rb new file mode 100644 index 0000000000..8bcb7131ce --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/order_spec.rb @@ -0,0 +1,137 @@ +require 'spec_helper_acceptance' + +describe 'concat order' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + end + + context '=> alpha' do + pp = <<-EOS + concat { '/tmp/concat/foo': + order => 'alpha' + } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + } + concat::fragment { '10': + target => '/tmp/concat/foo', + content => 'string10', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string10\nstring1\nsring2" } + end + end + + context '=> numeric' do + pp = <<-EOS + concat { '/tmp/concat/foo': + order => 'numeric' + } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + } + concat::fragment { '10': + target => '/tmp/concat/foo', + content => 'string10', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string1\nstring2\nsring10" } + end + end +end # concat order + +describe 'concat::fragment order' do + before(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + shell('mkdir -p /tmp/concat') + end + + context '=> reverse order' do + pp = <<-EOS + concat { '/tmp/concat/foo': } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + order => '15', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + # default order 10 + } + concat::fragment { '3': + target => '/tmp/concat/foo', + content => 'string3', + order => '1', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string3\nstring2\nsring1" } + end + end + + context '=> normal order' do + pp = <<-EOS + concat { '/tmp/concat/foo': } + concat::fragment { '1': + target => '/tmp/concat/foo', + content => 'string1', + order => '01', + } + concat::fragment { '2': + target => '/tmp/concat/foo', + content => 'string2', + order => '02' + } + concat::fragment { '3': + target => '/tmp/concat/foo', + content => 'string3', + order => '03', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/foo') do + it { should be_file } + it { should contain "string1\nstring2\nsring3" } + end + end +end # concat::fragment order diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/quoted_paths_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/quoted_paths_spec.rb new file mode 100644 index 0000000000..af352efce8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/quoted_paths_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper_acceptance' + +describe 'quoted paths' do + before(:all) do + shell('rm -rf "/tmp/concat test" /var/lib/puppet/concat') + shell('mkdir -p "/tmp/concat test"') + end + + context 'path with blanks' do + pp = <<-EOS + concat { '/tmp/concat test/foo': + } + concat::fragment { '1': + target => '/tmp/concat test/foo', + content => 'string1', + } + concat::fragment { '2': + target => '/tmp/concat test/foo', + content => 'string2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat test/foo') do + it { should be_file } + it { should contain "string1\nsring2" } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/replace_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/replace_spec.rb new file mode 100644 index 0000000000..7b31e09c44 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/replace_spec.rb @@ -0,0 +1,241 @@ +require 'spec_helper_acceptance' + +describe 'replacement of' do + context 'file' do + context 'should not succeed' do + before(:all) do + shell('mkdir -p /tmp/concat') + shell('echo "file exists" > /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + replace => false, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain 'file exists' } + it { should_not contain '1' } + it { should_not contain '2' } + end + end + + context 'should succeed' do + before(:all) do + shell('mkdir -p /tmp/concat') + shell('echo "file exists" > /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + replace => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should_not contain 'file exists' } + it { should contain '1' } + it { should contain '2' } + end + end + end # file + + context 'symlink' do + context 'should not succeed' do + # XXX the core puppet file type will replace a symlink with a plain file + # when using ensure => present and source => ... but it will not when using + # ensure => present and content => ...; this is somewhat confusing behavior + before(:all) do + shell('mkdir -p /tmp/concat') + shell('ln -s /tmp/concat/dangling /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + replace => false, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_linked_to '/tmp/concat/dangling' } + end + + describe file('/tmp/concat/dangling') do + # XXX serverspec does not have a matcher for 'exists' + it { should_not be_file } + it { should_not be_directory } + end + end + + context 'should succeed' do + # XXX the core puppet file type will replace a symlink with a plain file + # when using ensure => present and source => ... but it will not when using + # ensure => present and content => ...; this is somewhat confusing behavior + before(:all) do + shell('mkdir -p /tmp/concat') + shell('ln -s /tmp/concat/dangling /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + replace => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '1' } + it { should contain '2' } + end + end + end # symlink + + context 'directory' do + context 'should not succeed' do + before(:all) do + shell('mkdir -p /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with stderr for changing to file' do + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/change from directory to file failed/) + end + + describe file('/tmp/concat/file') do + it { should be_directory } + end + end + + # XXX concat's force param currently enables the creation of empty files + # when there are no fragments, and the replace param will only replace + # files and symlinks, not directories. The semantics either need to be + # changed, extended, or a new param introduced to control directory + # replacement. + context 'should succeed', :pending => 'not yet implemented' do + before(:all) do + shell('mkdir -p /tmp/concat/file') + end + after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + pp = <<-EOS + concat { '/tmp/concat/file': + force => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '1' } + end + end + end # directory +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/symbolic_name_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/symbolic_name_spec.rb new file mode 100644 index 0000000000..7267f5e6b4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/symbolic_name_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper_acceptance' + +describe 'symbolic name' do + pp = <<-EOS + concat { 'not_abs_path': + path => '/tmp/concat/file', + } + + concat::fragment { '1': + target => 'not_abs_path', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => 'not_abs_path', + content => '2', + order => '02', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '1' } + it { should contain '2' } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/warn_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/warn_spec.rb new file mode 100644 index 0000000000..cb0b7430dc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/acceptance/warn_spec.rb @@ -0,0 +1,97 @@ +require 'spec_helper_acceptance' + +describe 'concat warn =>' do + context 'true should enable default warning message' do + pp = <<-EOS + concat { '/tmp/concat/file': + warn => true, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain '1' } + it { should contain '2' } + end + end + context 'false should not enable default warning message' do + pp = <<-EOS + concat { '/tmp/concat/file': + warn => false, + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should_not contain '# This file is managed by Puppet. DO NOT EDIT.' } + it { should contain '1' } + it { should contain '2' } + end + end + context '# foo should overide default warning message' do + pp = <<-EOS + concat { '/tmp/concat/file': + warn => '# foo', + } + + concat::fragment { '1': + target => '/tmp/concat/file', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => '/tmp/concat/file', + content => '2', + order => '02', + } + EOS + + it 'applies the manifest twice with no stderr' do + expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("") + expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("") + end + + describe file('/tmp/concat/file') do + it { should be_file } + it { should contain '# foo' } + it { should contain '1' } + it { should contain '2' } + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/spec_helper.rb new file mode 100644 index 0000000000..2c6f56649a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/spec_helper_acceptance.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000000..22bd72f06a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/spec_helper_acceptance.rb @@ -0,0 +1,39 @@ +require 'beaker-rspec/spec_helper' +require 'beaker-rspec/helpers/serverspec' + +unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' + if hosts.first.is_pe? + install_pe + else + install_puppet + end + hosts.each do |host| + on hosts, "mkdir -p #{host['distmoduledir']}" + end +end + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + puppet_module_install(:source => proj_root, :module_name => 'concat') + hosts.each do |host| + on host, puppet('module','install','puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + end + end + + c.before(:all) do + shell('mkdir -p /tmp/concat') + end + c.after(:all) do + shell('rm -rf /tmp/concat /var/lib/puppet/concat') + end + + c.treat_symbols_as_metadata_keys_with_true_values = true +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/classes/concat_setup_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/classes/concat_setup_spec.rb new file mode 100644 index 0000000000..bba455ab91 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/classes/concat_setup_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +describe 'concat::setup', :type => :class do + + shared_examples 'setup' do |concatdir| + concatdir = '/foo' if concatdir.nil? + + let(:facts) {{ :concat_basedir => concatdir }} + + it do + should contain_file("#{concatdir}/bin/concatfragments.sh").with({ + :mode => '0755', + :source => 'puppet:///modules/concat/concatfragments.sh', + :backup => false, + }) + end + + [concatdir, "#{concatdir}/bin"].each do |file| + it do + should contain_file(file).with({ + :ensure => 'directory', + :mode => '0755', + :backup => false, + }) + end + end + end + + context 'facts' do + context 'concat_basedir =>' do + context '/foo' do + it_behaves_like 'setup', '/foo' + end + end + end # facts + + context 'deprecated as a public class' do + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/defines/concat_fragment_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/defines/concat_fragment_spec.rb new file mode 100644 index 0000000000..3b5269e8d5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/defines/concat_fragment_spec.rb @@ -0,0 +1,267 @@ +require 'spec_helper' + +describe 'concat::fragment', :type => :define do + + shared_examples 'fragment' do |title, params| + params = {} if params.nil? + + p = { + :content => nil, + :source => nil, + :order => 10, + :ensure => 'present', + }.merge(params) + + safe_name = title.gsub(/[\/\n]/, '_') + safe_target_name = p[:target].gsub(/[\/\n]/, '_') + concatdir = '/var/lib/puppet/concat' + fragdir = "#{concatdir}/#{safe_target_name}" + id = 'root' + if p[:ensure] == 'absent' + safe_ensure = p[:ensure] + else + safe_ensure = 'file' + end + + let(:title) { title } + let(:facts) {{ :concat_basedir => concatdir, :id => id }} + let(:params) { params } + let(:pre_condition) do + "concat{ '#{p[:target]}': }" + end + + it do + should contain_class('concat::setup') + should contain_concat(p[:target]) + should contain_file("#{fragdir}/fragments/#{p[:order]}_#{safe_name}").with({ + :ensure => safe_ensure, + :owner => id, + :mode => '0640', + :source => p[:source], + :content => p[:content], + :alias => "concat_fragment_#{title}", + :backup => false, + }) + end + end + + context 'title' do + ['0', '1', 'a', 'z'].each do |title| + it_behaves_like 'fragment', title, { + :target => '/etc/motd', + } + end + end # title + + context 'target =>' do + ['./etc/motd', 'etc/motd', 'motd_header'].each do |target| + context target do + it_behaves_like 'fragment', target, { + :target => '/etc/motd', + } + end + end + + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) {{ :target => false }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # target => + + context 'ensure =>' do + ['present', 'absent'].each do |ens| + context ens do + it_behaves_like 'fragment', 'motd_header', { + :ensure => ens, + :target => '/etc/motd', + } + end + end + + context 'any value other than \'present\' or \'absent\'' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) {{ :ensure => 'invalid', :target => '/etc/motd' }} + + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end + end # ensure => + + context 'content =>' do + ['', 'ashp is our hero'].each do |content| + context content do + it_behaves_like 'fragment', 'motd_header', { + :content => content, + :target => '/etc/motd', + } + end + end + + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) {{ :content => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # content => + + context 'source =>' do + ['', '/foo/bar', ['/foo/bar', '/foo/baz']].each do |source| + context source do + it_behaves_like 'fragment', 'motd_header', { + :source => source, + :target => '/etc/motd', + } + end + end + + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) {{ :source => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string or an Array/) + end + end + end # source => + + context 'order =>' do + ['', '42', 'a', 'z'].each do |order| + context '\'\'' do + it_behaves_like 'fragment', 'motd_header', { + :order => order, + :target => '/etc/motd', + } + end + end + + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) {{ :order => false, :target => '/etc/motd' }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # order => + + context 'more than one content source' do + error_msg = 'You cannot specify more than one of $content, $source, $ensure => /target' + + context 'ensure => target and source' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) do + { + :target => '/etc/motd', + :ensure => '/foo', + :source => '/bar', + } + end + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) + end + end + + context 'ensure => target and content' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) do + { + :target => '/etc/motd', + :ensure => '/foo', + :content => 'bar', + } + end + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) + end + end + + context 'source and content' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) do + { + :target => '/etc/motd', + :source => '/foo', + :content => 'bar', + } + end + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape(error_msg)}/m) + end + end + + end # more than one content source + + describe 'deprecated parameter' do + context 'mode =>' do + context '1755' do + it_behaves_like 'fragment', 'motd_header', { + :mode => '1755', + :target => '/etc/motd', + } + + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end + end # mode => + + context 'owner =>' do + context 'apenny' do + it_behaves_like 'fragment', 'motd_header', { + :owner => 'apenny', + :target => '/etc/motd', + } + + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end + end # owner => + + context 'group =>' do + context 'apenny' do + it_behaves_like 'fragment', 'motd_header', { + :group => 'apenny', + :target => '/etc/motd', + } + + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end + end # group => + + context 'backup =>' do + context 'foo' do + it_behaves_like 'fragment', 'motd_header', { + :backup => 'foo', + :target => '/etc/motd', + } + + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end + end # backup => + end # deprecated params + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/defines/concat_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/defines/concat_spec.rb new file mode 100644 index 0000000000..9fdd7b26f1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/defines/concat_spec.rb @@ -0,0 +1,380 @@ +require 'spec_helper' + +describe 'concat', :type => :define do + + shared_examples 'concat' do |title, params, id| + params = {} if params.nil? + id = 'root' if id.nil? + + # default param values + p = { + :ensure => 'present', + :path => title, + :owner => nil, + :group => nil, + :mode => '0644', + :warn => false, + :force => false, + :backup => 'puppet', + :replace => true, + :order => 'alpha', + :ensure_newline => false, + }.merge(params) + + safe_name = title.gsub('/', '_') + concatdir = '/var/lib/puppet/concat' + fragdir = "#{concatdir}/#{safe_name}" + concat_name = 'fragments.concat.out' + default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.' + + file_defaults = { + :backup => false, + } + + let(:title) { title } + let(:params) { params } + let(:facts) {{ :concat_basedir => concatdir, :id => id }} + + if p[:ensure] == 'present' + it do + should contain_file(fragdir).with(file_defaults.merge({ + :ensure => 'directory', + :mode => '0750', + })) + end + + it do + should contain_file("#{fragdir}/fragments").with(file_defaults.merge({ + :ensure => 'directory', + :mode => '0750', + :force => true, + :ignore => ['.svn', '.git', '.gitignore'], + :purge => true, + :recurse => true, + })) + end + + [ + "#{fragdir}/fragments.concat", + "#{fragdir}/#{concat_name}", + ].each do |file| + it do + should contain_file(file).with(file_defaults.merge({ + :ensure => 'present', + :mode => '0640', + })) + end + end + + it do + should contain_file(title).with(file_defaults.merge({ + :ensure => 'present', + :owner => p[:owner], + :group => p[:group], + :mode => p[:mode], + :replace => p[:replace], + :path => p[:path], + :alias => "concat_#{title}", + :source => "#{fragdir}/#{concat_name}", + :backup => p[:backup], + })) + end + + cmd = "#{concatdir}/bin/concatfragments.sh " + + "-o \"#{concatdir}/#{safe_name}/fragments.concat.out\" " + + "-d \"#{concatdir}/#{safe_name}\"" + + # flag order: fragdir, warnflag, forceflag, orderflag, newlineflag + if p.has_key?(:warn) + case p[:warn] + when TrueClass + message = default_warn_message + when 'true', 'yes', 'on' + # should generate a stringified boolean warning + message = default_warn_message + when FalseClass + message = nil + when 'false', 'no', 'off' + # should generate a stringified boolean warning + message = nil + else + message = p[:warn] + end + + unless message.nil? + cmd += " -w \'#{message}\'" + end + end + + cmd += " -f" if p[:force] + cmd += " -n" if p[:order] == 'numeric' + cmd += " -l" if p[:ensure_newline] == true + + it do + should contain_exec("concat_#{title}").with({ + :alias => "concat_#{fragdir}", + :command => cmd, + :unless => "#{cmd} -t", + }) + end + else + [ + fragdir, + "#{fragdir}/fragments", + "#{fragdir}/fragments.concat", + "#{fragdir}/#{concat_name}", + ].each do |file| + it do + should contain_file(file).with(file_defaults.merge({ + :ensure => 'absent', + :backup => false, + :force => true, + })) + end + end + + it do + should contain_file(title).with(file_defaults.merge({ + :ensure => 'absent', + :backup => p[:backup], + })) + end + + it do + should contain_exec("concat_#{title}").with({ + :alias => "concat_#{fragdir}", + :command => 'true', + :path => '/bin:/usr/bin', + }) + end + end + end + + context 'title' do + context 'without path param' do + # title/name is the default value for the path param. therefore, the + # title must be an absolute path unless path is specified + ['/foo', '/foo/bar', '/foo/bar/baz'].each do |title| + context title do + it_behaves_like 'concat', '/etc/foo.bar' + end + end + + ['./foo', 'foo', 'foo/bar'].each do |title| + context title do + let(:title) { title } + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not an absolute path/) + end + end + end + end + + context 'with path param' do + ['./foo', 'foo', 'foo/bar'].each do |title| + context title do + it_behaves_like 'concat', title, { :path => '/etc/foo.bar' } + end + end + end + end # title => + + context 'as non-root user' do + it_behaves_like 'concat', '/etc/foo.bar', {}, 'bob' + end + + context 'ensure =>' do + ['present', 'absent'].each do |ens| + context ens do + it_behaves_like 'concat', '/etc/foo.bar', { :ensure => ens } + end + end + + context 'invalid' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :ensure => 'invalid' }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^present$|^absent$"')}/) + end + end + end # ensure => + + context 'path =>' do + context '/foo' do + it_behaves_like 'concat', '/etc/foo.bar', { :path => '/foo' } + end + + ['./foo', 'foo', 'foo/bar', false].each do |path| + context path do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :path => path }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not an absolute path/) + end + end + end + end # path => + + context 'owner =>' do + context 'apenney' do + it_behaves_like 'concat', '/etc/foo.bar', { :owner => 'apenny' } + end + + context 'false' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :owner => false }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # owner => + + context 'group =>' do + context 'apenney' do + it_behaves_like 'concat', '/etc/foo.bar', { :group => 'apenny' } + end + + context 'false' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :group => false }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # group => + + context 'mode =>' do + context '1755' do + it_behaves_like 'concat', '/etc/foo.bar', { :mode => '1755' } + end + + context 'false' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :mode => false }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # mode => + + context 'warn =>' do + [true, false, '# foo'].each do |warn| + context warn do + it_behaves_like 'concat', '/etc/foo.bar', { :warn => warn } + end + end + + context '(stringified boolean)' do + ['true', 'yes', 'on', 'false', 'no', 'off'].each do |warn| + context warn do + it_behaves_like 'concat', '/etc/foo.bar', { :warn => warn } + + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end + end + end + + context '123' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :warn => 123 }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string or boolean/) + end + end + end # warn => + + context 'force =>' do + [true, false].each do |force| + context force do + it_behaves_like 'concat', '/etc/foo.bar', { :force => force } + end + end + + context '123' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :force => 123 }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + end + end + end # force => + + context 'backup =>' do + context 'reverse' do + it_behaves_like 'concat', '/etc/foo.bar', { :backup => 'reverse' } + end + + context 'false' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :backup => false }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) + end + end + end # backup => + + context 'replace =>' do + [true, false].each do |replace| + context replace do + it_behaves_like 'concat', '/etc/foo.bar', { :replace => replace } + end + end + + context '123' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :replace => 123 }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + end + end + end # replace => + + context 'order =>' do + ['alpha', 'numeric'].each do |order| + context order do + it_behaves_like 'concat', '/etc/foo.bar', { :order => order } + end + end + + context 'invalid' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :order => 'invalid' }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /#{Regexp.escape('does not match "^alpha$|^numeric$"')}/) + end + end + end # order => + + context 'ensure_newline =>' do + [true, false].each do |ensure_newline| + context 'true' do + it_behaves_like 'concat', '/etc/foo.bar', { :ensure_newline => ensure_newline} + end + end + + context '123' do + let(:title) { '/etc/foo.bar' } + let(:params) {{ :ensure_newline => 123 }} + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a boolean/) + end + end + end # ensure_newline => + + describe 'deprecated parameter' do + context 'gnu =>' do + context 'foo' do + it_behaves_like 'concat', '/etc/foo.bar', { :gnu => 'foo'} + + it 'should create a warning' do + pending('rspec-puppet support for testing warning()') + end + end + end + end + +end + +# vim:sw=2:ts=2:expandtab:textwidth=79 diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/facts/concat_basedir_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/facts/concat_basedir_spec.rb new file mode 100644 index 0000000000..41bc90f159 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/spec/unit/facts/concat_basedir_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe 'concat_basedir', :type => :fact do + before(:each) { Facter.clear } + + context 'Puppet[:vardir] ==' do + it '/var/lib/puppet' do + Puppet.stubs(:[]).with(:vardir).returns('/var/lib/puppet') + Facter.fact(:concat_basedir).value.should == '/var/lib/puppet/concat' + end + + it '/home/apenny/.puppet/var' do + Puppet.stubs(:[]).with(:vardir).returns('/home/apenny/.puppet/var') + Facter.fact(:concat_basedir).value.should == '/home/apenny/.puppet/var/concat' + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/tests/fragment.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/tests/fragment.pp new file mode 100644 index 0000000000..a2dfaca290 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/tests/fragment.pp @@ -0,0 +1,19 @@ +concat { 'testconcat': + ensure => present, + path => '/tmp/concat', + owner => 'root', + group => 'root', + mode => '0664', +} + +concat::fragment { '1': + target => 'testconcat', + content => '1', + order => '01', +} + +concat::fragment { '2': + target => 'testconcat', + content => '2', + order => '02', +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/tests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/tests/init.pp new file mode 100644 index 0000000000..fd21427180 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/concat/tests/init.pp @@ -0,0 +1,7 @@ +concat { '/tmp/concat': + ensure => present, + force => true, + owner => 'root', + group => 'root', + mode => '0644', +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/Puppetfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/Puppetfile new file mode 100644 index 0000000000..42968dff1b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/Puppetfile @@ -0,0 +1,6 @@ +forge "http://forge.puppetlabs.com" + +mod 'php', :git => 'https://github.com/puphpet/puppet-php.git' +mod 'composer', :git => 'https://github.com/puphpet/puppet-composer.git' +mod 'puphpet', :git => 'https://github.com/puphpet/puppet-puphpet.git' +mod 'puppi', :git => 'https://github.com/puphpet/puppi.git' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/README b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/README new file mode 100644 index 0000000000..d546e570ab --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/README @@ -0,0 +1,226 @@ +DRUSH PUPPET MODULE +=================== + +This module manages Drush, a command line shell and scripting interface for +Drupal. + +It can install and upgrade Drush from Debian packages or source, as well as +download, enable and disable Drupal modules and themes, build codebases from +Drush makefiles, run arbitrary Drush commands and optionally log its output. + + +DEPENDENCIES +------------ + +None. + + +REQUIREMENTS +------------ + +The Drush Puppet module is designed to work on Debian GNU/Linux systems and +derivatives. It provides rudimentary support for apt-get, but defaults to +letting the OS's default packaging system handle installation. As such, it +should work with other *nix systems, assuming Drush is available for install +in the OS's packaging system, or Drush is installed from source using the +provided 'drush::git' class. + + +INSTALLATION +------------ + +To use this module, follow these directions: + +1. Your modules directory will need all the files included in this + repository placed under a directory called "drush". + +2. To install Drush, add one of these entries to your manifests (such as in + manifests/nodes.pp): + + include drush + + or + + class {'drush': + ensure => latest, + } + + The following parameters are available: + + api: The major version of Drush to install. Currently supports '4' or '5'. + dist: The Debian distribution from which to install via apt-get. Defaults + to 'stable'. Set to false to suppres adding custom sources for install + via apt-get. + ensure: What state the package should be in. Valid values are 'present' + (also called 'installed'), 'absent', 'purged', 'held', of 'latest'. + +2a. To install Drush from source, add one of these entries to your manifests: + + include drush::git::drush + + or + + class {'drush::git::drush': + git_branch => '8.x-6.x', + update => true, + } + + + The following parameters are available: + + git_branch: The git branch to track. + git_tag: The git tag to check out. + git_url: The git URL from which to clone the repository. + update: Whether to update to the latest code with each Puppet run. + Defaults to false. + + +USAGE +----- + +1. To run a Drush command, use the drush::run defined type like so: + + drush::run { '@dev uli --uid=42': } + + The following parameters are all optional: + + command: The command to run. Defaults to the name of the resource. + site_alias: The alias against which to run the command. + options: Options to pass to Drush. + arguments: Arguments to pass to the command. + site_path: The path to the site or code-base in which to run the command. + drush_user: The user under which to execute the command. + drush_home: Set the drush_user's home directory, for alias search paths. + log: Path to the logfile in which to log all Drush output. + creates, unless, onlyif, refreshonly: Control whether the command is + executed at each Puppet run. Identical to these paramaters on the + built-in 'exec' resource. + timeout: The maximum time the command should take, specified in seconds. + Defaults to 300 seconds. Disable the timeout by setting to 0. + paths: provide alternative paths to search for your Drush executable. + +2. To download projects from drupal.org to a site, add lines such as the + following to your manifests: + + drush::dl {'token': + site_path => '/var/aegir/platforms/drupal/sites/example.com', + log => '/var/aegir/drush.log', + } + + The following parameters are all optional: + + type: The type of package to download. Defaults to 'module'. + version: The version of the package to download. + site_path: Operates the same as for drush::run. Set this parameter to avoid + having a package downloaded repeatedly, as it will allow Puppet to see + whether it already exists. Alternatively, do not set this parameter to + have the package continuously updated. + site_alias, options, arguments, drush_user, drush_home, log: All operate + the same as for drush::run. + +3. To enable or disable projects on a Drupal site, add lines such as the following to your + manifests: + + drush::en {'token': + site_alias => '@www.example.com', + } + + drush::dis {'@prod devel, devel-generate':} + + The following parameters are all optional: + + site_alias, options, arguments, site_path, drush_user, drush_home, log: All + operate the same as for drush::run. + +4. To display the status of a site in your Puppet log, add lines such as the + following to your manifests: + + drush::dis {'@prod status': + options => '--full', + } + + The following parameters are all optional: + + site_alias, options, arguments, site_path, drush_user, drush_home, log: All + operate the same as for drush::run. + + +5. To build a Drupal code-base using Drush Make, add lines such as the following to your + manifests: + + drush::make {'/var/aegir/platform/Drupal7': + makefile => '/var/aegir/makefiles/drupal7.make', + } + + There is one required parameter: + + makefile: The path to the makefile to use in building the code-base. + + The following parameters are all optional: + + make_path: The path to build the code-base. Defaults to the name of the + resource. + options, drush_user, drush_home, log: All operate the same as for + drush::run. + + +6. The module also provides a simple way to clone git repos and keep them up- + to-date: + + drush::git { 'git://git.drupal.org:project/provision': + path => '/var/aegir/.drush', + } + + There is one required parameter: + + path: Where to clone the git repo. + + The following parameters are all optional: + + git_branch: The git branch to checkout. + git_tag: The git tag to check out. Overrides 'branch' if also specified. + git_repo: The git repository to clone. Defaults to the resource name. + dir_name: The name of the directory in which to clone the git repo. + update: Run 'git pull -r' in this repo on every Puppet run. + paths: Alternative search paths for your git binary. + + +DEVELOPING +---------- + +The drush::run defined type provides a basis on which to build pretty much any +Drush command imagineable. The other provided commands build upon it to provide +convenience resources for common use-cases. While quite simple, they should +form a good basis for creating your own custom defined types. + +For more complex examples, take a look at the puppet-aegir module, which +extends this API further in the context of the Aegir Hosting System. It can be +found at: + + https://drupal.org/project/puppet-aegir + +Along similar lines, Skynet takes this way too far: + + https://drupal.org/project/skynet + +The drush::git resource is a minimalist general-purpose function to allow +cloning and updating git repositories. It is not intended to be a full-featured +git class/resource. It will not attempt to install git for you either, but this +should be sufficient: + + package {'git':} + +This Puppet module is published under the GNU GPLv2 (General Public License, +Version 2), and as such is, and will always remain, Free Software. Engagement +in the development process by users and other developers is very much appreci- +ated. So, please feel free to post to the issue queue, submit bug reports and +feature requests, and ask questions about how to use or extend it. + + +------------------------------------------------------------------------------- +Current maintainers: Christopher Gervais (mailto:chris@praxis.coop) + Guillaume Boudrias (mailto:gboudrias@praxis.coop) +Original authors: Christopher Gervais (mailto:chris@koumbit.org) + Antoine Beaupré (mailto:anarcat@koumbit.org) +Copyright:: Copyright (c) 2011-2013 Réseau Koumbit Networks +License:: GPLv2 or later diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/apt.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/apt.pp new file mode 100644 index 0000000000..8d7ff58561 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/apt.pp @@ -0,0 +1,49 @@ +class drush::apt ( $dist = false, $backports = false) { + + if $backports { + file { "/etc/apt/preferences.d/drush-${backports}.pref": + ensure => 'present', + content => "Package: drush\nPin: release a=${backports}-backports\nPin-Priority: 1001\n", + owner => root, group => root, mode => '0644', + notify => Exec['drush_update_apt'], + } + file { "/etc/apt/sources.list.d/drush-${backports}-backports.list" : + ensure => 'present', + content => "deb http://backports.debian.org/debian-backports ${backports}-backports main", + owner => root, group => root, mode => '0644', + notify => Exec['drush_update_apt'], + } + } + else { + file { [ + "/etc/apt/preferences.d/drush-${backports}.pref", + "/etc/apt/sources.list.d/drush-${backports}-backports.list", + ]: + ensure => 'absent', + notify => Exec['drush_update_apt'], + } + } + + if $dist { + file { "/etc/apt/sources.list.d/drush-${dist}.list" : + ensure => 'present', + content => "deb http://ftp.debian.org/debian ${dist} main", + owner => root, group => root, mode => '0644', + notify => Exec['drush_update_apt'], + before => Exec['drush_apt_update'], + } + } + + exec { 'drush_update_apt': + command => 'apt-get update & sleep 1', + path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ], + refreshonly => true, + } + + exec { 'drush_apt_update': + command => 'apt-get update && /usr/bin/apt-get autoclean', + path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ], + schedule => daily, + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/dis.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/dis.pp new file mode 100644 index 0000000000..9cbf1bcaab --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/dis.pp @@ -0,0 +1,25 @@ +define drush::dis ( + $site_alias = $drush::params::site_alias, + $options = $drush::params::options, + $arguments = $drush::params::arguments, + $site_path = $drush::params::site_path, + $drush_user = $drush::params::drush_user, + $drush_home = $drush::params::drush_home, + $log = $drush::params::log + ) { + + if $arguments { $real_args = $arguments } + else { $real_args = $name } + + drush::run {"drush-dis:${name}": + command => 'pm-disable', + site_alias => $site_alias, + options => $options, + arguments => $real_args, + site_path => $site_path, + drush_user => $drush_user, + drush_home => $drush_home, + log => $log, + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/dl.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/dl.pp new file mode 100644 index 0000000000..89a9a29059 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/dl.pp @@ -0,0 +1,48 @@ +define drush::dl ( + $type = 'module', + $site_alias = $drush::params::site_alias, + $options = $drush::params::options, + $arguments = $drush::params::arguments, + $drush_user = $drush::params::drush_user, + $drush_home = $drush::params::drush_home, + $log = $drush::params::log + ) { + + if $arguments { $real_args = $arguments } + else { $real_args = "${name}" } + + # Always download drush extensions without a site alias. + if $type == 'extension' { $real_alias = '@none' } + else { $real_alias = "${site_alias}" } + + drush::run {"drush-dl:${name}": + command => 'pm-download', + site_alias => $real_alias, + options => $options, + arguments => $real_args, + drush_user => $drush_user, + drush_home => $drush_home, + log => $log, + } + + # Add an 'unless' argument depending on the project type. + case $type { + 'module', 'theme': { + Drush::Run["drush-dl:${name}"] { + unless => "drush ${site_alias} pm-list | grep ${name}", + } + } + 'extension': { + Drush::Run["drush-dl:${name}"] { + unless => "[ -d '${drush_home}/.drush/${name}' ]", + } + } + } + + if defined(Drush::Run["drush-en:${name}"]) { + Drush::Run["drush-dl:${name}"] { + before +> Exec["drush-en:${name}"], + } + } +} + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/en.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/en.pp new file mode 100644 index 0000000000..036074968f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/en.pp @@ -0,0 +1,26 @@ +define drush::en ( + $site_alias = $drush::params::site_alias, + $options = $drush::params::options, + $arguments = $drush::params::arguments, + $drush_user = $drush::params::drush_user, + $drush_home = $drush::params::drush_home, + $log = $drush::params::log, + $refreshonly = false + ) { + + if $arguments { $real_args = $arguments } + else { $real_args = $name } + + drush::run {"drush-en:${name}": + command => 'pm-enable', + site_alias => $site_alias, + options => $options, + arguments => $real_args, + drush_user => $drush_user, + drush_home => $drush_home, + refreshonly => $refreshonly, + log => $log, + unless => "drush ${site_alias} pm-list --status=enabled | grep ${name}", + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/git.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/git.pp new file mode 100644 index 0000000000..dc0598121b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/git.pp @@ -0,0 +1,60 @@ +define drush::git ( + $path, + $git_branch = '', + $git_tag = '', + $git_repo = false, + $dir_name = false, + $update = false, + $paths = $drush::params::paths, + $user = 'root', + ) { + + # Default to the resource name if no explicit git repo is provided. + if $git_repo { $real_git_repo = $git_repo } + else { $real_git_repo = $name } + + # Figure out the path and directory name. + if $dir_name { + $real_path = "${path}/${dir_name}" + $real_dir = $dir_name + } + else { + # Figure out the name of the cloned into directory from the git repo. + $repo_array = split($real_git_repo, '[/]') + $last_element = $repo_array[-1] + $real_dir = regsubst($last_element, '\.git$', '') + $real_path = "${path}/${real_dir}" + } + + exec {"drush-clone-repo:${name}": + command => "git clone ${real_git_repo} ${real_dir}", + creates => $real_path, + cwd => $path, + user => $user, + path => $paths, + timeout => 0, + } + + # The specific (tag) overrides the general (branch). + if $git_tag { $git_ref = $git_tag } + else { $git_ref = $git_branch } + + if $git_ref { + exec {"drush-checkout-ref:${name}": + command => "git checkout ${git_ref}", + cwd => $real_path, + path => $paths, + require => Exec["drush-clone-repo:${name}"], + } + } + + if $update { + exec {"drush-update-repo:${name}": + command => 'git pull -r', + cwd => $real_path, + path => $paths, + require => Exec["drush-clone-repo:${name}"], + } + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/git/drush.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/git/drush.pp new file mode 100644 index 0000000000..36680c63f4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/git/drush.pp @@ -0,0 +1,61 @@ +class drush::git::drush ( + $git_branch = '', + $git_tag = '', + $git_repo = 'https://github.com/drush-ops/drush.git', + $update = false + ) inherits drush::params { + + include php::params + + Exec { path => ['/bin', '/usr/bin', '/usr/local/bin', '/usr/share'], } + + if ! defined(Package['git']) { + package { 'git': + ensure => present, + before => Drush::Git[$git_repo] + } + } + + if ! defined(Class['composer']) { + class { 'composer': + target_dir => '/usr/local/bin', + composer_file => 'composer', + download_method => 'curl', + logoutput => false, + tmp_path => '/tmp', + php_package => "${php::params::module_prefix}cli", + curl_package => 'curl', + suhosin_enabled => false, + } + } + + drush::git { $git_repo : + path => '/usr/share', + git_branch => $git_branch, + git_tag => $git_tag, + update => $update, + } + + composer::exec { 'drush': + cmd => 'install', + cwd => '/usr/share/drush', + require => Drush::Git[$git_repo], + notify => File['symlink drush'], + } + + file { 'symlink drush': + ensure => link, + path => '/usr/bin/drush', + target => '/usr/share/drush/drush', + require => Composer::Exec['drush'], + notify => Exec['first drush run'], + } + + # Needed to download a Pear library + exec { 'first drush run': + command => 'drush cache-clear drush', + refreshonly => true, + require => File['symlink drush'], + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/init.pp new file mode 100644 index 0000000000..53325d537a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/init.pp @@ -0,0 +1,33 @@ +class drush ( + $api = $drush::params::api, + $dist = $drush::params::dist, + $ensure = $drush::params::ensure + ) inherits drush::params { + + include drush::params + + package { 'drush': + ensure => $ensure, + } + + case $operatingsystem { + /^(Debian|Ubuntu)$/: { + include drush::apt + Package['drush'] { require => Exec['drush_update_apt'] } + } + } + + if $dist { + + Package['drush'] { require => Class['drush::apt'] } + + if $api == 4 { $backports = 'squeeze' } + else { $backports = '' } + + class {'drush::apt': + dist => $dist, + backports => $backports, + } + } +} + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/make.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/make.pp new file mode 100644 index 0000000000..e09efdfbb5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/make.pp @@ -0,0 +1,26 @@ +define drush::make ( + $makefile, + $make_path = false, + $options = $drush::params::options, + $site_path = $drush::params::site_path, + $drush_user = $drush::params::drush_user, + $drush_home = $drush::params::drush_home, + $log = $drush::params::log + ) { + + if $make_path { $real_make_path = $make_path } + else { $real_make_path = $name } + $arguments = "${makefile} ${real_make_path}" + + drush::run {"drush-make:${name}": + command => 'make', + creates => $make_path, + options => $options, + arguments => $arguments, + drush_user => $drush_user, + drush_home => $drush_home, + log => $log, + timeout => 0, + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/params.pp new file mode 100644 index 0000000000..1af2e4ae7c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/params.pp @@ -0,0 +1,35 @@ +class drush::params { + + case $::operatingsystem { + 'centos', 'redhat': { + $php_cli_package = 'php-cli' + } + 'ubuntu', 'debian': { + $php_cli_package = 'php5-cli' + } + default: { + fail('The puppet-drush module only supports RHEL and Debian systems') + } + } + + $drush_user = 'root' + $drush_home = '/root' + $site_alias = '@none' + $options = '' + $arguments = '' + $api = 5 + $dist = false + $ensure = 'present' + $site_path = false + $log = false + $creates = false + $paths = [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ] + + if defined(Class['drush::git::drush']) { + $installed = Class['drush::git::drush'] + } + else { + $installed = Class['drush'] + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/run.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/run.pp new file mode 100644 index 0000000000..2b6c1d255e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/run.pp @@ -0,0 +1,57 @@ +define drush::run ( + $command = false, + $site_alias = $drush::params::site_alias, + $options = $drush::params::options, + $arguments = $drush::params::arguments, + $site_path = $drush::params::site_path, + $drush_user = $drush::params::drush_user, + $drush_home = $drush::params::drush_home, + $log = $drush::params::log, + $installed = $drush::params::installed, + $creates = $drush::params::creates, + $paths = $drush::params::paths, + $timeout = false, + $unless = false, + $onlyif = false, + $refreshonly = false + ) { + + if $log { $log_output = " >> ${log} 2>&1" } + + if $command { $real_command = $command } + else { $real_command = $name} + + exec {"drush-run:${name}": + command => "drush ${site_alias} --yes ${options} ${real_command} ${arguments} ${log_output}", + user => $drush_user, + group => $drush_user, + path => $paths, + environment => "HOME=${drush_home}", + require => $installed, + } + + if $site_path { + Exec["drush-run:${name}"] { cwd => $site_path } + } + + if $creates { + Exec["drush-run:${name}"] { creates => $creates } + } + + if $timeout { + Exec["drush-run:${name}"] { timeout => $timeout } + } + + if $unless { + Exec["drush-run:${name}"] { unless => $unless } + } + + if $onlyif { + Exec["drush-run:${name}"] { onlyif => $onlyif } + } + + if $refreshonly { + Exec["drush-run:${name}"] { refreshonly => $refreshonly } + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/status.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/status.pp new file mode 100644 index 0000000000..3f7784bd4b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/manifests/status.pp @@ -0,0 +1,22 @@ +define drush::status ( + $site_alias = $drush::params::site_alias, + $options = $drush::params::options, + $arguments = $drush::params::arguments, + $site_path = $drush::params::site_path, + $drush_user = $drush::params::drush_user, + $drush_home = $drush::params::drush_home, + $log = $drush::params::log + ) { + + drush::run {"drush-status:${name}": + command => 'core-status', + site_alias => $site_alias, + options => $options, + arguments => $arguments, + site_path => $site_path, + drush_user => $drush_user, + drush_home => $drush_home, + log => $log, + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/.module b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/.module new file mode 100644 index 0000000000..e430fc6c1d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/.module @@ -0,0 +1 @@ +drush diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/Vagrantfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/Vagrantfile new file mode 100644 index 0000000000..6bb52efe91 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/Vagrantfile @@ -0,0 +1,11 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant::Config.run do |config| + config.vm.box = "Debian 6.0.7 x64" + config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210.box" + + config.vm.provision :shell, + :path => "./tests/.ci/vagrant_test.sh" + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/test.sh b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/test.sh new file mode 100644 index 0000000000..55ab628039 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/test.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +echo "Creating test environment..." +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +if [ -e $SCRIPT_DIR/.module ] +then + MODULE=`cat $SCRIPT_DIR/.module` +else + echo "ERROR: The test script expects the name of the module to be in a file" + echo " called '.module', in the same directory as the test script." + echo $SCRIPT_DIR + exit 1 +fi +cd $SCRIPT_DIR +cd ../.. +if [ -e manifests/init.pp ] +then + MODULE_DIR=`pwd` +else + echo "ERROR: The test script expects to be in /tests/.ci/, but" + echo " cannot find the module's 'init.pp', from its current location." + echo $SCRIPT_DIR + exit 1 +fi +rm -rf /tmp/$MODULE +cp $MODULE_DIR /tmp/$MODULE -r +cd /tmp/$MODULE +wget http://ansi-color.googlecode.com/svn/tags/0.6/ansi-color/color >> /dev/null 2>&1 +mv ./color /usr/local/bin +chmod a+x /usr/local/bin/color + +echo "Scanning for tests in '$MODULE' module..." +FILES=`find /tmp/$MODULE/tests -name *.pp` +COUNT=${#FILES[@]} +PASSED=0 +FAILED=0 +TOTAL=0 + +echo "Running tests..." +for f in $FILES +do + NAME=`basename $f` + echo "Running '$NAME' test..." + OUTPUT=`puppet apply --noop --modulepath=/tmp/ --color=ansi $f 2>&1` + STATUS=$? + if [ $STATUS -ne 0 ] + then + color red + echo "///////////////////////////////////////////////////////" + echo + echo " ERROR in '$NAME' test." + echo " Output from failed test:" + echo + echo $OUTPUT + echo + echo "///////////////////////////////////////////////////////" + color off + let FAILED++ + let TOTAL++ + else + color green + echo "'$NAME' test passed." + color off + let PASSED++ + let TOTAL++ + fi +done + +echo "Total tests run: $TOTAL" +color green +echo "Tests passed: $PASSED" +color red +echo "Tests failed: $FAILED" +color off + +rm -rf /tmp/$MODULE +rm /usr/local/bin/color +exit $FAILED diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/vagrant_test.sh b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/vagrant_test.sh new file mode 100644 index 0000000000..162b704173 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/.ci/vagrant_test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd /vagrant +chmod a+x tests/.ci/test.sh +./tests/.ci/test.sh diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/apt.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/apt.pp new file mode 100644 index 0000000000..4e5fa18404 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/apt.pp @@ -0,0 +1,4 @@ +class { 'drush::apt' : + dist => 'squeeze', + backports => 'squeeze', +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/defaults.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/defaults.pp new file mode 100644 index 0000000000..da0c41ab8b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/defaults.pp @@ -0,0 +1 @@ +include drush::defaults diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/dis.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/dis.pp new file mode 100644 index 0000000000..8b6519724d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/dis.pp @@ -0,0 +1,3 @@ +include drush + +drush::dis { 'devel': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/dl.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/dl.pp new file mode 100644 index 0000000000..4a7d19897a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/dl.pp @@ -0,0 +1,2 @@ +include drush +drush::dl { 'token': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/en.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/en.pp new file mode 100644 index 0000000000..c43afe3826 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/en.pp @@ -0,0 +1,2 @@ +include drush +drush::en { 'views': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/git.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/git.pp new file mode 100644 index 0000000000..d33d4a6894 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/git.pp @@ -0,0 +1,4 @@ +include drush +drush::git { 'git://git.drupal.org:project/provision.git' : + path => '/var/aegir/.drush', +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/git/drush.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/git/drush.pp new file mode 100644 index 0000000000..6acc7e34d3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/git/drush.pp @@ -0,0 +1 @@ +include drush::git::drush diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/init.pp new file mode 100644 index 0000000000..86f0b12cf0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/init.pp @@ -0,0 +1 @@ +include drush diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/make.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/make.pp new file mode 100644 index 0000000000..8df88a5253 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/make.pp @@ -0,0 +1,4 @@ +include drush +drush::make { '/var/aegir/platforms/drupal7' : + makefile => '/var/aegir/makefiles/drupal7.make', +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/run.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/run.pp new file mode 100644 index 0000000000..b6f37a633d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/run.pp @@ -0,0 +1,2 @@ +include drush +drush::run { '@hostmaster hosting-dispatch' : } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/status.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/status.pp new file mode 100644 index 0000000000..9e562fa6bb --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/drush/tests/status.pp @@ -0,0 +1,2 @@ +include drush +drush::status { '@none' : } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/.fixtures.yml new file mode 100644 index 0000000000..e16c4080a1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/.fixtures.yml @@ -0,0 +1,5 @@ +fixtures: + repositories: + stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git + symlinks: + elasticsearch: "#{source_dir}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/.travis.yml new file mode 100644 index 0000000000..c4a322e03f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/.travis.yml @@ -0,0 +1,33 @@ +language: ruby +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 +script: + - "rake lint" + - "rake parser_validate" + - "rake template_verify" + - "rake spec SPEC_OPTS='--format documentation'" +env: + - PUPPET_VERSION="~> 2.7.0" + - PUPPET_VERSION="~> 3.0.0" + - PUPPET_VERSION="~> 3.1.0" + - PUPPET_VERSION="~> 3.2.0" + - PUPPET_VERSION="~> 3.3.0" +matrix: + allow_failures: + - rvm: 2.0.0 +gemfile: Gemfile +notifications: + email: + recipients: + - richard.pijnenburg@elasticsearch.com + on_success: change + on_failure: always + hipchat: + rooms: + secure: "gFaED3lu9MRrmoojO2iagrfOaKAbCeQSqVZ9TsIo+qkqem8hwOsMuxsYQ9evPbPbanXQoVNALXTd4fgQW16+hfg/ClqI3nDtVZZJSy0W+U0yVZtz9TXFpi9Q/Z4TwK5TMdNMjemt0l2idY2SE3leHBZEeaIAGfLf0v38tCsNI84=" + template: + - '@electrical %{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message} %{build_url}' + on_success: change + on_failure: always diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/CHANGELOG b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/CHANGELOG new file mode 100644 index 0000000000..90a59fc930 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/CHANGELOG @@ -0,0 +1,91 @@ +0.2.2 ( Jan 23, 2014 ) + Ensure exec names are unique. This caused issues when using our logstash module + Add spec tests for plugin define + +0.2.1 ( Jan 22, 2014 ) + Simplify the management of the defaults file ( PR #64 ) + Doc improvements for the plugin define ( PR #66 ) + Allow creation of data directory ( PR #68 ) + Fail early when package version and package_url are defined + +0.2.0 ( Nov 19, 2013 ) + Large rewrite of the entire module described below + Make the core more dynamic for different service providers and multi instance capable + Add better testing and devided into different files + Fix template function. Replace of template is now only done when the file is changed + Add different ways to install the package except from the repository ( puppet/http/https/ftp/file ) + Update java class to install openjdk 1.7 + Add tests for python function + Update config file template to fix scoping issue ( from PR #57 ) + Add validation of templates + Small changes for preperation for system tests + Update readme for new functionality + Added more test scenario's + Added puppet parser validate task for added checking + Ensure we don't add stuff when removing the module + Update python client define + Add ruby client define + Add tests for ruby clients and update python client tests + +0.1.3 ( Sep 06, 2013 ) + Exec path settings has been updated to fix warnings ( PR #37, #47 ) + Adding define to install python bindings ( PR #43 ) + Scope deprecation fixes ( PR #41 ) + feature to install plugins ( PR #40 ) + +0.1.2 ( Jun 21, 2013 ) + Update rake file to ignore the param inherit + Added missing documentation to the template define + Fix for template define to allow multiple templates ( PR #36 by Bruce Morrison ) + +0.1.1 ( Jun 14, 2013 ) + Add Oracle Linux to the OS list ( PR #25 by Stas Alekseev ) + Respect the restart_on_change on the defaults ( PR #29 by Simon Effenberg ) + Make sure the config can be empty as advertised in the readme + Remove dependency cycle when the defaults file is updated ( PR #31 by Bruce Morrison ) + Enable retry on the template insert in case ES isn't started yet ( PR #32 by Bruce Morrison ) + Update templates to avoid deprecation notice with Puppet 3.2.x + Update template define to avoid auto insert issue with ES + Update spec tests to reflect changes to template define + +0.1.0 ( May 09, 2013 ) + Populate .gitignore ( PR #19 by Igor Galić ) + Add ability to install initfile ( PR #20 by Justin Lambert ) + Add ability to manage default file* service parameters ( PR #21 by Mathieu Bornoz ) + Providing complete containment of the module ( PR #24 by Brian Lalor ) + Add ability to specify package version ( PR #25 by Justin Lambert ) + Adding license file + +0.0.7 ( Mar 23, 2013 ) + Ensure config directory is created and managed ( PR #13 by Martin Seener ) + Dont backup package if it changes + Create explicit dependency on template directory ( PR #16 by Igor Galić ) + Make the config directory variable ( PR #17 by Igor Galić and PR #18 by Vincent Janelle ) + Fixing template define + +0.0.6 ( Mar 05, 2013 ) + Fixing issue with configuration not printing out arrays + New feature to write the config hash shorter + Updated readme to reflect the new feature + Adding spec tests for config file generation + +0.0.5 ( Mar 03, 2013 ) + Option to disable restart on config file change ( PR #10 by Chris Boulton ) + +0.0.4 ( Mar 02, 2013 ) + Fixed a major issue with the config template ( Issue #9 ) + +0.0.3 ( Mar 02, 2013 ) + Adding spec tests + Fixed init issue on Ubuntu ( Issue #6 by Marcus Furlong ) + Fixed config template problem ( Issue #8 by surfchris ) + New feature to manage templates + +0.0.2 ( Feb 16, 2013 ) + Feature to supply a package instead of being dependent on the repository + Feature to install java in case one doesn't manage it externally + Adding RedHat and Amazon as Operating systems + fixed a typo - its a shard not a shared :) ( PR #5 by Martin Seener ) + +0.0.1 ( Jan 13, 2013 ) + Initial release of the module diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/CONTRIBUTING.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/CONTRIBUTING.md new file mode 100644 index 0000000000..13f29e3307 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/CONTRIBUTING.md @@ -0,0 +1,18 @@ +If you have a bugfix or new feature that you would like to contribute to this puppet module, please find or open an issue about it first. Talk about what you would like to do. It may be that somebody is already working on it, or that there are particular issues that you should know about before implementing the change. + +We enjoy working with contributors to get their code accepted. There are many approaches to fixing a problem and it is important to find the best approach before writing too much code. + +The process for contributing to any of the Elasticsearch repositories is similar. + +1. Sign the contributor license agreement +Please make sure you have signed the [Contributor License Agreement](http://www.elasticsearch.org/contributor-agreement/). We are not asking you to assign copyright to us, but to give us the right to distribute your code without restriction. We ask this of all contributors in order to assure our users of the origin and continuing existence of the code. You only need to sign the CLA once. + +2. Run the rspec tests and ensure it completes without errors with your changes. + +3. Rebase your changes +Update your local repository with the most recent code from the main this puppet module repository, and rebase your branch on top of the latest master branch. We prefer your changes to be squashed into a single commit. + +4. Submit a pull request +Push your local changes to your forked copy of the repository and submit a pull request. In the pull request, describe what your changes do and mention the number of the issue where discussion has taken place, eg “Closes #123″. + +Then sit back and wait. There will probably be discussion about the pull request and, if any changes are needed, we would love to work with you to get your pull request merged into this puppet module. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/CONTRIBUTORS b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/CONTRIBUTORS new file mode 100644 index 0000000000..ad0eb76c4d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/CONTRIBUTORS @@ -0,0 +1,20 @@ +The following is a list of people who have contributed ideas, code, bug +reports, or in general have helped this puppet module along its way. + +Project Owner +* Richard Pijnenburg (electrical) + +Contributors: +Martin Seener (martinseener) +Marcus Furlong (furlongm) +Chris Boulton (chrisboulton) +Igor Galić (igalic) +Vincent Janelle (vjanelle) +Mathieu Bornoz (mbornoz) +Justin Lambert (jlambert121) +Brian Lalor (blalor) +Stas Alekseev (salekseev) +Simon Effenberg (Savar) +Bruce Morrison (brucem) +deanmalmgren +Matteo Sessa (msessa-cotd) diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/Gemfile new file mode 100644 index 0000000000..95b8d66d8f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/Gemfile @@ -0,0 +1,7 @@ +source 'https://rubygems.org' + +puppetversion = ENV['PUPPET_VERSION'] +gem 'puppet', puppetversion, :require => false +gem 'puppet-lint' +gem 'rspec-puppet' +gem 'puppetlabs_spec_helper', '>= 0.1.0' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/LICENSE new file mode 100644 index 0000000000..f8b711d55d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2012-2014 Elasticsearch + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/Modulefile new file mode 100644 index 0000000000..44aae1c8bd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/Modulefile @@ -0,0 +1,9 @@ +name 'elasticsearch-elasticsearch' +version '0.2.2' +source 'https://github.com/elasticsearch/puppet-elasticsearch' +author 'elasticsearch' +license 'Apache License, Version 2.0' +summary 'Module for managing and configuring Elasticsearch nodes' +description 'Module for managing and configuring Elasticsearch nodes' +project_page 'https://github.com/elasticsearch/puppet-elasticsearch' +dependency 'puppetlabs/stdlib', '>= 3.0.0' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/README.md new file mode 100644 index 0000000000..12a12759d9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/README.md @@ -0,0 +1,203 @@ +# puppet-elasticsearch + +A puppet module for managing elasticsearch nodes + +http://www.elasticsearch.org/ + +[](https://travis-ci.org/elasticsearch/puppet-elasticsearch) + +## Usage + +Installation, make sure service is running and will be started at boot time: + + class { 'elasticsearch': } + +Install a certain version: + + class { 'elasticsearch': + version => '0.90.3' + } + +This assumes an elasticsearch package is already available to your distribution's package manager. To install it in a different way: + +To download from http/https/ftp source: + + class { 'elasticsearch': + package_url => 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.deb' + } + +To download from a puppet:// source: + + class { 'elasticsearch': + package_url => 'puppet:///path/to/elasticsearch-0.90.7.deb' + } + +Or use a local file source: + + class { 'elasticsearch': + package_url => 'file:/path/to/elasticsearch-0.90.7.deb' + } + +Automatic upgrade of the software ( default set to false ): + + class { 'elasticsearch': + autoupgrade => true + } + +Removal/decommissioning: + + class { 'elasticsearch': + ensure => 'absent' + } + +Install everything but disable service(s) afterwards: + + class { 'elasticsearch': + status => 'disabled' + } + +Disable automated restart of Elasticsearch on config file change: + + class { 'elasticsearch': + restart_on_change => false + } + +For the config variable a hash needs to be passed: + + class { 'elasticsearch': + config => { + 'node' => { + 'name' => 'elasticsearch001' + }, + 'index' => { + 'number_of_replicas' => '0', + 'number_of_shards' => '5' + }, + 'network' => { + 'host' => $::ipaddress + } + } + } + +Short write up of the config hash is also possible. + +Instead of writing the full hash representation: + + class { 'elasticsearch': + config => { + 'cluster' => { + 'name' => 'ClusterName', + 'routing' => { + 'allocation' => { + 'awareness' => { + 'attributes' => 'rack' + } + } + } + } + } + } + +You can write the dotted key naming: + + class { 'elasticsearch': + config => { + 'cluster' => { + 'name' => 'ClusterName', + 'routing.allocation.awareness.attributes' => 'rack' + } + } + } + + +## Manage templates + +### Add a new template + +This will install and/or replace the template in Elasticearch + + elasticsearch::template { 'templatename': + file => 'puppet:///path/to/template.json' + } + +### Delete a template + + elasticsearch::template { 'templatename': + ensure => 'absent' + } + +### Host + + Default it uses localhost:9200 as host. you can change this with the 'host' and 'port' variables + + elasticsearch::template { 'templatename': + host => $::ipaddress, + port => 9200 + } + +## Bindings / clients + +Install a variety of [clients/bindings](http://www.elasticsearch.org/guide/clients/): + +### Python + + elasticsearch::python { 'rawes': } + +### Ruby + + elasticsearch::ruby { 'elasticsearch': } + +## Plugins + +Install [a variety of plugins](http://www.elasticsearch.org/guide/clients/): + +### From official repository: + + elasticsearch::plugin{'mobz/elasticsearch-head': + module_dir => 'head' + } + +### From custom url: + + elasticsearch::plugin{ 'elasticsearch-jetty': + module_dir => 'jetty', + url => 'https://oss-es-plugins.s3.amazonaws.com/elasticsearch-jetty/elasticsearch-jetty-0.90.0.zip' + } + +## Java install + +For those that have no separate module for installation of java: + + class { 'elasticsearch': + java_install => true + } + +If you want a specific java package/version: + + class { 'elasticsearch': + java_install => true, + java_package => 'packagename' + } + +## Service providers + +Currently only the 'init' service provider is supported but others can be implemented quite easy. + +### init + +#### Defaults file + +You can populate the defaults file ( /etc/defaults/elasticsearch or /etc/sysconfig/elasticsearch ) + +##### hash representation + + class { 'elasticsearch': + init_defaults => { 'ES_USER' => 'elasticsearch', 'ES_GROUP' => 'elasticsearch' } + } + +##### file source + + class { 'elasticsearch': + init_defaults_file => 'puppet:///path/to/defaults' + } + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/Rakefile new file mode 100644 index 0000000000..425e032920 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/Rakefile @@ -0,0 +1,7 @@ +require 'rubygems' +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint' +require './spec/lib/template_check_task.rb' +require './spec/lib/parser_validate_task.rb' +PuppetLint.configuration.send("disable_80chars") +PuppetLint.configuration.send("disable_class_inherits_from_params_class") diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/config.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/config.pp new file mode 100644 index 0000000000..a26886d4f0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/config.pp @@ -0,0 +1,90 @@ +# == Class: elasticsearch::config +# +# This class exists to coordinate all configuration related actions, +# functionality and logical units in a central place. +# +# +# === Parameters +# +# This class does not provide any parameters. +# +# +# === Examples +# +# This class may be imported by other classes to use its functionality: +# class { 'elasticsearch::config': } +# +# It is not intended to be used directly by external resources like node +# definitions or other modules. +# +# +# === Authors +# +# * Richard Pijnenburg +# +class elasticsearch::config { + + #### Configuration + + File { + owner => $elasticsearch::elasticsearch_user, + group => $elasticsearch::elasticsearch_group + } + + Exec { + path => [ '/bin', '/usr/bin', '/usr/local/bin' ], + cwd => '/', + } + + if ( $elasticsearch::ensure == 'present' ) { + + $notify_service = $elasticsearch::restart_on_change ? { + true => Class['elasticsearch::service'], + false => undef, + } + + file { $elasticsearch::confdir: + ensure => directory, + mode => '0644', + purge => $elasticsearch::purge_confdir, + force => $elasticsearch::purge_confdir + } + + file { "${elasticsearch::confdir}/elasticsearch.yml": + ensure => file, + content => template("${module_name}/etc/elasticsearch/elasticsearch.yml.erb"), + mode => '0644', + notify => $notify_service + } + + exec { 'mkdir_templates_elasticsearch': + command => "mkdir -p ${elasticsearch::confdir}/templates_import", + creates => "${elasticsearch::confdir}/templates_import" + } + + file { "${elasticsearch::confdir}/templates_import": + ensure => 'directory', + mode => '0644', + require => Exec['mkdir_templates_elasticsearch'] + } + + if ( $elasticsearch::datadir != undef ) { + file { $elasticsearch::datadir: + ensure => 'directory', + owner => $elasticsearch::elasticsearch_user, + group => $elasticsearch::elasticsearch_group, + mode => '0770', + } + } + + } elsif ( $elasticsearch::ensure == 'absent' ) { + + file { $elasticsearch::confdir: + ensure => 'absent', + recurse => true, + force => true + } + + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/init.pp new file mode 100644 index 0000000000..fabfd78867 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/init.pp @@ -0,0 +1,208 @@ +# == Class: elasticsearch +# +# This class is able to install or remove elasticsearch on a node. +# It manages the status of the related service. +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. +# +# [*autoupgrade*] +# Boolean. If set to true, any managed package gets upgraded +# on each Puppet run when the package provider is able to find a newer +# version than the present one. The exact behavior is provider dependent. +# Q.v.: +# * Puppet type reference: {package, "upgradeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# Defaults to false. +# +# [*status*] +# String to define the status of the service. Possible values: +# * enabled: Service is running and will be started at boot time. +# * disabled: Service is stopped and will not be started at boot +# time. +# * running: Service is running but will not be started at boot time. +# You can use this to start a service on the first Puppet run instead of +# the system startup. +# * unmanaged: Service will not be started at boot time and Puppet +# does not care whether the service is running or not. For example, this may +# be useful if a cluster management software is used to decide when to start +# the service plus assuring it is running on the desired node. +# Defaults to enabled. The singular form ("service") is used for the +# sake of convenience. Of course, the defined status affects all services if +# more than one is managed (see service.pp to check if this is the +# case). +# +# [*version*] +# String to set the specific version you want to install. +# Defaults to false. +# +# [*restart_on_change*] +# Boolean that determines if the application should be automatically restarted +# whenever the configuration changes. Disabling automatic restarts on config +# changes may be desired in an environment where you need to ensure restarts +# occur in a controlled/rolling manner rather than during a Puppet run. +# +# Defaults to true, which will restart the application on any config +# change. Setting to false disables the automatic restart. +# +# [*confdir*] +# Path to directory containing the elasticsearch configuration. +# Use this setting if your packages deviate from the norm (/etc/elasticsearch) +# +# [*plugindir*] +# Path to directory containing the elasticsearch plugins +# Use this setting if your packages deviate from the norm (/usr/share/elasticsearch/plugins) +# +# [*plugintool*] +# Path to directory containing the elasticsearch plugin installation script +# Use this setting if your packages deviate from the norm (/usr/share/elasticsearch/bin/plugin) +# +# The default values for the parameters are set in elasticsearch::params. Have +# a look at the corresponding params.pp manifest file if you need more +# technical information about them. +# +# === Examples +# +# * Installation, make sure service is running and will be started at boot time: +# class { 'elasticsearch': } +# +# * Removal/decommissioning: +# class { 'elasticsearch': +# ensure => 'absent', +# } +# +# * Install everything but disable service(s) afterwards +# class { 'elasticsearch': +# status => 'disabled', +# } +# +# +# === Authors +# +# * Richard Pijnenburg +# +class elasticsearch( + $ensure = $elasticsearch::params::ensure, + $status = $elasticsearch::params::status, + $restart_on_change = $elasticsearch::params::restart_on_change, + $autoupgrade = $elasticsearch::params::autoupgrade, + $version = false, + $package_provider = 'package', + $package_url = undef, + $package_dir = $elasticsearch::params::package_dir, + $purge_package_dir = $elasticsearch::params::purge_package_dir, + $elasticsearch_user = $elasticsearch::params::elasticsearch_user, + $elasticsearch_group = $elasticsearch::params::elasticsearch_group, + $purge_confdir = $elasticsearch::params::purge_confdir, + $service_provider = 'init', + $init_defaults = undef, + $init_defaults_file = undef, + $init_template = undef, + $config = {}, + $confdir = $elasticsearch::params::confdir, + $datadir = undef, + $plugindir = $elasticsearch::params::plugindir, + $plugintool = $elasticsearch::params::plugintool, + $java_install = false, + $java_package = undef +) inherits elasticsearch::params { + + anchor {'elasticsearch::begin': } + anchor {'elasticsearch::end': } + + + #### Validate parameters + + # ensure + if ! ($ensure in [ 'present', 'absent' ]) { + fail("\"${ensure}\" is not a valid ensure parameter value") + } + + # autoupgrade + validate_bool($autoupgrade) + + # service status + if ! ($status in [ 'enabled', 'disabled', 'running', 'unmanaged' ]) { + fail("\"${status}\" is not a valid status parameter value") + } + + # restart on change + validate_bool($restart_on_change) + + # purge conf dir + validate_bool($purge_confdir) + + if ! ($service_provider in $elasticsearch::params::service_providers) { + fail("\"${service_provider}\" is not a valid provider for \"${::operatingsystem}\"") + } + + if ($package_url != undef and $version != false) { + fail('Unable to set the version number when using package_url option.') + } + + # validate config hash + validate_hash($config) + + # java install validation + validate_bool($java_install) + + #### Manage actions + + # package(s) + class { 'elasticsearch::package': } + + # configuration + class { 'elasticsearch::config': } + + # service(s) + class { 'elasticsearch::service': } + + if $java_install == true { + # Install java + class { 'elasticsearch::java': } + + # ensure we first java java and then manage the service + Anchor['elasticsearch::begin'] + -> Class['elasticsearch::java'] + -> Class['elasticsearch::service'] + } + + #### Manage relationships + + if $ensure == 'present' { + + # we need the software before configuring it + Anchor['elasticsearch::begin'] + -> Class['elasticsearch::package'] + -> Class['elasticsearch::config'] + + # we need the software and a working configuration before running a service + Class['elasticsearch::package'] -> Class['elasticsearch::service'] + Class['elasticsearch::config'] -> Class['elasticsearch::service'] + + Class['elasticsearch::service'] -> Anchor['elasticsearch::end'] + + } else { + + # make sure all services are getting stopped before software removal + Anchor['elasticsearch::begin'] + -> Class['elasticsearch::service'] + -> Class['elasticsearch::package'] + -> Anchor['elasticsearch::end'] + + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/java.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/java.pp new file mode 100644 index 0000000000..8d5149d381 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/java.pp @@ -0,0 +1,50 @@ +# == Class: elasticsearch::java +# +# This class exists to install java if its not managed from an other module +# +# +# === Parameters +# +# This class does not provide any parameters. +# +# +# === Examples +# +# This class may be imported by other classes to use its functionality: +# class { 'elasticsearch::java': } +# +# It is not intended to be used directly by external resources like node +# definitions or other modules. +# +# +# === Authors +# +# * Richard Pijnenburg +# +class elasticsearch::java { + + if $elasticsearch::java_package == undef { + # Default Java package + case $::operatingsystem { + 'CentOS', 'Fedora', 'Scientific', 'RedHat', 'Amazon', 'OracleLinux': { + $package = 'java-1.7.0-openjdk' + } + 'Debian', 'Ubuntu': { + $package = 'openjdk-7-jre-headless' + } + default: { + fail("\"${module_name}\" provides no java package + for \"${::operatingsystem}\"") + } + } + } else { + $package = $elasticsearch::java_package + } + + ## Install the java package unless already specified somewhere else + if !defined(Package[$package]) { + package { $package: + ensure => present + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/package.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/package.pp new file mode 100644 index 0000000000..1cb5295d47 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/package.pp @@ -0,0 +1,145 @@ +# == Class: elasticsearch::package +# +# This class exists to coordinate all software package management related +# actions, functionality and logical units in a central place. +# +# +# === Parameters +# +# This class does not provide any parameters. +# +# +# === Examples +# +# This class may be imported by other classes to use its functionality: +# class { 'elasticsearch::package': } +# +# It is not intended to be used directly by external resources like node +# definitions or other modules. +# +# +# === Authors +# +# * Richard Pijnenburg +# +class elasticsearch::package { + + + #### Package management + + # set params: in operation + if $elasticsearch::ensure == 'present' { + + # Check if we want to install a specific version or not + if $elasticsearch::version == false { + + $package_ensure = $elasticsearch::autoupgrade ? { + true => 'latest', + false => 'present', + } + + } else { + + # install specific version + $package_ensure = $elasticsearch::version + + } + + # action + if ($elasticsearch::package_url != undef) { + + $package_dir = $elasticsearch::package_dir + + # Create directory to place the package file + exec { 'create_package_dir_elasticsearch': + cwd => '/', + path => ['/usr/bin', '/bin'], + command => "mkdir -p ${elasticsearch::package_dir}", + creates => $elasticsearch::package_dir; + } + + file { $package_dir: + ensure => 'directory', + purge => $elasticsearch::purge_package_dir, + force => $elasticsearch::purge_package_dir, + require => Exec['create_package_dir_elasticsearch'], + } + + $filenameArray = split($elasticsearch::package_url, '/') + $basefilename = $filenameArray[-1] + + $sourceArray = split($elasticsearch::package_url, ':') + $protocol_type = $sourceArray[0] + + $extArray = split($basefilename, '\.') + $ext = $extArray[-1] + + case $protocol_type { + + puppet: { + + file { "${package_dir}/${basefilename}": + ensure => present, + source => $elasticsearch::package_url, + require => File[$package_dir], + backup => false, + before => Package[$elasticsearch::params::package] + } + + } + ftp, https, http: { + + exec { 'download_package_elasticsearch': + command => "${elasticsearch::params::dlcmd} ${package_dir}/${basefilename} ${elasticsearch::package_url} 2> /dev/null", + path => ['/usr/bin', '/bin'], + creates => "${package_dir}/${basefilename}", + require => File[$package_dir], + before => Package[$elasticsearch::params::package] + } + + } + file: { + + $source_path = $sourceArray[1] + file { "${package_dir}/${basefilename}": + ensure => present, + source => $source_path, + require => File[$package_dir], + backup => false, + before => Package[$elasticsearch::params::package] + } + + } + default: { + fail("Protocol must be puppet, file, http, https, or ftp. You have given \"${protocol_type}\"") + } + } + + case $ext { + 'deb': { $pkg_provider = 'dpkg' } + 'rpm': { $pkg_provider = 'rpm' } + default: { fail("Unknown file extention \"${ext}\".") } + } + + $pkg_source = "${package_dir}/${basefilename}" + + } else { + $pkg_source = undef + $pkg_provider = undef + } + + # Package removal + } else { + + $pkg_source = undef + $pkg_provider = undef + $package_ensure = 'purged' + } + + package { $elasticsearch::params::package: + ensure => $package_ensure, + source => $pkg_source, + provider => $pkg_provider + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/params.pp new file mode 100644 index 0000000000..aea527f1b6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/params.pp @@ -0,0 +1,122 @@ +# == Class: elasticsearch::params +# +# This class exists to +# 1. Declutter the default value assignment for class parameters. +# 2. Manage internally used module variables in a central place. +# +# Therefore, many operating system dependent differences (names, paths, ...) +# are addressed in here. +# +# +# === Parameters +# +# This class does not provide any parameters. +# +# +# === Examples +# +# This class is not intended to be used directly. +# +# +# === Links +# +# * {Puppet Docs: Using Parameterized Classes}[http://j.mp/nVpyWY] +# +# +# === Authors +# +# * Richard Pijnenburg +# +class elasticsearch::params { + + #### Default values for the parameters of the main module class, init.pp + + # ensure + $ensure = 'present' + + # autoupgrade + $autoupgrade = false + + # service status + $status = 'enabled' + + # restart on configuration change? + $restart_on_change = true + + # Package dir. Temporary place to download the package to for installation + $package_dir = '/var/lib/elasticsearch' + + # User and Group for the files and user to run the service as. + $elasticsearch_user = 'elasticsearch' + $elasticsearch_group = 'elasticsearch' + + # Purge configuration directory + $purge_confdir = true + + ## init service provider + + # configuration directory + $confdir = '/etc/elasticsearch' + + # plugins directory + $plugindir = '/usr/share/elasticsearch/plugins' + + # plugins helper binary + $plugintool = '/usr/share/elasticsearch/bin/plugin' + + # Download tool + $dlcmd = 'wget -O' + + $purge_package_dir = false + + #### Internal module values + + # packages + case $::operatingsystem { + 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon', 'OracleLinux': { + # main application + $package = [ 'elasticsearch' ] + } + 'Debian', 'Ubuntu': { + # main application + $package = [ 'elasticsearch' ] + } + default: { + fail("\"${module_name}\" provides no package default value + for \"${::operatingsystem}\"") + } + } + + # service parameters + case $::operatingsystem { + 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon', 'OracleLinux': { + $service_name = 'elasticsearch' + $service_hasrestart = true + $service_hasstatus = true + $service_pattern = $service_name + $service_providers = [ 'init' ] + $defaults_location = '/etc/sysconfig' + } + 'Debian', 'Ubuntu': { + $service_name = 'elasticsearch' + $service_hasrestart = true + $service_hasstatus = true + $service_pattern = $service_name + $service_providers = [ 'init' ] + $defaults_location = '/etc/default' + } + 'Darwin': { + $service_name = 'FIXME/TODO' + $service_hasrestart = true + $service_hasstatus = true + $service_pattern = $service_name + $service_providers = [ 'launchd' ] + $defaults_location = false + } + default: { + fail("\"${module_name}\" provides no service parameters + for \"${::operatingsystem}\"") + } + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/plugin.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/plugin.pp new file mode 100644 index 0000000000..025c302332 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/plugin.pp @@ -0,0 +1,96 @@ +# == Define: elasticsearch::plugin +# +# This define allows you to install arbitrary Elasticsearch plugins +# either by using the default repositories or by specifying an URL +# +# All default values are defined in the elasticsearch::params class. +# +# +# === Parameters +# +# [*module_dir*] +# Directory name where the module will be installed +# Value type is string +# Default value: None +# This variable is required +# +# [*ensure*] +# Whether the plugin will be installed or removed. +# Set to 'absent' to ensure a plugin is not installed +# Value type is string +# Default value: present +# This variable is optional +# +# [*url*] +# Specify an URL where to download the plugin from. +# Value type is string +# Default value: None +# This variable is optional +# +# +# === Examples +# +# # From official repository +# elasticsearch::plugin{'mobz/elasticsearch-head': module_dir => 'head'} +# +# # From custom url +# elasticsearch::plugin{ 'elasticsearch-jetty': +# module_dir => 'elasticsearch-jetty', +# url => 'https://oss-es-plugins.s3.amazonaws.com/elasticsearch-jetty/elasticsearch-jetty-0.90.0.zip', +# } +# +# === Authors +# +# * Matteo Sessa +# * Dennis Konert +# +define elasticsearch::plugin( + $module_dir, + $ensure = 'present', + $url = '' +) { + + Exec { + path => [ '/bin', '/usr/bin', '/usr/local/bin' ], + cwd => '/', + } + + $notify_service = $elasticsearch::restart_on_change ? { + false => undef, + default => Service['elasticsearch'], + } + + if ($module_dir != '') { + validate_string($module_dir) + } else { + fail("module_dir undefined for plugin ${name}") + } + + if ($url != '') { + validate_string($url) + $install_cmd = "${elasticsearch::plugintool} -install ${name} -url ${url}" + $exec_rets = [0,1] + } else { + $install_cmd = "${elasticsearch::plugintool} -install ${name}" + $exec_rets = [0,] + } + + case $ensure { + 'installed', 'present': { + exec {"install_plugin_${name}": + command => $install_cmd, + creates => "${elasticsearch::plugindir}/${module_dir}", + returns => $exec_rets, + notify => $notify_service, + require => Class['elasticsearch::package'] + } + } + default: { + exec {"remove_plugin_${name}": + command => "${elasticsearch::plugintool} --remove ${module_dir}", + onlyif => "test -d ${elasticsearch::plugindir}/${module_dir}", + notify => $notify_service, + } + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/python.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/python.pp new file mode 100644 index 0000000000..e1d91a9aba --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/python.pp @@ -0,0 +1,73 @@ +# == Define: elasticsearch::python +# +# there are many python bindings for elasticsearch. This provides all +# the ones we know about http://www.elasticsearch.org/guide/clients/ +# +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. + +# +# +# === Examples +# +# elasticsearch::python { 'pyes':; } +# +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::python ( + $ensure = 'present' +) { + + if ! ($ensure in [ 'present', 'absent' ]) { + fail("\"${ensure}\" is not a valid ensure parameter value") + } + + # make sure the package name is valid and setup the provider as + # necessary + case $name { + 'pyes': { + $provider = 'pip' + } + 'rawes': { + $provider = 'pip' + } + 'pyelasticsearch': { + $provider = 'pip' + } + 'ESClient': { + $provider = 'pip' + } + 'elasticutils': { + $provider = 'pip' + } + 'elasticsearch': { + $provider = 'pip' + } + default: { + fail("unknown python binding package '${name}'") + } + } + + package { $name: + ensure => $ensure, + provider => $provider, + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/ruby.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/ruby.pp new file mode 100644 index 0000000000..3e35f416f2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/ruby.pp @@ -0,0 +1,67 @@ +# == Define: elasticsearch::ruby +# +# there are many ruby bindings for elasticsearch. This provides all +# the ones we know about http://www.elasticsearch.org/guide/clients/ +# +# +# === Parameters +# +# [*ensure*] +# String. Controls if the managed resources shall be present or +# absent. If set to absent: +# * The managed software packages are being uninstalled. +# * Any traces of the packages will be purged as good as possible. This may +# include existing configuration files. The exact behavior is provider +# dependent. Q.v.: +# * Puppet type reference: {package, "purgeable"}[http://j.mp/xbxmNP] +# * {Puppet's package provider source code}[http://j.mp/wtVCaL] +# * System modifications (if any) will be reverted as good as possible +# (e.g. removal of created users, services, changed log settings, ...). +# * This is thus destructive and should be used with care. +# Defaults to present. + +# +# +# === Examples +# +# elasticsearch::ruby { 'elasticsearch':; } +# +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::ruby ( + $ensure = 'present' +) { + + if ! ($ensure in [ 'present', 'absent' ]) { + fail("\"${ensure}\" is not a valid ensure parameter value") + } + + # make sure the package name is valid and setup the provider as + # necessary + case $name { + 'tire': { + $provider = 'gem' + } + 'stretcher': { + $provider = 'gem' + } + 'elastic_searchable': { + $provider = 'gem' + } + 'elasticsearch': { + $provider = 'gem' + } + default: { + fail("unknown ruby client package '${name}'") + } + } + + package { $name: + ensure => $ensure, + provider => $provider, + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/service.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/service.pp new file mode 100644 index 0000000000..891f559799 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/service.pp @@ -0,0 +1,43 @@ +# == Class: elasticsearch::service +# +# This class exists to coordinate all service management related actions, +# functionality and logical units in a central place. +# +# Note: "service" is the Puppet term and type for background processes +# in general and is used in a platform-independent way. E.g. "service" means +# "daemon" in relation to Unix-like systems. +# +# +# === Parameters +# +# This class does not provide any parameters. +# +# +# === Examples +# +# This class may be imported by other classes to use its functionality: +# class { 'elasticsearch::service': } +# +# It is not intended to be used directly by external resources like node +# definitions or other modules. +# +# +# === Authors +# +# * Richard Pijnenburg +# +class elasticsearch::service { + + case $elasticsearch::service_provider { + + init: { + elasticsearch::service::init { 'elasticsearch': } + } + + default: { + fail("Unknown service provider ${elasticsearch::service_provider}") + } + + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/service/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/service/init.pp new file mode 100644 index 0000000000..2db645c8de --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/service/init.pp @@ -0,0 +1,132 @@ +# == Define: elasticsearch::service::init +# +# This class exists to coordinate all service management related actions, +# functionality and logical units in a central place. +# +# Note: "service" is the Puppet term and type for background processes +# in general and is used in a platform-independent way. E.g. "service" means +# "daemon" in relation to Unix-like systems. +# +# +# === Parameters +# +# This class does not provide any parameters. +# +# +# === Examples +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::service::init{ + + #### Service management + + # set params: in operation + if $elasticsearch::ensure == 'present' { + + case $elasticsearch::status { + # make sure service is currently running, start it on boot + 'enabled': { + $service_ensure = 'running' + $service_enable = true + } + # make sure service is currently stopped, do not start it on boot + 'disabled': { + $service_ensure = 'stopped' + $service_enable = false + } + # make sure service is currently running, do not start it on boot + 'running': { + $service_ensure = 'running' + $service_enable = false + } + # do not start service on boot, do not care whether currently running + # or not + 'unmanaged': { + $service_ensure = undef + $service_enable = false + } + # unknown status + # note: don't forget to update the parameter check in init.pp if you + # add a new or change an existing status. + default: { + fail("\"${elasticsearch::status}\" is an unknown service status value") + } + } + + # set params: removal + } else { + + # make sure the service is stopped and disabled (the removal itself will be + # done by package.pp) + $service_ensure = 'stopped' + $service_enable = false + + } + + $notify_service = $elasticsearch::restart_on_change ? { + true => Service[$name], + false => undef, + } + + + if ( $elasticsearch::status != 'unmanaged' ) { + + # defaults file content. Either from a hash or file + if ($elasticsearch::init_defaults_file != undef) { + $defaults_content = undef + $defaults_source = $elasticsearch::init_defaults_file + } elsif ($elasticsearch::init_defaults != undef and is_hash($elasticsearch::init_defaults) ) { + $defaults_content = template("${module_name}/etc/sysconfig/defaults.erb") + $defaults_source = undef + } else { + $defaults_content = undef + $defaults_source = undef + } + + # Check if we are going to manage the defaults file. + if ( $defaults_content != undef or $defaults_source != undef ) { + + file { "${elasticsearch::params::defaults_location}/${name}": + ensure => $elasticsearch::ensure, + source => $defaults_source, + content => $defaults_content, + owner => 'root', + group => 'root', + mode => '0644', + before => Service[$name], + notify => $notify_service + } + + } + + # init file from template + if ($elasticsearch::init_template != undef) { + + file { "/etc/init.d/${name}": + ensure => $elasticsearch::ensure, + content => template($elasticsearch::init_template), + owner => 'root', + group => 'root', + mode => '0755', + before => Service[$name], + notify => $notify_service + } + + } + + } + + # action + service { $name: + ensure => $service_ensure, + enable => $service_enable, + name => $elasticsearch::params::service_name, + hasstatus => $elasticsearch::params::service_hasstatus, + hasrestart => $elasticsearch::params::service_hasrestart, + pattern => $elasticsearch::params::service_pattern, + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/template.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/template.pp new file mode 100644 index 0000000000..b8ab2a6151 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/manifests/template.pp @@ -0,0 +1,114 @@ +# == Define: elasticsearch::template +# +# This define allows you to insert, update or delete templates that are used within Elasticsearch for the indexes +# +# === Parameters +# +# [*file*] +# File path of the template ( json file ) +# Value type is string +# Default value: undef +# This variable is optional +# +# [*replace*] +# Set to 'true' if you intend to replace the existing template +# Value type is boolean +# Default value: false +# This variable is optional +# +# [*delete*] +# Set to 'true' if you intend to delete the existing template +# Value type is boolean +# Default value: false +# This variable is optional +# +# [*host*] +# Host name or IP address of the ES instance to connect to +# Value type is string +# Default value: localhost +# This variable is optional +# +# [*port*] +# Port number of the ES instance to connect to +# Value type is number +# Default value: 9200 +# This variable is optional +# +# === Authors +# +# * Richard Pijnenburg +# +define elasticsearch::template( + $ensure = 'present', + $file = undef, + $host = 'localhost', + $port = 9200 +) { + + require elasticsearch + + # ensure + if ! ($ensure in [ 'present', 'absent' ]) { + fail("\"${ensure}\" is not a valid ensure parameter value") + } + + if ! is_integer($port) { + fail("\"${port}\" is not an integer") + } + + Exec { + path => [ '/bin', '/usr/bin', '/usr/local/bin' ], + cwd => '/', + tries => 3, + try_sleep => 10 + } + + # Build up the url + $es_url = "http://${host}:${port}/_template/${name}" + + # Can't do a replace and delete at the same time + + if ($ensure == 'present') { + + # Fail when no file is supplied + if $file == undef { + fail('The variable "file" cannot be empty when inserting or updating a template') + + } else { # we are good to go. notify to insert in case we deleted + $insert_notify = Exec[ "insert_template_${name}" ] + } + + } else { + + $insert_notify = undef + + } + + # Delete the existing template + # First check if it exists of course + exec { "delete_template_${name}": + command => "curl -s -XDELETE ${es_url}", + onlyif => "test $(curl -s '${es_url}?pretty=true' | wc -l) -gt 1", + notify => $insert_notify, + refreshonly => true + } + + if ($ensure == 'present') { + + # place the template file + file { "${elasticsearch::confdir}/templates_import/elasticsearch-template-${name}.json": + ensure => 'present', + source => $file, + notify => Exec[ "delete_template_${name}" ], + require => Exec[ 'mkdir_templates' ], + } + + exec { "insert_template_${name}": + command => "curl -s -XPUT ${es_url} -d @${elasticsearch::confdir}/templates_import/elasticsearch-template-${name}.json", + unless => "test $(curl -s '${es_url}?pretty=true' | wc -l) -gt 1", + refreshonly => true + } + + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/001_elasticsearch_init_debian_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/001_elasticsearch_init_debian_spec.rb new file mode 100644 index 0000000000..dd4b5c1d20 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/001_elasticsearch_init_debian_spec.rb @@ -0,0 +1,219 @@ +require 'spec_helper' + +describe 'elasticsearch', :type => 'class' do + + [ 'Debian', 'Ubuntu'].each do |distro| + + context "on #{distro} OS" do + + let :facts do { + :operatingsystem => distro + } end + + context 'main class tests' do + + # init.pp + it { should contain_class('elasticsearch::package') } + it { should contain_class('elasticsearch::config') } + it { should contain_class('elasticsearch::service') } + + end + + context 'package installation' do + + context 'via repository' do + + context 'with default settings' do + + it { should contain_package('elasticsearch').with(:ensure => 'present') } + + end + + context 'with specified version' do + + let :params do { + :version => '1.0' + } end + + it { should contain_package('elasticsearch').with(:ensure => '1.0') } + end + + context 'with auto upgrade enabled' do + + let :params do { + :autoupgrade => true + } end + + it { should contain_package('elasticsearch').with(:ensure => 'latest') } + end + + end + + context 'when setting package version and package_url' do + + let :params do { + :version => '0.90.10', + :package_url => 'puppet:///path/to/some/elasticsearch-0.90.10.deb' + } end + + it { expect { should raise_error(Puppet::Error) } } + + end + + context 'via package_url setting' do + + context 'using puppet:/// schema' do + + let :params do { + :package_url => 'puppet:///path/to/package.deb' + } end + + it { should contain_file('/var/lib/elasticsearch/package.deb').with(:source => 'puppet:///path/to/package.deb', :backup => false) } + it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.deb', :provider => 'dpkg') } + end + + context 'using http:// schema' do + + let :params do { + :package_url => 'http://www.domain.com/path/to/package.deb' + } end + + it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') } + it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => "Exec[create_package_dir_elasticsearch]") } + it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.deb http://www.domain.com/path/to/package.deb 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') } + it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.deb', :provider => 'dpkg') } + end + + context 'using https:// schema' do + + let :params do { + :package_url => 'https://www.domain.com/path/to/package.deb' + } end + + it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') } + it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') } + it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.deb https://www.domain.com/path/to/package.deb 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') } + it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.deb', :provider => 'dpkg') } + end + + context 'using ftp:// schema' do + + let :params do { + :package_url => 'ftp://www.domain.com/path/to/package.deb' + } end + + it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') } + it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') } + it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.deb ftp://www.domain.com/path/to/package.deb 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') } + it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.deb', :provider => 'dpkg') } + end + + context 'using file:// schema' do + + let :params do { + :package_url => 'file:/path/to/package.deb' + } end + + it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') } + it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') } + it { should contain_file('/var/lib/elasticsearch/package.deb').with(:source => '/path/to/package.deb', :backup => false) } + it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.deb', :provider => 'dpkg') } + end + + end + + end # package + + context 'service setup' do + + context 'with provider \'init\'' do + + context 'and default settings' do + + it { should contain_service('elasticsearch').with(:ensure => 'running') } + + end + + context 'and set defaults via hash param' do + + let :params do { + :init_defaults => { 'SERVICE_USER' => 'root', 'SERVICE_GROUP' => 'root' } + } end + + it { should contain_file('/etc/default/elasticsearch').with(:content => "### MANAGED BY PUPPET ###\n\nSERVICE_GROUP=root\nSERVICE_USER=root\n", :notify => 'Service[elasticsearch]') } + + end + + context 'and set defaults via file param' do + + let :params do { + :init_defaults_file => 'puppet:///path/to/elasticsearch.defaults' + } end + + it { should contain_file('/etc/default/elasticsearch').with(:source => 'puppet:///path/to/elasticsearch.defaults', :notify => 'Service[elasticsearch]') } + + end + + context 'no service restart when defaults change' do + + let :params do { + :init_defaults => { 'SERVICE_USER' => 'root', 'SERVICE_GROUP' => 'root' }, + :restart_on_change => false + } end + + it { should contain_file('/etc/default/elasticsearch').with(:content => "### MANAGED BY PUPPET ###\n\nSERVICE_GROUP=root\nSERVICE_USER=root\n").without_notify } + + end + + context 'and set init file via template' do + + let :params do { + :init_template => "elasticsearch/etc/init.d/elasticsearch.Debian.erb" + } end + + it { should contain_file('/etc/init.d/elasticsearch').with(:notify => 'Service[elasticsearch]') } + + end + + context 'No service restart when restart_on_change is false' do + + let :params do { + :init_template => "elasticsearch/etc/init.d/elasticsearch.Debian.erb", + :restart_on_change => false + } end + + it { should contain_file('/etc/init.d/elasticsearch').without_notify } + + end + + context 'when its unmanaged do nothing with it' do + + let :params do { + :status => 'unmanaged' + } end + + it { should contain_service('elasticsearch').with(:ensure => nil, :enable => false) } + + end + + end # provider init + + end # Services + + context 'when setting the module to absent' do + + let :params do { + :ensure => 'absent' + } end + + it { should contain_file('/etc/elasticsearch').with(:ensure => 'absent', :force => true, :recurse => true) } + it { should contain_package('elasticsearch').with(:ensure => 'purged') } + it { should contain_service('elasticsearch').with(:ensure => 'stopped', :enable => false) } + + end + + end + + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/002_elasticsearch_init_redhat_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/002_elasticsearch_init_redhat_spec.rb new file mode 100644 index 0000000000..9151b20e6c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/002_elasticsearch_init_redhat_spec.rb @@ -0,0 +1,219 @@ +require 'spec_helper' + +describe 'elasticsearch', :type => 'class' do + + [ 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon', 'OracleLinux' ].each do |distro| + + context "on #{distro} OS" do + + let :facts do { + :operatingsystem => distro + } end + + context 'Main class' do + + # init.pp + it { should contain_class('elasticsearch::package') } + it { should contain_class('elasticsearch::config') } + it { should contain_class('elasticsearch::service') } + + end + + context 'package installation' do + + context 'via repository' do + + context 'with default settings' do + + it { should contain_package('elasticsearch').with(:ensure => 'present') } + + end + + context 'with specified version' do + + let :params do { + :version => '1.0' + } end + + it { should contain_package('elasticsearch').with(:ensure => '1.0') } + end + + context 'with auto upgrade enabled' do + + let :params do { + :autoupgrade => true + } end + + it { should contain_package('elasticsearch').with(:ensure => 'latest') } + end + + end + + context 'when setting package version and package_url' do + + let :params do { + :version => '0.90.10', + :package_url => 'puppet:///path/to/some/elasticsearch-0.90.10.rpm' + } end + + it { expect { should raise_error(Puppet::Error) } } + + end + + context 'via package_url setting' do + + context 'using puppet:/// schema' do + + let :params do { + :package_url => 'puppet:///path/to/package.rpm' + } end + + it { should contain_file('/var/lib/elasticsearch/package.rpm').with(:source => 'puppet:///path/to/package.rpm', :backup => false) } + it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.rpm', :provider => 'rpm') } + end + + context 'using http:// schema' do + + let :params do { + :package_url => 'http://www.domain.com/path/to/package.rpm' + } end + + it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') } + it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => "Exec[create_package_dir_elasticsearch]") } + it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.rpm http://www.domain.com/path/to/package.rpm 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') } + it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.rpm', :provider => 'rpm') } + end + + context 'using https:// schema' do + + let :params do { + :package_url => 'https://www.domain.com/path/to/package.rpm' + } end + + it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') } + it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') } + it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.rpm https://www.domain.com/path/to/package.rpm 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') } + it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.rpm', :provider => 'rpm') } + end + + context 'using ftp:// schema' do + + let :params do { + :package_url => 'ftp://www.domain.com/path/to/package.rpm' + } end + + it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') } + it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') } + it { should contain_exec('download_package_elasticsearch').with(:command => 'wget -O /var/lib/elasticsearch/package.rpm ftp://www.domain.com/path/to/package.rpm 2> /dev/null', :require => 'File[/var/lib/elasticsearch]') } + it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.rpm', :provider => 'rpm') } + end + + context 'using file:// schema' do + + let :params do { + :package_url => 'file:/path/to/package.rpm' + } end + + it { should contain_exec('create_package_dir_elasticsearch').with(:command => 'mkdir -p /var/lib/elasticsearch') } + it { should contain_file('/var/lib/elasticsearch').with(:purge => false, :force => false, :require => 'Exec[create_package_dir_elasticsearch]') } + it { should contain_file('/var/lib/elasticsearch/package.rpm').with(:source => '/path/to/package.rpm', :backup => false) } + it { should contain_package('elasticsearch').with(:ensure => 'present', :source => '/var/lib/elasticsearch/package.rpm', :provider => 'rpm') } + end + + end + + end # package + + context 'service setup' do + + context 'with provider \'init\'' do + + context 'and default settings' do + + it { should contain_service('elasticsearch').with(:ensure => 'running') } + + end + + context 'and set defaults via hash param' do + + let :params do { + :init_defaults => { 'SERVICE_USER' => 'root', 'SERVICE_GROUP' => 'root' } + } end + + it { should contain_file('/etc/sysconfig/elasticsearch').with(:content => "### MANAGED BY PUPPET ###\n\nSERVICE_GROUP=root\nSERVICE_USER=root\n", :notify => 'Service[elasticsearch]') } + + end + + context 'and set defaults via file param' do + + let :params do { + :init_defaults_file => 'puppet:///path/to/elasticsearch.defaults' + } end + + it { should contain_file('/etc/sysconfig/elasticsearch').with(:source => 'puppet:///path/to/elasticsearch.defaults', :notify => 'Service[elasticsearch]') } + + end + + context 'no service restart when defaults change' do + + let :params do { + :init_defaults => { 'SERVICE_USER' => 'root', 'SERVICE_GROUP' => 'root' }, + :restart_on_change => false + } end + + it { should contain_file('/etc/sysconfig/elasticsearch').with(:content => "### MANAGED BY PUPPET ###\n\nSERVICE_GROUP=root\nSERVICE_USER=root\n").without_notify } + + end + + context 'and set init file via template' do + + let :params do { + :init_template => "elasticsearch/etc/init.d/elasticsearch.RedHat.erb" + } end + + it { should contain_file('/etc/init.d/elasticsearch').with(:notify => 'Service[elasticsearch]') } + + end + + context 'No service restart when restart_on_change is false' do + + let :params do { + :init_template => "elasticsearch/etc/init.d/elasticsearch.RedHat.erb", + :restart_on_change => false + } end + + it { should contain_file('/etc/init.d/elasticsearch').without_notify } + + end + + context 'when its unmanaged do nothing with it' do + + let :params do { + :status => 'unmanaged' + } end + + it { should contain_service('elasticsearch').with(:ensure => nil, :enable => false) } + + end + + end + + end # Services + + context 'when setting the module to absent' do + + let :params do { + :ensure => 'absent' + } end + + it { should contain_file('/etc/elasticsearch').with(:ensure => 'absent', :force => true, :recurse => true) } + it { should contain_package('elasticsearch').with(:ensure => 'purged') } + it { should contain_service('elasticsearch').with(:ensure => 'stopped', :enable => false) } + + end + + end + + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/003_elasticsearch_init_unknown_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/003_elasticsearch_init_unknown_spec.rb new file mode 100644 index 0000000000..12bce8fef8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/003_elasticsearch_init_unknown_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe 'elasticsearch', :type => 'class' do + + context "on an unknown OS" do + + context "it should fail" do + let :facts do { + :operatingsystem => 'Windows' + } end + + it { expect { should raise_error(Puppet::Error) } } + + end + + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/004_elasticsearch_init_config_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/004_elasticsearch_init_config_spec.rb new file mode 100644 index 0000000000..2f01fb5b29 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/004_elasticsearch_init_config_spec.rb @@ -0,0 +1,112 @@ +require 'spec_helper' + +describe 'elasticsearch', :type => 'class' do + + let :facts do { + :operatingsystem => 'CentOS' + } end + + context "config file content" do + + context "with nothing set" do + + let :params do { + } end + + it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n") } + + end + + context "set a value" do + + let :params do { + :config => { 'node' => { 'name' => 'test' } } + } end + + it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nnode: \n name: test\n") } + + end + + context "set a value to true" do + + let :params do { + :config => { 'node' => { 'master' => true } } + } end + + it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nnode: \n master: true\n") } + + end + + context "set a value to false" do + + let :params do { + :config => { 'node' => { 'data' => false } } + } end + + it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nnode: \n data: false\n") } + + end + + context "deeper hash and multiple keys" do + + let :params do { + :config => { 'index' => { 'routing' => { 'allocation' => { 'include' => 'tag1', 'exclude' => [ 'tag2', 'tag3' ] } } }, 'node' => { 'name' => 'somename' } } + } end + + it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nindex: \n routing: \n allocation: \n exclude: \n - tag2\n - tag3\n include: tag1\nnode: \n name: somename\n") } + + end + + context "Combination of full hash and shorted write up keys" do + + let :params do { + :config => { 'node' => { 'name' => 'NodeName', 'rack' => 46 }, 'boostrap.mlockall' => true, 'cluster' => { 'name' => 'ClusterName', 'routing.allocation.awareness.attributes' => 'rack' }, 'discovery.zen' => { 'ping.unicast.hosts'=> [ "host1", "host2" ], 'minimum_master_nodes' => 3, 'ping.multicast.enabled' => false }, 'gateway' => { 'expected_nodes' => 4, 'recover_after_nodes' => 3 }, 'network.host' => '123.123.123.123' } + } end + + it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:content => "### MANAGED BY PUPPET ###\n---\nboostrap: \n mlockall: true\ncluster: \n name: ClusterName\n routing: \n allocation: \n awareness: \n attributes: rack\ndiscovery: \n zen: \n minimum_master_nodes: 3\n ping: \n multicast: \n enabled: false\n unicast: \n hosts: \n - host1\n - host2\ngateway: \n expected_nodes: 4\n recover_after_nodes: 3\nnetwork: \n host: 123.123.123.123\nnode: \n name: NodeName\n rack: 46\n") } + + end + + end + + context "service restarts" do + + let :facts do { + :operatingsystem => 'CentOS' + } end + + context "does not restart when restart_on_change is false" do + let :params do { + :config => { 'node' => { 'name' => 'test' } }, + :restart_on_change => false, + } end + + it { should contain_file('/etc/elasticsearch/elasticsearch.yml').without_notify } + end + + context "should happen restart_on_change is true (default)" do + let :params do { + :config => { 'node' => { 'name' => 'test' } }, + :restart_on_change => true, + } end + + it { should contain_file('/etc/elasticsearch/elasticsearch.yml').with(:notify => "Class[Elasticsearch::Service]") } + end + + end + + context 'data directory' do + let(:facts) do { + :operatingsystem => 'CentOS' + } end + + context 'should allow creating datadir' do + let(:params) do { + :datadir => '/foo' + } end + + it { should contain_file('/foo').with(:ensure => 'directory') } + end + + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/005_elasticsearch_java_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/005_elasticsearch_java_spec.rb new file mode 100644 index 0000000000..d51108746d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/classes/005_elasticsearch_java_spec.rb @@ -0,0 +1,120 @@ +require 'spec_helper' + +describe 'elasticsearch', :type => 'class' do + + context "install java" do + + let :params do { + :java_install => true, + :config => { 'node' => { 'name' => 'test' } } + } end + + context "On Debian OS" do + + let :facts do { + :operatingsystem => 'Debian' + } end + + it { should contain_package('openjdk-7-jre-headless') } + + end + + context "On Ubuntu OS" do + + let :facts do { + :operatingsystem => 'Ubuntu' + } end + + it { should contain_package('openjdk-7-jre-headless') } + + end + + context "On CentOS OS " do + + let :facts do { + :operatingsystem => 'CentOS' + } end + + it { should contain_package('java-1.7.0-openjdk') } + + end + + context "On RedHat OS " do + + let :facts do { + :operatingsystem => 'Redhat' + } end + + it { should contain_package('java-1.7.0-openjdk') } + + end + + context "On Fedora OS " do + + let :facts do { + :operatingsystem => 'Fedora' + } end + + it { should contain_package('java-1.7.0-openjdk') } + + end + + context "On Scientific OS " do + + let :facts do { + :operatingsystem => 'Scientific' + } end + + it { should contain_package('java-1.7.0-openjdk') } + + end + + context "On Amazon OS " do + + let :facts do { + :operatingsystem => 'Amazon' + } end + + it { should contain_package('java-1.7.0-openjdk') } + + end + + context "On OracleLinux OS " do + + let :facts do { + :operatingsystem => 'OracleLinux' + } end + + it { should contain_package('java-1.7.0-openjdk') } + + end + + context "On an unknown OS" do + + let :facts do { + :operatingsystem => 'Windows' + } end + + it { expect { should raise_error(Puppet::Error) } } + + end + + context "Custom java package" do + + let :facts do { + :operatingsystem => 'CentOS' + } end + + let :params do { + :java_install => true, + :java_package => 'java-1.6.0-openjdk', + :config => { 'node' => { 'name' => 'test' } } + } end + + it { should contain_package('java-1.6.0-openjdk') } + + end + + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/001_elasticsearch_python_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/001_elasticsearch_python_spec.rb new file mode 100644 index 0000000000..56d0428067 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/001_elasticsearch_python_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe 'elasticsearch::python', :type => 'define' do + + let(:facts) { {:operatingsystem => 'CentOS' }} + + [ 'pyes', 'rawes', 'pyelasticsearch', 'ESClient', 'elasticutils', 'elasticsearch' ].each do |pythonlib| + + context "installation of library #{pythonlib}" do + + let(:title) { pythonlib } + + it { should contain_package(pythonlib).with(:provider => 'pip') } + + end + + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/002_elasticsearch_ruby_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/002_elasticsearch_ruby_spec.rb new file mode 100644 index 0000000000..6de94f76b2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/002_elasticsearch_ruby_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe 'elasticsearch::ruby', :type => 'define' do + + let(:facts) { {:operatingsystem => 'CentOS' }} + + [ 'tire', 'stretcher', 'elastic_searchable', 'elasticsearch'].each do |rubylib| + + context "installation of library #{rubylib}" do + + let(:title) { rubylib } + + it { should contain_package(rubylib).with(:provider => 'gem') } + + end + + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/003_elasticsearch_template_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/003_elasticsearch_template_spec.rb new file mode 100644 index 0000000000..527fb118f0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/003_elasticsearch_template_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe 'elasticsearch::template', :type => 'define' do + + let(:title) { 'foo' } + let(:facts) { {:operatingsystem => 'CentOS' }} + let(:pre_condition) { 'class {"elasticsearch": config => { "node" => {"name" => "test" }}}'} + + context "Add a template" do + + let :params do { + :ensure => 'present', + :file => 'puppet:///path/to/foo.json', + } end + + it { should contain_file('/etc/elasticsearch/templates_import/elasticsearch-template-foo.json').with(:source => 'puppet:///path/to/foo.json', :notify => "Exec[delete_template_foo]", :require => "Exec[mkdir_templates]") } + it { should contain_exec('insert_template_foo').with(:command => 'curl -s -XPUT http://localhost:9200/_template/foo -d @/etc/elasticsearch/templates_import/elasticsearch-template-foo.json', :unless => 'test $(curl -s \'http://localhost:9200/_template/foo?pretty=true\' | wc -l) -gt 1') } + end + + context "Delete a template" do + + let :params do { + :ensure => 'absent' + } end + + it { should_not contain_file('/etc/elasticsearch/templates_import/elasticsearch-template-foo.json').with(:source => 'puppet:///path/to/foo.json') } + it { should_not contain_exec('insert_template_foo') } + it { should contain_exec('delete_template_foo').with(:command => 'curl -s -XDELETE http://localhost:9200/_template/foo', :notify => nil, :onlyif => 'test $(curl -s \'http://localhost:9200/_template/foo?pretty=true\' | wc -l) -gt 1' ) } + end + + context "Add template with alternative host and port" do + + let :params do { + :file => 'puppet:///path/to/foo.json', + :host => 'otherhost', + :port => '9201' + } end + + it { should contain_file('/etc/elasticsearch/templates_import/elasticsearch-template-foo.json').with(:source => 'puppet:///path/to/foo.json') } + it { should contain_exec('insert_template_foo').with(:command => 'curl -s -XPUT http://otherhost:9201/_template/foo -d @/etc/elasticsearch/templates_import/elasticsearch-template-foo.json', :unless => 'test $(curl -s \'http://otherhost:9201/_template/foo?pretty=true\' | wc -l) -gt 1') } + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/004_elasticsearch_plugin_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/004_elasticsearch_plugin_spec.rb new file mode 100644 index 0000000000..dcf2170ea7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/defines/004_elasticsearch_plugin_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe 'elasticsearch::plugin', :type => 'define' do + + let(:title) { 'mobz/elasticsearch-head' } + let(:facts) { {:operatingsystem => 'CentOS' }} + let(:pre_condition) { 'class {"elasticsearch": config => { "node" => {"name" => "test" }}}'} + + context "Add a plugin" do + + let :params do { + :ensure => 'present', + :module_dir => 'head', + } end + + it { should contain_exec('install_plugin_mobz/elasticsearch-head').with(:command => '/usr/share/elasticsearch/bin/plugin -install mobz/elasticsearch-head', :creates => '/usr/share/elasticsearch/plugins/head') } + end + + context "Remove a plugin" do + + let :params do { + :ensure => 'absent', + :module_dir => 'head' + } end + + it { should contain_exec('remove_plugin_mobz/elasticsearch-head').with(:command => '/usr/share/elasticsearch/bin/plugin --remove head', :onlyif => 'test -d /usr/share/elasticsearch/plugins/head') } + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/lib/parser_validate_task.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/lib/parser_validate_task.rb new file mode 100644 index 0000000000..27ab76450a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/lib/parser_validate_task.rb @@ -0,0 +1,40 @@ +require 'find' +require 'pathname' +require 'rake' +require 'rspec/core/rake_task' + +desc "run Puppet parser validate" +task :parser_validate do + + pwd = ENV["PWD"] + puppet_file_paths = [] + Find.find(pwd) do |path| + puppet_file_paths << path if path =~ /.*\.pp$/ + end + + exit_code = 0 + puppet_file_paths.each do |puppetfile| + + pwdpath = Pathname.new(pwd) + pn = Pathname.new(puppetfile) + rel_path = pn.relative_path_from(pwdpath) + + print "Validating #{rel_path}.... " + $stdout.flush + + result = `puppet parser validate #{puppetfile}` + if $?.exitstatus == 0 + res = 'OK' + else + res = 'ERR' + end + + puts "#{res}" + + if $?.exitstatus != 0 + exit_code = 1 + end + end + exit exit_code + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/lib/template_check_task.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/lib/template_check_task.rb new file mode 100644 index 0000000000..f4748236fb --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/lib/template_check_task.rb @@ -0,0 +1,31 @@ +require 'find' +require 'pathname' +require 'rake' +require 'rspec/core/rake_task' + +desc "Verify puppet templates" +task :template_verify do + + pwd = ENV["PWD"] + erb_file_paths = [] + Find.find(pwd) do |path| + erb_file_paths << path if path =~ /.*\.erb$/ + end + + exit_code = 0 + erb_file_paths.each do |erbfile| + + pwdpath = Pathname.new(pwd) + pn = Pathname.new(erbfile) + rel_path = pn.relative_path_from(pwdpath) + + result = `erb -P -x -T '-' #{erbfile} | ruby -c` + puts "Verifying #{rel_path}.... #{result}" + + if $?.exitstatus != 0 + exit_code = 1 + end + end + exit exit_code + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/spec_helper.rb new file mode 100644 index 0000000000..dc7e9f4a0e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/spec/spec_helper.rb @@ -0,0 +1,2 @@ +require 'rubygems' +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/elasticsearch/elasticsearch.yml.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/elasticsearch/elasticsearch.yml.erb new file mode 100644 index 0000000000..b93ccdcb21 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/elasticsearch/elasticsearch.yml.erb @@ -0,0 +1,93 @@ +<%- + + # Function to make a structured and sorted yaml representation out of a hash + def recursive_hash_to_yml_string(hash, depth=0) + spacer = "" + depth.times { spacer += " "} + hash.keys.sort.each do |sorted_key| + @yml_string += spacer + sorted_key + ": " + if hash[sorted_key].is_a?(Array) + keyspacer = "" + sorted_key.length.times { keyspacer += " " } + @yml_string += "\n" + hash[sorted_key].each do |item| + @yml_string += spacer + keyspacer + "- " + item +"\n" + end + elsif hash[sorted_key].is_a?(Hash) + @yml_string += "\n" + recursive_hash_to_yml_string(hash[sorted_key], depth+1) + else + @yml_string += "#{hash[sorted_key].to_s}\n" + end + end + end + + # Function to transform shorted write up of the keys into full hash representation + def transform(hash) + return_vals = [] + + hash.each do |key,val| + if m = /^([^.]+)\.(.*)$/.match(key) + temp = { m[1] => { m[2] => val } } + transform(temp).each do |stuff| + return_vals << stuff + end + else + if val.is_a?(Hash) + transform(val).each do |stuff| + return_vals << { key => stuff } + end + else + return_vals << { key => val } + end + end + end + + return_vals + end + + # Function to deep merge hashes with same keys + class ::Hash + def deep_merge_with_array_values_concatenated(hash) + target = dup + + hash.keys.each do |key| + if hash[key].is_a? Hash and self[key].is_a? Hash + target[key] = target[key].deep_merge_with_array_values_concatenated(hash[key]) + next + end + + if hash[key].is_a?(Array) && target[key].is_a?(Array) + target[key] = target[key] + hash[key] + else + target[key] = hash[key] + end + end + + target + end + end + + # initial string + @yml_string = "### MANAGED BY PUPPET ###\n" + + if !scope.lookupvar('elasticsearch::config').empty? + + @yml_string += "---\n" + + ## Transform shorted keys into full write up + transformed_config = transform(scope.lookupvar('elasticsearch::config')) + + # Merge it back into a hash + tmphash = { } + transformed_config.each do |subhash| + tmphash = tmphash.deep_merge_with_array_values_concatenated(subhash) + end + + # Transform it into yaml + recursive_hash_to_yml_string(tmphash) + + end + +-%> +<%= @yml_string -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/init.d/elasticsearch.Debian.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/init.d/elasticsearch.Debian.erb new file mode 100644 index 0000000000..220c2f80b7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/init.d/elasticsearch.Debian.erb @@ -0,0 +1,196 @@ +#!/bin/sh +# +# /etc/init.d/elasticsearch -- startup script for Elasticsearch +# +# Written by Miquel van Smoorenburg . +# Modified for Debian GNU/Linux by Ian Murdock . +# Modified for Tomcat by Stefan Gybas . +# Modified for Tomcat6 by Thierry Carrez . +# Additional improvements by Jason Brittain . +# Modified by Nicolas Huray for ElasticSearch . +# +### BEGIN INIT INFO +# Provides: elasticsearch +# Required-Start: $network $remote_fs $named +# Required-Stop: $network $remote_fs $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Starts elasticsearch +# Description: Starts elasticsearch using start-stop-daemon +### END INIT INFO + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +NAME=elasticsearch +DESC="ElasticSearch Server" +DEFAULT=/etc/default/$NAME + +if [ `id -u` -ne 0 ]; then + echo "You need root privileges to run this script" + exit 1 +fi + + +. /lib/lsb/init-functions + +if [ -r /etc/default/rcS ]; then + . /etc/default/rcS +fi + + +# The following variables can be overwritten in $DEFAULT + +# Run ElasticSearch as this user ID and group ID +ES_USER=elasticsearch +ES_GROUP=elasticsearch + +# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT) +JDK_DIRS="/usr/lib/jvm/java-7-oracle /usr/lib/jvm/java-7-openjdk /usr/lib/jvm/java-7-openjdk-amd64/ /usr/lib/jvm/java-7-openjdk-armhf /usr/lib/jvm/java-7-openjdk-i386/ /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-amd64 /usr/lib/jvm/java-6-openjdk-armhf /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/default-java" + +# Look for the right JVM to use +for jdir in $JDK_DIRS; do + if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then + JAVA_HOME="$jdir" + fi +done +export JAVA_HOME + +# Directory where the ElasticSearch binary distribution resides +ES_HOME=/usr/share/$NAME + +# Heap Size (defaults to 256m min, 1g max) +#ES_HEAP_SIZE=2g + +# Heap new generation +#ES_HEAP_NEWSIZE= + +# max direct memory +#ES_DIRECT_SIZE= + +# Additional Java OPTS +#ES_JAVA_OPTS= + +# Maximum number of open files +MAX_OPEN_FILES=65535 + +# Maximum amount of locked memory +#MAX_LOCKED_MEMORY= + +# ElasticSearch log directory +LOG_DIR=/var/log/$NAME + +# ElasticSearch data directory +DATA_DIR=/var/lib/$NAME + +# ElasticSearch work directory +WORK_DIR=/tmp/$NAME + +# ElasticSearch configuration directory +CONF_DIR=/etc/$NAME + +# ElasticSearch configuration file (elasticsearch.yml) +CONF_FILE=$CONF_DIR/elasticsearch.yml + +# End of variables that can be overwritten in $DEFAULT + +# overwrite settings from default file +if [ -f "$DEFAULT" ]; then + . "$DEFAULT" +fi + +# Define other required variables +PID_FILE=/var/run/$NAME.pid +DAEMON=$ES_HOME/bin/elasticsearch +DAEMON_OPTS="-p $PID_FILE -Des.default.config=$CONF_FILE -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR" + +export ES_HEAP_SIZE +export ES_HEAP_NEWSIZE +export ES_DIRECT_SIZE +export ES_JAVA_OPTS + +# Check DAEMON exists +test -x $DAEMON || exit 0 + +checkJava() { + if [ -x "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" + else + JAVA=`which java` + fi + + if [ ! -x "$JAVA" ]; then + echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME" + exit 1 + fi +} + +case "$1" in + start) + checkJava + + if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then + log_failure_msg "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set" + exit 1 + fi + + log_daemon_msg "Starting $DESC" + + pid=`pidofproc -p $PID_FILE elasticsearch` + if [ -n "$pid" ] ; then + log_begin_msg "Already running." + log_end_msg 0 + exit 0 + fi + + # Prepare environment + mkdir -p "$LOG_DIR" "$DATA_DIR" "$WORK_DIR" && chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR" "$WORK_DIR" + touch "$PID_FILE" && chown "$ES_USER":"$ES_GROUP" "$PID_FILE" + + if [ -n "$MAX_OPEN_FILES" ]; then + ulimit -n $MAX_OPEN_FILES + fi + + if [ -n "$MAX_LOCKED_MEMORY" ]; then + ulimit -l $MAX_LOCKED_MEMORY + fi + + # Start Daemon + start-stop-daemon --start -b --user "$ES_USER" -c "$ES_USER" --pidfile "$PID_FILE" --exec $DAEMON -- $DAEMON_OPTS + log_end_msg $? + ;; + stop) + log_daemon_msg "Stopping $DESC" + + if [ -f "$PID_FILE" ]; then + start-stop-daemon --stop --pidfile "$PID_FILE" \ + --user "$ES_USER" \ + --retry=TERM/20/KILL/5 >/dev/null + if [ $? -eq 1 ]; then + log_progress_msg "$DESC is not running but pid file exists, cleaning up" + elif [ $? -eq 3 ]; then + PID="`cat $PID_FILE`" + log_failure_msg "Failed to stop $DESC (pid $PID)" + exit 1 + fi + rm -f "$PID_FILE" + else + log_progress_msg "(not running)" + fi + log_end_msg 0 + ;; + status) + status_of_proc -p $PID_FILE elasticsearch elasticsearch && exit 0 || exit $? + ;; + restart|force-reload) + if [ -f "$PID_FILE" ]; then + $0 stop + sleep 1 + fi + $0 start + ;; + *) + log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}" + exit 1 + ;; +esac + +exit 0 diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/init.d/elasticsearch.RedHat.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/init.d/elasticsearch.RedHat.erb new file mode 100644 index 0000000000..8d611514a1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/init.d/elasticsearch.RedHat.erb @@ -0,0 +1,155 @@ +#!/bin/sh +# +# elasticsearch +# +# chkconfig: 2345 80 20 +# description: Starts and stops a single elasticsearch instance on this system +# + +### BEGIN INIT INFO +# Provides: Elasticsearch +# Required-Start: $network $named +# Required-Stop: $network $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: This service manages the elasticsearch daemon +# Description: Elasticsearch is a very scalable, schema-free and high-performance search solution supporting multi-tenancy and near realtime search. +### END INIT INFO + +# +# init.d / servicectl compatibility (openSUSE) +# +if [ -f /etc/rc.status ]; then + . /etc/rc.status + rc_reset +fi + +# +# Source function library. +# +if [ -f /etc/rc.d/init.d/functions ]; then + . /etc/rc.d/init.d/functions +fi + +exec="/usr/share/elasticsearch/bin/elasticsearch" +prog="elasticsearch" +pidfile=/var/run/elasticsearch/${prog}.pid + +[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +export ES_HEAP_SIZE +export ES_HEAP_NEWSIZE +export ES_DIRECT_SIZE +export ES_JAVA_OPTS + +lockfile=/var/lock/subsys/$prog + +# backwards compatibility for old config sysconfig files, pre 0.90.1 +if [ -n $USER ] && [ -z $ES_USER ] ; then + ES_USER=$USER +fi + +checkJava() { + if [ -x "$JAVA_HOME/bin/java" ]; then + JAVA="$JAVA_HOME/bin/java" + else + JAVA=$(which java) + fi + + if [ ! -x "$JAVA" ]; then + echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME" + exit 1 + fi +} + +start() { + checkJava + [ -x $exec ] || exit 5 + [ -f $CONF_FILE ] || exit 6 + if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then + echo "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set" + return 7 + fi + if [ -n "$MAX_OPEN_FILES" ]; then + ulimit -n $MAX_OPEN_FILES + fi + if [ -n "$MAX_LOCKED_MEMORY" ]; then + ulimit -l $MAX_LOCKED_MEMORY + fi + if [ -n "$WORK_DIR" ]; then + mkdir -p "$WORK_DIR" + chown "$ES_USER":"$ES_GROUP" "$WORK_DIR" + fi + echo -n $"Starting $prog: " + # if not running, start it up here, usually something like "daemon $exec" + daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR + retval=$? + echo + [ $retval -eq 0 ] && touch $lockfile + return $retval +} + +stop() { + echo -n $"Stopping $prog: " + # stop it here, often "killproc $prog" + killproc -p $pidfile $prog + retval=$? + echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval +} + +restart() { + stop + start +} + +reload() { + restart +} + +force_reload() { + restart +} + +rh_status() { + # run checks to determine if the service is running or use generic status + status -p $pidfile $prog +} + +rh_status_q() { + rh_status >/dev/null 2>&1 +} + + +case "$1" in + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 +esac +exit $? diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/sysconfig/defaults.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/sysconfig/defaults.erb new file mode 100644 index 0000000000..b4e8af62dc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/elasticsearch/templates/etc/sysconfig/defaults.erb @@ -0,0 +1,5 @@ +### MANAGED BY PUPPET ### + +<% scope.lookupvar('elasticsearch::init_defaults').sort.map do |key, value| -%> +<%= key %>=<%= value %> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._Gemfile new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._Gemfile differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._LICENSE new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._LICENSE differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._Modulefile new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._Modulefile differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._README.md new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._README.md differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._Rakefile new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._Rakefile differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._files b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._files new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._files differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._lib b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._lib new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._lib differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._manifests b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._manifests new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._manifests differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._metadata.json b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._metadata.json new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._metadata.json differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._spec b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._spec new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._spec differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._tests b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._tests new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/._tests differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/Gemfile new file mode 100644 index 0000000000..95c7a5dd0b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/Gemfile @@ -0,0 +1,15 @@ +source 'https://rubygems.org' + +group :development, :test do + gem 'rake', :require => false + gem 'rspec-puppet', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'puppet-lint', :require => false + gem 'rspec-system-puppet', '~>2.0.0' +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end \ No newline at end of file diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/LICENSE new file mode 100644 index 0000000000..009b66b6cc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/LICENSE @@ -0,0 +1,13 @@ +Copyright 2012-2014 Michael Stahnke + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/Modulefile new file mode 100644 index 0000000000..237d164011 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/Modulefile @@ -0,0 +1,8 @@ +name 'stahnma-epel' +version '0.1.0' +source 'http://github.com/stahnma/puppet-module-epel' +author 'stahnma' +license 'Apache License, Version 2.0' +summary 'Setup the EPEL package repo' +description 'Setup the EPEL package repo on Centos/RHEL et all' +project_page 'http://github.com/stahnma/puppet-module-epel' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/README.md new file mode 100644 index 0000000000..33b8727857 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/README.md @@ -0,0 +1,90 @@ +# Configure EPEL (Extra Repository for Enterprise Linux) + +# About +This module basically just mimics the epel-release rpm. The same repos are +enabled/disabled and the GPG key is imported. In the end you will end up with +the EPEL repos configured. + +The following Repos will be setup and enabled by default: + + * epel + +Other repositories that will setup but disabled (as per the epel-release setup) + + * epel-debuginfo + * epel-source + * epel-testing + * epel-testing-debuginfo + * epel-testing-source + +# Proxy +If you have an http proxy required to access the internet, you can use either +a class parameter in the _epel_ class, or edit the $proxy variable in the +params.pp file. By default no proxy is assumed. + +# Why? +I am a big fan of EPEL. I actually was one of the people who helped get it +going. I am also the owner of the epel-release package, so in general this +module should stay fairly up to date with the official upstream package. + +I just got sick of coding Puppet modules and basically having an assumption +that EPEL was setup or installed. I can now depend on this module instead. + +I realize it is fairly trivial to get EPEL setup. Every now-and-then however +the path to epel-release changes because something changes in the package (mass +rebuild, rpm build macros updates, etc). This module will bypass the changing +URL and just setup the package mirrors. + +This does mean that if you are looking for RPM macros that are normally +included with EPEL release, this will not have them. + +# Futher Information + +* [EPEL Wiki](http://fedoraproject.org/wiki/EPEL) +* [epel-release package information](http://mirrors.servercentral.net/fedora/epel/6/i386/repoview/epel-release.html) + +# Testing + +* This is commonly used on Puppet Enterprise 3.x +* This was tested using Puppet 3.3.0 on Centos5/6 +* This was tested using Puppet 3.1.1 on Amazon's AWS Linux +* I assume it will work on any RHEL variant (Amazon Linux is debatable as a variant) + +# Lifecycle +* No functionality has been introduced that should break Puppet 2.6 or 2.7, but I am no longer testing these versions of Puppet as they are end-of-lifed from Puppet Labs. + +## Unit tests + +Install the necessary gems + + bundle install + +Run the RSpec and puppet-lint tests + + bundle exec rake ci + +## System tests + +If you have Vagrant >=1.1.0 you can also run system tests: + + RSPEC_SET=centos-64-x64 bundle exec rake spec:system + +Available RSPEC_SET options are in .nodeset.yml + +# License +Apache Software License 2.0 + +# Author/Contributors + * Chad Metcalf + * Joseph Swick + * Matthaus Owens + * Michael Stahnke + * Michael Stahnke + * Pro Cabales + * Proletaryo Cabales + * Stefan Goethals + * Tim Rupp + * Trey Dockendorf + * Troy Bollinger + * Vlastimil Holer + * Ewoud Kohl van Wijngaarden diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/Rakefile new file mode 100644 index 0000000000..5a71d17767 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/Rakefile @@ -0,0 +1,17 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' +require 'rspec-system/rake_task' + +task :default do + sh %{rake -T} +end + +# Disable specific puppet-lint checks +PuppetLint.configuration.send("disable_80chars") +PuppetLint.configuration.send("disable_class_inherits_from_params_class") + +desc "Run rspec-puppet and puppet-lint tasks" +task :ci => [ + :lint, + :spec, +] diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/._RPM-GPG-KEY-EPEL-5 b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/._RPM-GPG-KEY-EPEL-5 new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/._RPM-GPG-KEY-EPEL-5 differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/._RPM-GPG-KEY-EPEL-6 b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/._RPM-GPG-KEY-EPEL-6 new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/._RPM-GPG-KEY-EPEL-6 differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/._RPM-GPG-KEY-EPEL-7 b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/._RPM-GPG-KEY-EPEL-7 new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/._RPM-GPG-KEY-EPEL-7 differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-5 b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-5 new file mode 100644 index 0000000000..5a13bb4f9f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-5 @@ -0,0 +1,30 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.2.6 (GNU/Linux) + +mQGiBEXopTIRBACZDBMOoFOakAjaxw1LXjeSvh/kmE35fU1rXfM7T0AV31NATCLF +l5CQiNDA4oWreDThg2Bf6+LIVTsGQb1V+XXuLak4Em5yTYwMTVB//4/nMxQEbpl/ +QB2XwlJ7EQ0vW+kiPDz/7pHJz1p1jADzd9sQQicMtzysS4qT2i5A23j0VwCg1PB/ +lpYqo0ZhWTrevxKMa1n34FcD/REavj0hSLQFTaKNLHRotRTF8V0BajjSaTkUT4uk +/RTaZ8Kr1mTosVtosqmdIAA2XHxi8ZLiVPPSezJjfElsSqOAxEKPL0djfpp2wrTm +l/1iVnX+PZH5DRKCbjdCMLDJhYap7YUhcPsMGSeUKrwmBCBJUPc6DhjFvyhA9IMl +1T0+A/9SKTv94ToP/JYoCTHTgnG5MoVNafisfe0wojP2mWU4gRk8X4dNGKMj6lic +vM6gne3hESyjcqZSmr7yELPPGhI9MNauJ6Ob8cTR2T12Fmv9w03DD3MnBstR6vhP +QcqZKhc5SJYYY7oVfxlSOfF4xfwcHQKoD5TOKwIAQ6T8jyFpKbQkRmVkb3JhIEVQ +RUwgPGVwZWxAZmVkb3JhcHJvamVjdC5vcmc+iGQEExECACQFAkXopTICGwMFCRLM +AwAGCwkIBwMCAxUCAwMWAgECHgECF4AACgkQEZzANiF1IfabmQCgzvE60MnHSOBa +ZXXF7uU2Vzu8EOkAoKg9h+j0NuNom6WUYZyJQt4zc5seuQINBEXopTYQCADapnR/ +blrJ8FhlgNPl0X9S3JE/kygPbNXIqne4XBVYisVp0uzNCRUxNZq30MpY027JCs2J +nL2fMpwvx33f0phU029vrIZKA3CmnnwVsjcWfMJOVPBmVN7m5bGU68F+PdRIcDsl +PMOWRLkTBZOGolLgIbM4719fqA8etewILrX6uPvRDwywV7/sPCFpRcfNNBUY+Zx3 +5bf4fnkaCKxgXgQS3AT+hGYhlzIqQVTkGNveHTnt4SSzgAqR9sSwQwqvEfVtYNeS +w5rDguLG41HQm1Hojv59HNYjH6F/S1rClZi21bLgZbKpCFX76qPt8CTw+iQLBPPd +yoOGHfzyp7nsfhUrAAMFB/9/H9Gpk822ZpBexQW4y3LGFo9ZSnmu+ueOZPU3SqDA +DW1ovZdYzGuJTGGM9oMl6bL8eZrcUBBOFaWge5wZczIE3hx2exEOkDdvq+MUDVD1 +axmN45q/7h1NYRp5GQL2ZsoV4g9U2gMdzHOFtZCER6PP9ErVlfJpgBUCdSL93V4H +Sgpkk7znmTOklbCM6l/G/A6q4sCRqfzHwVSTiruyTBiU9lfROsAl8fjIq2OzWJ2T +P9sadBe1llUYaow7txYSUxssW+89avct35gIyrBbof5M+CBXyAOUaSWmpM2eub24 +0qbqiSr/Y6Om0t6vSzR8gRk7g+1H6IE0Tt1IJCvCAMimiE8EGBECAA8FAkXopTYC +GwwFCRLMAwAACgkQEZzANiF1IfZQYgCgiZHCv4xb+sTHCn/otc1Ovvi/OgMAnRXY +bbsLFWOfmzAnNIGvFRWy+YHi +=MMNL +-----END PGP PUBLIC KEY BLOCK----- diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-6 b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-6 new file mode 100644 index 0000000000..7a2030489d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-6 @@ -0,0 +1,29 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.5 (GNU/Linux) + +mQINBEvSKUIBEADLGnUj24ZVKW7liFN/JA5CgtzlNnKs7sBg7fVbNWryiE3URbn1 +JXvrdwHtkKyY96/ifZ1Ld3lE2gOF61bGZ2CWwJNee76Sp9Z+isP8RQXbG5jwj/4B +M9HK7phktqFVJ8VbY2jfTjcfxRvGM8YBwXF8hx0CDZURAjvf1xRSQJ7iAo58qcHn +XtxOAvQmAbR9z6Q/h/D+Y/PhoIJp1OV4VNHCbCs9M7HUVBpgC53PDcTUQuwcgeY6 +pQgo9eT1eLNSZVrJ5Bctivl1UcD6P6CIGkkeT2gNhqindRPngUXGXW7Qzoefe+fV +QqJSm7Tq2q9oqVZ46J964waCRItRySpuW5dxZO34WM6wsw2BP2MlACbH4l3luqtp +Xo3Bvfnk+HAFH3HcMuwdaulxv7zYKXCfNoSfgrpEfo2Ex4Im/I3WdtwME/Gbnwdq +3VJzgAxLVFhczDHwNkjmIdPAlNJ9/ixRjip4dgZtW8VcBCrNoL+LhDrIfjvnLdRu +vBHy9P3sCF7FZycaHlMWP6RiLtHnEMGcbZ8QpQHi2dReU1wyr9QgguGU+jqSXYar +1yEcsdRGasppNIZ8+Qawbm/a4doT10TEtPArhSoHlwbvqTDYjtfV92lC/2iwgO6g +YgG9XrO4V8dV39Ffm7oLFfvTbg5mv4Q/E6AWo/gkjmtxkculbyAvjFtYAQARAQAB +tCFFUEVMICg2KSA8ZXBlbEBmZWRvcmFwcm9qZWN0Lm9yZz6JAjYEEwECACAFAkvS +KUICGw8GCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRA7Sd8qBgi4lR/GD/wLGPv9 +qO39eyb9NlrwfKdUEo1tHxKdrhNz+XYrO4yVDTBZRPSuvL2yaoeSIhQOKhNPfEgT +9mdsbsgcfmoHxmGVcn+lbheWsSvcgrXuz0gLt8TGGKGGROAoLXpuUsb1HNtKEOwP +Q4z1uQ2nOz5hLRyDOV0I2LwYV8BjGIjBKUMFEUxFTsL7XOZkrAg/WbTH2PW3hrfS +WtcRA7EYonI3B80d39ffws7SmyKbS5PmZjqOPuTvV2F0tMhKIhncBwoojWZPExft +HpKhzKVh8fdDO/3P1y1Fk3Cin8UbCO9MWMFNR27fVzCANlEPljsHA+3Ez4F7uboF +p0OOEov4Yyi4BEbgqZnthTG4ub9nyiupIZ3ckPHr3nVcDUGcL6lQD/nkmNVIeLYP +x1uHPOSlWfuojAYgzRH6LL7Idg4FHHBA0to7FW8dQXFIOyNiJFAOT2j8P5+tVdq8 +wB0PDSH8yRpn4HdJ9RYquau4OkjluxOWf0uRaS//SUcCZh+1/KBEOmcvBHYRZA5J +l/nakCgxGb2paQOzqqpOcHKvlyLuzO5uybMXaipLExTGJXBlXrbbASfXa/yGYSAG +iVrGz9CE6676dMlm8F+s3XXE13QZrXmjloc6jwOljnfAkjTGXjiB7OULESed96MR +XtfLk0W5Ab9pd7tKDR6QHI7rgHXfCopRnZ2VVQ== +=V/6I +-----END PGP PUBLIC KEY BLOCK----- diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-7 b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-7 new file mode 100644 index 0000000000..f205ede463 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/files/RPM-GPG-KEY-EPEL-7 @@ -0,0 +1,29 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.11 (GNU/Linux) + +mQINBFKuaIQBEAC1UphXwMqCAarPUH/ZsOFslabeTVO2pDk5YnO96f+rgZB7xArB +OSeQk7B90iqSJ85/c72OAn4OXYvT63gfCeXpJs5M7emXkPsNQWWSju99lW+AqSNm +jYWhmRlLRGl0OO7gIwj776dIXvcMNFlzSPj00N2xAqjMbjlnV2n2abAE5gq6VpqP +vFXVyfrVa/ualogDVmf6h2t4Rdpifq8qTHsHFU3xpCz+T6/dGWKGQ42ZQfTaLnDM +jToAsmY0AyevkIbX6iZVtzGvanYpPcWW4X0RDPcpqfFNZk643xI4lsZ+Y2Er9Yu5 +S/8x0ly+tmmIokaE0wwbdUu740YTZjCesroYWiRg5zuQ2xfKxJoV5E+Eh+tYwGDJ +n6HfWhRgnudRRwvuJ45ztYVtKulKw8QQpd2STWrcQQDJaRWmnMooX/PATTjCBExB +9dkz38Druvk7IkHMtsIqlkAOQMdsX1d3Tov6BE2XDjIG0zFxLduJGbVwc/6rIc95 +T055j36Ez0HrjxdpTGOOHxRqMK5m9flFbaxxtDnS7w77WqzW7HjFrD0VeTx2vnjj +GqchHEQpfDpFOzb8LTFhgYidyRNUflQY35WLOzLNV+pV3eQ3Jg11UFwelSNLqfQf +uFRGc+zcwkNjHh5yPvm9odR1BIfqJ6sKGPGbtPNXo7ERMRypWyRz0zi0twARAQAB +tChGZWRvcmEgRVBFTCAoNykgPGVwZWxAZmVkb3JhcHJvamVjdC5vcmc+iQI4BBMB +AgAiBQJSrmiEAhsPBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRBqL66iNSxk +5cfGD/4spqpsTjtDM7qpytKLHKruZtvuWiqt5RfvT9ww9GUUFMZ4ZZGX4nUXg49q +ixDLayWR8ddG/s5kyOi3C0uX/6inzaYyRg+Bh70brqKUK14F1BrrPi29eaKfG+Gu +MFtXdBG2a7OtPmw3yuKmq9Epv6B0mP6E5KSdvSRSqJWtGcA6wRS/wDzXJENHp5re +9Ism3CYydpy0GLRA5wo4fPB5uLdUhLEUDvh2KK//fMjja3o0L+SNz8N0aDZyn5Ax +CU9RB3EHcTecFgoy5umRj99BZrebR1NO+4gBrivIfdvD4fJNfNBHXwhSH9ACGCNv +HnXVjHQF9iHWApKkRIeh8Fr2n5dtfJEF7SEX8GbX7FbsWo29kXMrVgNqHNyDnfAB +VoPubgQdtJZJkVZAkaHrMu8AytwT62Q4eNqmJI1aWbZQNI5jWYqc6RKuCK6/F99q +thFT9gJO17+yRuL6Uv2/vgzVR1RGdwVLKwlUjGPAjYflpCQwWMAASxiv9uPyYPHc +ErSrbRG0wjIfAR3vus1OSOx3xZHZpXFfmQTsDP7zVROLzV98R3JwFAxJ4/xqeON4 +vCPFU6OsT3lWQ8w7il5ohY95wmujfr6lk89kEzJdOTzcn7DBbUru33CQMGKZ3Evt +RjsC7FDbL017qxS+ZVA/HGkyfiu4cpgV8VUnbql5eAZ+1Ll6Dw== +=hdPa +-----END PGP PUBLIC KEY BLOCK----- diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/lib/._facter b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/lib/._facter new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/lib/._facter differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/lib/facter/._os_maj_version.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/lib/facter/._os_maj_version.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/lib/facter/._os_maj_version.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/lib/facter/os_maj_version.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/lib/facter/os_maj_version.rb new file mode 100644 index 0000000000..ba5cb84043 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/lib/facter/os_maj_version.rb @@ -0,0 +1,11 @@ +# This is a simple fact to get the Major version of an OS without having to +# have the entire LSB suite installed. LSB seems to pull in about 300 megs of +# stuff I often don't require. This fact is quick to load so it shouldn't be +# much of an issue. + +Facter.add(:os_maj_version) do + setcode do + v = Facter.value(:operatingsystemrelease) + v.split('.')[0].strip + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/._init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/._init.pp new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/._init.pp differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/._params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/._params.pp new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/._params.pp differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/._rpm_gpg_key.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/._rpm_gpg_key.pp new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/._rpm_gpg_key.pp differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/init.pp new file mode 100644 index 0000000000..f9f4be114a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/init.pp @@ -0,0 +1,135 @@ +# Class epel +# +# Actions: +# Configure the proper repositories and import GPG keys +# +# Reqiures: +# You should probably be on an Enterprise Linux variant. (Centos, RHEL, +# Scientific, Oracle, Ascendos, et al) +# +# Sample Usage: +# include epel +# +class epel ( + $epel_mirrorlist = $epel::params::epel_mirrorlist, + $epel_baseurl = $epel::params::epel_baseurl, + $epel_failovermethod = $epel::params::epel_failovermethod, + $epel_proxy = $epel::params::epel_proxy, + $epel_enabled = $epel::params::epel_enabled, + $epel_gpgcheck = $epel::params::epel_gpgcheck, + $epel_testing_baseurl = $epel::params::epel_testing_baseurl, + $epel_testing_failovermethod = $epel::params::epel_testing_failovermethod, + $epel_testing_proxy = $epel::params::epel_testing_proxy, + $epel_testing_enabled = $epel::params::epel_testing_enabled, + $epel_testing_gpgcheck = $epel::params::epel_testing_gpgcheck, + $epel_source_mirrorlist = $epel::params::epel_source_mirrorlist, + $epel_source_baseurl = $epel::params::epel_source_baseurl, + $epel_source_failovermethod = $epel::params::epel_source_failovermethod, + $epel_source_proxy = $epel::params::epel_source_proxy, + $epel_source_enabled = $epel::params::epel_source_enabled, + $epel_source_gpgcheck = $epel::params::epel_source_gpgcheck, + $epel_debuginfo_mirrorlist = $epel::params::epel_debuginfo_mirrorlist, + $epel_debuginfo_baseurl = $epel::params::epel_debuginfo_baseurl, + $epel_debuginfo_failovermethod = $epel::params::epel_debuginfo_failovermethod, + $epel_debuginfo_proxy = $epel::params::epel_debuginfo_proxy, + $epel_debuginfo_enabled = $epel::params::epel_debuginfo_enabled, + $epel_debuginfo_gpgcheck = $epel::params::epel_debuginfo_gpgcheck, + $epel_testing_source_baseurl = $epel::params::epel_testing_source_baseurl, + $epel_testing_source_failovermethod = $epel::params::epel_testing_source_failovermethod, + $epel_testing_source_proxy = $epel::params::epel_testing_source_proxy, + $epel_testing_source_enabled = $epel::params::epel_testing_source_enabled, + $epel_testing_source_gpgcheck = $epel::params::epel_testing_source_gpgcheck, + $epel_testing_debuginfo_baseurl = $epel::params::epel_testing_debuginfo_baseurl, + $epel_testing_debuginfo_failovermethod = $epel::params::epel_testing_debuginfo_failovermethod, + $epel_testing_debuginfo_proxy = $epel::params::epel_testing_debuginfo_proxy, + $epel_testing_debuginfo_enabled = $epel::params::epel_testing_debuginfo_enabled, + $epel_testing_debuginfo_gpgcheck = $epel::params::epel_testing_debuginfo_gpgcheck +) inherits epel::params { + + if $::osfamily == 'RedHat' and $::operatingsystem !~ /Fedora|Amazon/ { + yumrepo { 'epel-testing': + baseurl => $epel_testing_baseurl, + failovermethod => $epel_testing_failovermethod, + proxy => $epel_testing_proxy, + enabled => $epel_testing_enabled, + gpgcheck => $epel_testing_gpgcheck, + gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::os_maj_version}", + descr => "Extra Packages for Enterprise Linux ${::os_maj_version} - Testing - \$basearch ", + } + + yumrepo { 'epel-testing-debuginfo': + baseurl => $epel_testing_debuginfo_baseurl, + failovermethod => $epel_testing_debuginfo_failovermethod, + proxy => $epel_testing_debuginfo_proxy, + enabled => $epel_testing_debuginfo_enabled, + gpgcheck => $epel_testing_debuginfo_gpgcheck, + gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::os_maj_version}", + descr => "Extra Packages for Enterprise Linux ${::os_maj_version} - Testing - \$basearch - Debug", + } + + yumrepo { 'epel-testing-source': + baseurl => $epel_testing_source_baseurl, + failovermethod => $epel_testing_source_failovermethod, + proxy => $epel_testing_source_proxy, + enabled => $epel_testing_source_enabled, + gpgcheck => $epel_testing_source_gpgcheck, + gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::os_maj_version}", + descr => "Extra Packages for Enterprise Linux ${::os_maj_version} - Testing - \$basearch - Source", + } + + yumrepo { 'epel': + mirrorlist => $epel_mirrorlist, + baseurl => $epel_baseurl, + failovermethod => $epel_failovermethod, + proxy => $epel_proxy, + enabled => $epel_enabled, + gpgcheck => $epel_gpgcheck, + gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::os_maj_version}", + descr => "Extra Packages for Enterprise Linux ${::os_maj_version} - \$basearch", + } + + yumrepo { 'epel-debuginfo': + mirrorlist => $epel_debuginfo_mirrorlist, + baseurl => $epel_debuginfo_baseurl, + failovermethod => $epel_debuginfo_failovermethod, + proxy => $epel_debuginfo_proxy, + enabled => $epel_debuginfo_enabled, + gpgcheck => $epel_debuginfo_gpgcheck, + gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::os_maj_version}", + descr => "Extra Packages for Enterprise Linux ${::os_maj_version} - \$basearch - Debug", + } + + yumrepo { 'epel-source': + mirrorlist => $epel_source_mirrorlist, + baseurl => $epel_source_baseurl, + failovermethod => $epel_source_failovermethod, + proxy => $epel_source_proxy, + enabled => $epel_source_enabled, + gpgcheck => $epel_source_gpgcheck, + gpgkey => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::os_maj_version}", + descr => "Extra Packages for Enterprise Linux ${::os_maj_version} - \$basearch - Source", + } + + file { "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::os_maj_version}": + ensure => present, + owner => 'root', + group => 'root', + mode => '0644', + source => "puppet:///modules/epel/RPM-GPG-KEY-EPEL-${::os_maj_version}", + } + + epel::rpm_gpg_key{ "EPEL-${::os_maj_version}": + path => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-${::os_maj_version}", + before => Yumrepo['epel','epel-source','epel-debuginfo','epel-testing','epel-testing-source','epel-testing-debuginfo'], + } + + } elsif $::osfamily == 'RedHat' and $::operatingsystem == 'Amazon' { + yumrepo { 'epel': + enabled => $epel_enabled, + gpgcheck => $epel_gpgcheck, + } + } else { + notice ("Your operating system ${::operatingsystem} will not have the EPEL repository applied") + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/params.pp new file mode 100644 index 0000000000..0939de9045 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/params.pp @@ -0,0 +1,45 @@ +# Optional parameters in setting up EPEL +class epel::params { + # Setting to 'absent' will fall back to the yum.conf + # Setting proxy here will be the default for all repos. + # + # If you wish to set a proxy for an individual set of repos, + # you can declare $proxy in that class, and should scope to + # the most specific declaration of proxy. + $proxy = 'absent' + + $epel_mirrorlist = "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-${::os_maj_version}&arch=\$basearch" + $epel_baseurl = 'absent' + $epel_failovermethod = 'priority' + $epel_proxy = $proxy + $epel_enabled = '1' + $epel_gpgcheck = '1' + $epel_testing_baseurl = "http://download.fedoraproject.org/pub/epel/testing/${::os_maj_version}/\$basearch" + $epel_testing_failovermethod = 'priority' + $epel_testing_proxy = $proxy + $epel_testing_enabled = '0' + $epel_testing_gpgcheck = '1' + $epel_source_mirrorlist = "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-${::os_maj_version}&arch=\$basearch" + $epel_source_baseurl = 'absent' + $epel_source_failovermethod = 'priority' + $epel_source_proxy = $proxy + $epel_source_enabled = '0' + $epel_source_gpgcheck = '1' + $epel_debuginfo_mirrorlist = "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-${::os_maj_version}&arch=\$basearch" + $epel_debuginfo_baseurl = 'absent' + $epel_debuginfo_failovermethod = 'priority' + $epel_debuginfo_proxy = $proxy + $epel_debuginfo_enabled = '0' + $epel_debuginfo_gpgcheck = '1' + $epel_testing_source_baseurl = "http://download.fedoraproject.org/pub/epel/testing/${::os_maj_version}/SRPMS" + $epel_testing_source_failovermethod = 'priority' + $epel_testing_source_proxy = $proxy + $epel_testing_source_enabled = '0' + $epel_testing_source_gpgcheck = '1' + $epel_testing_debuginfo_baseurl = "http://download.fedoraproject.org/pub/epel/testing/${::os_maj_version}/\$basearch/debug" + $epel_testing_debuginfo_failovermethod = 'priority' + $epel_testing_debuginfo_proxy = $proxy + $epel_testing_debuginfo_enabled = '0' + $epel_testing_debuginfo_gpgcheck = '1' + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/rpm_gpg_key.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/rpm_gpg_key.pp new file mode 100644 index 0000000000..ee0604dbbf --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/manifests/rpm_gpg_key.pp @@ -0,0 +1,28 @@ +# Define epel::rpm_gpg_key +# +# Actions: +# Import a RPM gpg key +# +# Parameters: +# +# [*path*] +# Path of the RPM GPG key to import +# +# Reqiures: +# You should probably be on an Enterprise Linux variant. (Centos, RHEL, Scientific, Oracle, Ascendos, et al) +# +# Sample Usage: +# epel::rpm_gpg_key{ "EPEL-6": +# path => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6" +# } +# +define epel::rpm_gpg_key($path) { + # Given the path to a key, see if it is imported, if not, import it + exec { "import-${name}": + path => '/bin:/usr/bin:/sbin:/usr/sbin', + command => "rpm --import ${path}", + unless => "rpm -q gpg-pubkey-$(echo $(gpg --throw-keyids < ${path}) | cut --characters=11-18 | tr '[A-Z]' '[a-z]')", + require => File[$path], + logoutput => 'on_failure', + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/metadata.json b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/metadata.json new file mode 100644 index 0000000000..ba8770e8b6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/metadata.json @@ -0,0 +1,45 @@ +{ + "name": "stahnma-epel", + "version": "0.1.0", + "source": "http://github.com/stahnma/puppet-module-epel", + "author": "stahnma", + "license": "Apache License, Version 2.0", + "summary": "Setup the EPEL package repo", + "description": "Setup the EPEL package repo on Centos/RHEL et all", + "project_page": "http://github.com/stahnma/puppet-module-epel", + "dependencies": [ + + ], + "types": [ + + ], + "checksums": { + "Gemfile": "3189476f30a99858b367d955298fe469", + "LICENSE": "94f0b1430ad7e59227ccabf8232f81d5", + "Modulefile": "250a4370b189d3f2e68ffd359ee02bb5", + "README.md": "6b4c4d2e7f0f9c1b6197529fa1120c88", + "Rakefile": "946eced163d7f8e0da85bda4baa7fa9c", + "files/RPM-GPG-KEY-EPEL-5": "0466c259781def56dafe0a2cdc9de0c5", + "files/RPM-GPG-KEY-EPEL-6": "d865e6b948a74cb03bc3401c0b01b785", + "files/RPM-GPG-KEY-EPEL-7": "58fa8ae27c89f37b08429f04fd4a88cc", + "lib/facter/os_maj_version.rb": "806fb856251b605df379e973c716a41c", + "manifests/init.pp": "61856de8db1eb00700e0a9a93aea506f", + "manifests/params.pp": "4fb2e283b4ba6e41abd7a914bdd001b8", + "manifests/rpm_gpg_key.pp": "69086f12752a14b200e462afaa59a93c", + "spec/classes/epel_spec.rb": "7e8e5973fdccb866e91ed00a3fd0af4c", + "spec/classes/shared_base.rb": "a6a46eb7225a1814b9343f32190ba75b", + "spec/classes/shared_debuginfo.rb": "1bd23934bc1f7d14d2491c7741f10299", + "spec/classes/shared_gpgkey.rb": "38a62fe24acfc9cc8d740d242c9f1c85", + "spec/classes/shared_source.rb": "6581989ed1ca2edd589ed98ecb08bdfa", + "spec/classes/shared_testing.rb": "50e936b9cf241c9849cf551961492532", + "spec/classes/shared_testing_debuginfo.rb": "41e8a2215d347246ff241f1b3a819c91", + "spec/classes/shared_testing_source.rb": "8cd827b2cb0b08b1633d70784417f946", + "spec/defines/rpm_gpg_key_spec.rb": "489fa716eaa2aba013089a6cf552c5a6", + "spec/spec_helper.rb": "a5ad64bd67aa3fe2512fa7ba505c8e8b", + "spec/spec_helper_system.rb": "d24a7ffdf4b67dbbd3ef5687292f51cf", + "spec/system/basic_spec.rb": "bc475b95f390134b31d905590bf8b039", + "spec/system/usage_spec.rb": "04506df5627ecbe975acd1fd0407ae40", + "spec/unit/facter/os_maj_version_spec.rb": "67ab2730991d4a8430f1115aad46bcea", + "tests/init.pp": "7c69b7adf2ba141cb62cfc9e0704d59e" + } +} \ No newline at end of file diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._classes b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._classes new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._classes differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._defines b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._defines new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._defines differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._spec_helper.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._spec_helper.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._spec_helper_system.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._spec_helper_system.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._spec_helper_system.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._system b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._system new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._system differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._unit b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._unit new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/._unit differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._epel_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._epel_spec.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._epel_spec.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_base.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_base.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_base.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_debuginfo.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_debuginfo.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_debuginfo.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_gpgkey.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_gpgkey.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_gpgkey.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_source.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_source.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_source.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_testing.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_testing.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_testing.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_testing_debuginfo.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_testing_debuginfo.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_testing_debuginfo.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_testing_source.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_testing_source.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/._shared_testing_source.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/epel_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/epel_spec.rb new file mode 100644 index 0000000000..5d95a61a5f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/epel_spec.rb @@ -0,0 +1,80 @@ +require 'spec_helper' +require 'classes/shared_gpgkey' +require 'classes/shared_base' +require 'classes/shared_source' +require 'classes/shared_debuginfo' +require 'classes/shared_testing' +require 'classes/shared_testing_source' +require 'classes/shared_testing_debuginfo' + +describe 'epel' do + it { should create_class('epel') } + it { should contain_class('epel::params') } + + context "operatingsystem => #{default_facts[:operatingsystem]}" do + context 'os_maj_version => 6' do + include_context :base_6 + include_context :gpgkey_6 + include_context :epel_source_6 + include_context :epel_debuginfo_6 + include_context :epel_testing_6 + include_context :epel_testing_source_6 + include_context :epel_testing_debuginfo_6 + + let :facts do + default_facts.merge({ + :operatingsystemrelease => '6.4', + :os_maj_version => '6', + }) + end + + context 'epel_baseurl => http://example.com/epel/6/x86_64' do + let(:params) {{ :epel_baseurl => "http://example.com/epel/6/x86_64" }} + it { should contain_yumrepo('epel').with('baseurl' => 'http://example.com/epel/6/x86_64') } + end + + context 'epel_mirrorlist => absent' do + let(:params) {{ :epel_mirrorlist => 'absent' }} + it { should contain_yumrepo('epel').with('mirrorlist' => 'absent') } + end + end + + context 'os_maj_version => 5' do + include_context :base_5 + include_context :gpgkey_5 + include_context :epel_source_5 + include_context :epel_debuginfo_5 + include_context :epel_testing_5 + include_context :epel_testing_source_5 + include_context :epel_testing_debuginfo_5 + + let :facts do + default_facts.merge({ + :operatingsystemrelease => '5.9', + :os_maj_version => '5', + }) + end + end + end + + context 'operatingsystem => Amazon' do + let :facts do + default_facts.merge({ + :operatingsystem => 'Amazon', + }) + end + + it { should_not contain_yumrepo('epel-testing') } + it { should_not contain_yumrepo('epel-testing-debuginfo') } + it { should_not contain_yumrepo('epel-testing-source') } + it { should_not contain_yumrepo('epel-debuginfo') } + it { should_not contain_yumrepo('epel-source') } + + it do + should contain_yumrepo('epel').with({ + 'enabled' => '1', + 'gpgcheck' => '1', + }) + end + end +end \ No newline at end of file diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_base.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_base.rb new file mode 100644 index 0000000000..89b3c58cca --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_base.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +shared_context :base do + it do + should contain_yumrepo('epel').with({ + 'failovermethod' => 'priority', + 'proxy' => 'absent', + 'enabled' => '1', + 'gpgcheck' => '1', + }) + end +end + +shared_context :base_6 do + include_context :base + + it do + should contain_yumrepo('epel').with({ + 'mirrorlist' => "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=$basearch", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", + 'descr' => "Extra Packages for Enterprise Linux 6 - $basearch", + }) + end +end + +shared_context :base_5 do + include_context :base + + it do + should contain_yumrepo('epel').with({ + 'mirrorlist' => "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", + 'descr' => "Extra Packages for Enterprise Linux 5 - $basearch", + }) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_debuginfo.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_debuginfo.rb new file mode 100644 index 0000000000..d47934d142 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_debuginfo.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +shared_context :epel_debuginfo do + it do + should contain_yumrepo('epel-debuginfo').with({ + 'proxy' => 'absent', + 'failovermethod' => 'priority', + 'enabled' => '0', + 'gpgcheck' => '1', + }) + end +end + +shared_context :epel_debuginfo_6 do + include_context :epel_debuginfo + + it do + should contain_yumrepo('epel-debuginfo').with({ + 'mirrorlist' => "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-6&arch=$basearch", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", + 'descr' => "Extra Packages for Enterprise Linux 6 - $basearch - Debug", + }) + end +end + +shared_context :epel_debuginfo_5 do + include_context :epel_debuginfo + + it do + should contain_yumrepo('epel-debuginfo').with({ + 'mirrorlist' => "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=$basearch", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", + 'descr' => "Extra Packages for Enterprise Linux 5 - $basearch - Debug", + }) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_gpgkey.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_gpgkey.rb new file mode 100644 index 0000000000..8b79c8cdd7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_gpgkey.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +shared_context :gpgkey_6 do + it do + should contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6").with({ + 'ensure' => 'present', + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'source' => "puppet:///modules/epel/RPM-GPG-KEY-EPEL-6", + }) + end + + it do + should contain_epel__rpm_gpg_key("EPEL-6").with({ + 'path' => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6" + }) + end +end + +shared_context :gpgkey_5 do + it do + should contain_file("/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5").with({ + 'ensure' => 'present', + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0644', + 'source' => "puppet:///modules/epel/RPM-GPG-KEY-EPEL-5", + }) + end + + it do + should contain_epel__rpm_gpg_key("EPEL-5").with({ + 'path' => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5" + }) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_source.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_source.rb new file mode 100644 index 0000000000..c371465ba9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_source.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +shared_context :epel_source do + it do + should contain_yumrepo('epel-source').with({ + 'proxy' => 'absent', + 'failovermethod' => 'priority', + 'enabled' => '0', + 'gpgcheck' => '1', + }) + end +end + +shared_context :epel_source_6 do + include_context :epel_source + + it do + should contain_yumrepo('epel-source').with({ + 'mirrorlist' => "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-6&arch=$basearch", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", + 'descr' => "Extra Packages for Enterprise Linux 6 - $basearch - Source", + }) + end +end + +shared_context :epel_source_5 do + include_context :epel_source + + it do + should contain_yumrepo('epel-source').with({ + 'mirrorlist' => "http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-5&arch=$basearch", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", + 'descr' => "Extra Packages for Enterprise Linux 5 - $basearch - Source", + }) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_testing.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_testing.rb new file mode 100644 index 0000000000..d560edb6e0 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_testing.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +shared_context :epel_testing do + it do + should contain_yumrepo('epel-testing').with({ + 'failovermethod' => 'priority', + 'proxy' => 'absent', + 'enabled' => '0', + 'gpgcheck' => '1', + }) + end +end + +shared_context :epel_testing_6 do + include_context :epel_testing + + it do + should contain_yumrepo('epel-testing').with({ + 'baseurl' => "http://download.fedoraproject.org/pub/epel/testing/6/$basearch", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", + 'descr' => "Extra Packages for Enterprise Linux 6 - Testing - $basearch ", + }) + end +end + +shared_context :epel_testing_5 do + include_context :epel_testing + + it do + should contain_yumrepo('epel-testing').with({ + 'baseurl' => "http://download.fedoraproject.org/pub/epel/testing/5/$basearch", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", + 'descr' => "Extra Packages for Enterprise Linux 5 - Testing - $basearch ", + }) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_testing_debuginfo.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_testing_debuginfo.rb new file mode 100644 index 0000000000..62f647d379 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_testing_debuginfo.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +shared_context :epel_testing_debuginfo do + it do + should contain_yumrepo('epel-testing-debuginfo').with({ + 'failovermethod' => 'priority', + 'proxy' => 'absent', + 'enabled' => '0', + 'gpgcheck' => '1', + }) + end +end + +shared_context :epel_testing_debuginfo_6 do + include_context :epel_testing_debuginfo + + it do + should contain_yumrepo('epel-testing-debuginfo').with({ + 'baseurl' => "http://download.fedoraproject.org/pub/epel/testing/6/$basearch/debug", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", + 'descr' => "Extra Packages for Enterprise Linux 6 - Testing - $basearch - Debug", + }) + end +end + +shared_context :epel_testing_debuginfo_5 do + include_context :epel_testing_debuginfo + + it do + should contain_yumrepo('epel-testing-debuginfo').with({ + 'baseurl' => "http://download.fedoraproject.org/pub/epel/testing/5/$basearch/debug", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", + 'descr' => "Extra Packages for Enterprise Linux 5 - Testing - $basearch - Debug", + }) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_testing_source.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_testing_source.rb new file mode 100644 index 0000000000..1a7e0a6ae8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/classes/shared_testing_source.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +shared_context :epel_testing_source do + it do + should contain_yumrepo('epel-testing-source').with({ + 'failovermethod' => 'priority', + 'proxy' => 'absent', + 'enabled' => '0', + 'gpgcheck' => '1', + }) + end +end + +shared_context :epel_testing_source_6 do + include_context :epel_testing_source + + it do + should contain_yumrepo('epel-testing-source').with({ + 'baseurl' => "http://download.fedoraproject.org/pub/epel/testing/6/SRPMS", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6", + 'descr' => "Extra Packages for Enterprise Linux 6 - Testing - $basearch - Source", + }) + end +end + +shared_context :epel_testing_source_5 do + include_context :epel_testing_source + + it do + should contain_yumrepo('epel-testing-source').with({ + 'baseurl' => "http://download.fedoraproject.org/pub/epel/testing/5/SRPMS", + 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5", + 'descr' => "Extra Packages for Enterprise Linux 5 - Testing - $basearch - Source", + }) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/defines/._rpm_gpg_key_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/defines/._rpm_gpg_key_spec.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/defines/._rpm_gpg_key_spec.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/defines/rpm_gpg_key_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/defines/rpm_gpg_key_spec.rb new file mode 100644 index 0000000000..63cfe08ff9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/defines/rpm_gpg_key_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe 'epel::rpm_gpg_key' do + context 'os_maj_version => 6' do + let :facts do + default_facts.merge({ + :operatingsystemrelease => '6.4', + :os_maj_version => '6', + }) + end + + let :title do + 'EPEL-6' + end + + let :params do + { :path => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6" } + end + + it do + should contain_exec("import-#{title}").with({ + 'path' => '/bin:/usr/bin:/sbin:/usr/sbin', + 'command' => "rpm --import #{params[:path]}", + 'unless' => "rpm -q gpg-pubkey-$(echo $(gpg --throw-keyids < #{params[:path]}) | cut --characters=11-18 | tr '[A-Z]' '[a-z]')", + 'require' => "File[#{params[:path]}]", + 'logoutput' => 'on_failure', + }) + end + end + + context 'os_maj_version => 5' do + let :facts do + default_facts.merge({ + :operatingsystemrelease => '5.9', + :os_maj_version => '5', + }) + end + + let :title do + 'EPEL-5' + end + + let :params do + { :path => "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-5" } + end + + it do + should contain_exec("import-#{title}").with({ + 'path' => '/bin:/usr/bin:/sbin:/usr/sbin', + 'command' => "rpm --import #{params[:path]}", + 'unless' => "rpm -q gpg-pubkey-$(echo $(gpg --throw-keyids < #{params[:path]}) | cut --characters=11-18 | tr '[A-Z]' '[a-z]')", + 'require' => "File[#{params[:path]}]", + 'logoutput' => 'on_failure', + }) + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/spec_helper.rb new file mode 100644 index 0000000000..eafe6b6001 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/spec_helper.rb @@ -0,0 +1,8 @@ +require 'puppetlabs_spec_helper/module_spec_helper' + +def default_facts + { + :osfamily => 'RedHat', + :operatingsystem => 'CentOS', + } +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/spec_helper_system.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/spec_helper_system.rb new file mode 100644 index 0000000000..cf680367b9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/spec_helper_system.rb @@ -0,0 +1,23 @@ +require 'rspec-system/spec_helper' +require 'rspec-system-puppet/helpers' + +include RSpecSystemPuppet::Helpers + +RSpec.configure do |c| + # Project root for the this module's code + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Enable colour in Jenkins + c.tty = true + + c.include RSpecSystemPuppet::Helpers + + # This is where we 'setup' the nodes before running our tests + c.before :suite do + # Install puppet + puppet_install + puppet_master_install + + puppet_module_install(:source => proj_root, :module_name => 'epel') + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/._basic_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/._basic_spec.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/._basic_spec.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/._usage_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/._usage_spec.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/._usage_spec.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/basic_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/basic_spec.rb new file mode 100644 index 0000000000..569e12d373 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/basic_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper_system' + +describe 'epel class:' do + context puppet_agent do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + end + + # Verify the os_maj_version fact is working + context shell 'facter --puppet os_maj_version' do + its(:stdout) { should_not be_empty } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + pp = "class { 'epel': }" + + context puppet_apply pp do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + context 'test EPEL repo presence' do + facts = node.facts + + # Only test for EPEL's presence if not Fedora + if facts['operatingsystem'] !~ /Fedora/ + context shell '/usr/bin/yum-config-manager epel | grep -q "\[epel\]"' do + its(:exit_code) { should be_zero } + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/usage_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/usage_spec.rb new file mode 100644 index 0000000000..2b0d8f36e2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/system/usage_spec.rb @@ -0,0 +1,60 @@ +require 'spec_helper_system' + +describe 'standage usage tests:' do + context 'test epel baseurl and mirrorlist' do + facts = node.facts + os_maj_version = facts['operatingsystemrelease'].split('.')[0] + pp = <<-EOS + class { 'epel': + epel_baseurl => 'http://dl.fedoraproject.org/pub/epel/#{os_maj_version}/x86_64/', + epel_mirrorlist => 'absent', + } + EOS + + context puppet_apply pp do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + # Only test for EPEL's presence if not Fedora + if facts['operatingsystem'] !~ /Fedora/ + # Test the yum config to ensure mirrorlist was emptied + context shell '/usr/bin/yum-config-manager epel | egrep "^mirrorlist ="' do + its(:stdout) { should =~ /mirrorlist =\s+/ } + end + + # Test the yum config to ensure baseurl was defined + context shell '/usr/bin/yum-config-manager epel | egrep "^baseurl ="' do + its(:stdout) { should =~ /baseurl = http:\/\/dl.fedoraproject.org\/pub\/epel\/#{os_maj_version}\/x86_64\// } + end + end + end + + context 'test epel-testing is enabled' do + facts = node.facts + pp = <<-EOS + class { 'epel': + epel_testing_enabled => '1', + } + EOS + + context puppet_apply pp do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + # Only test for EPEL's presence if not Fedora + if facts['operatingsystem'] !~ /Fedora/ + # Test the yum config to ensure epel-testing was enabled + context shell '/usr/bin/yum-config-manager epel-testing | grep -q "enabled = True"' do + its(:exit_code) { should be_zero } + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/unit/._facter b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/unit/._facter new file mode 100755 index 0000000000..bb87e14dde Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/unit/._facter differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/unit/facter/._os_maj_version_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/unit/facter/._os_maj_version_spec.rb new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/unit/facter/._os_maj_version_spec.rb differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/unit/facter/os_maj_version_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/unit/facter/os_maj_version_spec.rb new file mode 100644 index 0000000000..83bcdffd2c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/spec/unit/facter/os_maj_version_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe 'os_maj_version fact' do + before :each do + Facter.clear + end + + context "on 5.9 operatingsystemrelease" do + it "should have os_maj_version => 5" do + Facter.fact(:operatingsystemrelease).stubs(:value).returns("5.9") + Facter.fact(:os_maj_version).value.should == "5" + end + end + + context "on 6.4 operatingsystemrelease" do + it "should have os_maj_version => 6" do + Facter.fact(:operatingsystemrelease).stubs(:value).returns("6.4") + Facter.fact(:os_maj_version).value.should == "6" + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/tests/._init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/tests/._init.pp new file mode 100644 index 0000000000..313e184ac1 Binary files /dev/null and b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/tests/._init.pp differ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/tests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/tests/init.pp new file mode 100644 index 0000000000..c2e61d4298 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/epel/tests/init.pp @@ -0,0 +1,3 @@ +# And by test, I mean, run this thing for me using Puppet apply and I'll check +# it out. +include 'epel' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.fixtures.yml new file mode 100644 index 0000000000..8968df1f45 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.fixtures.yml @@ -0,0 +1,7 @@ +fixtures: + repositories: + apt: git://github.com/puppetlabs/puppetlabs-apt.git + stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git + epel: git://github.com/stahnma/puppet-module-epel.git + symlinks: + erlang: "#{source_dir}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.nodeset.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.nodeset.yml new file mode 100644 index 0000000000..cbd0d57b83 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.nodeset.yml @@ -0,0 +1,35 @@ +--- +default_set: 'centos-64-x64' +sets: + 'centos-59-x64': + nodes: + "main.foo.vm": + prefab: 'centos-59-x64' + 'centos-64-x64': + nodes: + "main.foo.vm": + prefab: 'centos-64-x64' + 'fedora-18-x64': + nodes: + "main.foo.vm": + prefab: 'fedora-18-x64' + 'debian-607-x64': + nodes: + "main.foo.vm": + prefab: 'debian-607-x64' + 'debian-70rc1-x64': + nodes: + "main.foo.vm": + prefab: 'debian-70rc1-x64' + 'ubuntu-server-10044-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-10044-x64' + 'ubuntu-server-12042-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-12042-x64' + 'sles-11sp1-x64': + nodes: + "main.foo.vm": + prefab: 'sles-11sp1-x64' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.rspec b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.rspec new file mode 100644 index 0000000000..49d5710b3e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.rspec @@ -0,0 +1 @@ +--format documentation diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.travis.yml new file mode 100644 index 0000000000..cd412bfd34 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/.travis.yml @@ -0,0 +1,23 @@ +--- +language: ruby +bundler_args: --without development +before_install: rm Gemfile.lock || true +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 +script: bundle exec rake test +env: + - PUPPET_VERSION="~> 2.7.0" + - PUPPET_VERSION="~> 3.1.0" + - PUPPET_VERSION="~> 3.2.0" + - PUPPET_VERSION="~> 3.3.0" + - PUPPET_VERSION="~> 3.4.0" +matrix: + exclude: + - rvm: 2.0.0 + env: PUPPET_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_VERSION="~> 3.1.0" + - rvm: 1.9.3 + env: PUPPET_VERSION="~> 2.7.0" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Gemfile new file mode 100644 index 0000000000..39ba7f9f63 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Gemfile @@ -0,0 +1,15 @@ +source "http://rubygems.org" + + +gem "rake" +gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.2.0' +gem "puppet-lint" +gem "rspec-puppet", '~> 1.0.0' +gem "puppetlabs_spec_helper" +gem "rspec-system-puppet" +gem "vagrant-wrapper" +gem "puppet-syntax" + +group :development do + gem "puppet-blacksmith" +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Gemfile.lock b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Gemfile.lock new file mode 100644 index 0000000000..d719aa9791 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Gemfile.lock @@ -0,0 +1,94 @@ +GEM + remote: http://rubygems.org/ + specs: + builder (3.2.2) + diff-lcs (1.2.5) + excon (0.31.0) + facter (1.7.5) + fog (1.20.0) + builder + excon (~> 0.31.0) + formatador (~> 0.2.0) + mime-types + multi_json (~> 1.0) + net-scp (~> 1.1) + net-ssh (>= 2.1.3) + nokogiri (>= 1.5.11) + formatador (0.2.4) + hiera (1.3.2) + json_pure + json_pure (1.8.1) + kwalify (0.7.2) + metaclass (0.0.4) + mime-types (1.25.1) + mocha (1.0.0) + metaclass (~> 0.0.1) + multi_json (1.8.4) + net-scp (1.1.2) + net-ssh (>= 2.6.5) + net-ssh (2.8.0) + nokogiri (1.5.11) + puppet (3.2.4) + facter (~> 1.6) + hiera (~> 1.0) + rgen (~> 0.6.5) + puppet-blacksmith (2.0.2) + nokogiri + puppet (>= 2.7.16) + rest-client + puppet-lint (0.3.2) + puppet-syntax (1.1.0) + puppet (>= 2.7.0) + rake + puppetlabs_spec_helper (0.4.1) + mocha (>= 0.10.5) + rake + rspec (>= 2.9.0) + rspec-puppet (>= 0.1.1) + rake (10.1.1) + rbvmomi (1.8.1) + builder + nokogiri (>= 1.4.1) + trollop + rest-client (1.6.7) + mime-types (>= 1.16) + rgen (0.6.6) + rspec (2.14.1) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + rspec-core (2.14.8) + rspec-expectations (2.14.5) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.6) + rspec-puppet (1.0.1) + rspec + rspec-system (2.8.0) + fog (~> 1.18) + kwalify (~> 0.7.2) + mime-types (~> 1.16) + net-scp (~> 1.1) + net-ssh (~> 2.7) + nokogiri (~> 1.5.10) + rbvmomi (~> 1.6) + rspec (~> 2.14) + systemu (~> 2.5) + rspec-system-puppet (2.2.1) + rspec-system (~> 2.0) + systemu (2.6.3) + trollop (2.0) + vagrant-wrapper (1.2.1.1) + +PLATFORMS + ruby + +DEPENDENCIES + puppet (~> 3.2.0) + puppet-blacksmith + puppet-lint + puppet-syntax + puppetlabs_spec_helper + rake + rspec-puppet (~> 1.0.0) + rspec-system-puppet + vagrant-wrapper diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/LICENSE new file mode 100644 index 0000000000..bf023233a1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/LICENSE @@ -0,0 +1,207 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, and + distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by the + copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all other + entities that control, are controlled by, or are under common control with + that entity. For the purposes of this definition, "control" means (i) the + power, direct or indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (ii) ownership of + fifty percent (50%) or more of the outstanding shares, or (iii) beneficial + ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity exercising + permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation source, + and configuration files. + + "Object" form shall mean any form resulting from mechanical transformation + or translation of a Source form, including but not limited to compiled + object code, generated documentation, and conversions to + other media types. + + "Work" shall mean the work of authorship, whether in Source or Object + form, made available under the License, as indicated by a copyright notice + that is included in or attached to the work (an example is provided in the + Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object form, + that is based on (or derived from) the Work and for which the editorial + revisions, annotations, elaborations, or other modifications represent, + as a whole, an original work of authorship. For the purposes of this + License, Derivative Works shall not include works that remain separable + from, or merely link (or bind by name) to the interfaces of, the Work and + Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including the original + version of the Work and any modifications or additions to that Work or + Derivative Works thereof, that is intentionally submitted to Licensor for + inclusion in the Work by the copyright owner or by an individual or + Legal Entity authorized to submit on behalf of the copyright owner. + For the purposes of this definition, "submitted" means any form of + electronic, verbal, or written communication sent to the Licensor or its + representatives, including but not limited to communication on electronic + mailing lists, source code control systems, and issue tracking systems + that are managed by, or on behalf of, the Licensor for the purpose of + discussing and improving the Work, but excluding communication that is + conspicuously marked or otherwise designated in writing by the copyright + owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity on + behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. + + Subject to the terms and conditions of this License, each Contributor + hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, + royalty-free, irrevocable copyright license to reproduce, prepare + Derivative Works of, publicly display, publicly perform, sublicense, + and distribute the Work and such Derivative Works in + Source or Object form. + +3. Grant of Patent License. + + Subject to the terms and conditions of this License, each Contributor + hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, + royalty-free, irrevocable (except as stated in this section) patent + license to make, have made, use, offer to sell, sell, import, and + otherwise transfer the Work, where such license applies only to those + patent claims licensable by such Contributor that are necessarily + infringed by their Contribution(s) alone or by combination of their + Contribution(s) with the Work to which such Contribution(s) was submitted. + If You institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work or a + Contribution incorporated within the Work constitutes direct or + contributory patent infringement, then any patent licenses granted to + You under this License for that Work shall terminate as of the date such + litigation is filed. + +4. Redistribution. + + You may reproduce and distribute copies of the Work or Derivative Works + thereof in any medium, with or without modifications, and in Source or + Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works a + copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + + 3. You must retain, in the Source form of any Derivative Works that You + distribute, all copyright, patent, trademark, and attribution notices from + the Source form of the Work, excluding those notices that do not pertain + to any part of the Derivative Works; and + + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable copy + of the attribution notices contained within such NOTICE file, excluding + those notices that do not pertain to any part of the Derivative Works, + in at least one of the following places: within a NOTICE text file + distributed as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, within a + display generated by the Derivative Works, if and wherever such + third-party notices normally appear. The contents of the NOTICE file are + for informational purposes only and do not modify the License. + You may add Your own attribution notices within Derivative Works that You + distribute, alongside or as an addendum to the NOTICE text from the Work, + provided that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and may + provide additional or different license terms and conditions for use, + reproduction, or distribution of Your modifications, or for any such + Derivative Works as a whole, provided Your use, reproduction, and + distribution of the Work otherwise complies with the conditions + stated in this License. + +5. Submission of Contributions. + + Unless You explicitly state otherwise, any Contribution intentionally + submitted for inclusion in the Work by You to the Licensor shall be under + the terms and conditions of this License, without any additional + terms or conditions. Notwithstanding the above, nothing herein shall + supersede or modify the terms of any separate license agreement you may + have executed with Licensor regarding such Contributions. + +6. Trademarks. + + This License does not grant permission to use the trade names, trademarks, + service marks, or product names of the Licensor, except as required for + reasonable and customary use in describing the origin of the Work and + reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + + Unless required by applicable law or agreed to in writing, Licensor + provides the Work (and each Contributor provides its Contributions) + on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + either express or implied, including, without limitation, any warranties + or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS + FOR A PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any risks + associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + + In no event and under no legal theory, whether in tort + (including negligence), contract, or otherwise, unless required by + applicable law (such as deliberate and grossly negligent acts) or agreed + to in writing, shall any Contributor be liable to You for damages, + including any direct, indirect, special, incidental, or consequential + damages of any character arising as a result of this License or out of + the use or inability to use the Work (including but not limited to damages + for loss of goodwill, work stoppage, computer failure or malfunction, + or any and all other commercial damages or losses), even if such + Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + + While redistributing the Work or Derivative Works thereof, You may choose + to offer, and charge a fee for, acceptance of support, warranty, + indemnity, or other liability obligations and/or rights consistent with + this License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf of any + other Contributor, and only if You agree to indemnify, defend, and hold + each Contributor harmless for any liability incurred by, or claims + asserted against, such Contributor by reason of your accepting any such + warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + + To apply the Apache License to your work, attach the following boilerplate + notice, with the fields enclosed by brackets "[]" replaced with your own + identifying information. (Don't include the brackets!) The text should be + enclosed in the appropriate comment syntax for the file format. We also + recommend that a file or class name and description of purpose be included + on the same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2013 Gareth Rushgrove + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the License for the specific language governing + permissions and limitations under the License. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Modulefile new file mode 100644 index 0000000000..9ca1ef7042 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Modulefile @@ -0,0 +1,10 @@ +name 'garethr-erlang' +version '0.3.0' +source 'git://github.com/garethr/garethr-erlang.git' +author 'Gareth Rushgrove' +summary 'Module for installing erlang from official repos' +description 'Install one of the official erlang packages' +license 'Apache License, Version 2.0' +dependency 'puppetlabs/apt' +dependency 'puppetlabs/stdlib' +dependency 'stahnma/epel' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/README.md new file mode 100644 index 0000000000..a1959740bc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/README.md @@ -0,0 +1,28 @@ +Puppet module for installing Erlang from alternative repositories. + +On debian it will use the official repositories +mentioned on the [Erlang +docs](https://www.erlang-solutions.com/downloads/download-erlang-otp). + +On Redhat 5 it'll use an additional EPEL repository hosted by +[Redhat](http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo). + +On Redhat 6 it'll require EPEL. + +On SUSE it'll use the official repos. + +On Archlinux it'll use community repos. + +This module is also available on the [Puppet +Forge](https://forge.puppetlabs.com/garethr/erlang) + +[](http://travis-ci.org/garethr/garethr-erlang) + +## Usage + +The module includes a single class: + + include 'erlang' + +By default this sets up the repository and installs the erlang package. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Rakefile new file mode 100644 index 0000000000..d45aa3d574 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/Rakefile @@ -0,0 +1,35 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' +require 'puppet-syntax/tasks/puppet-syntax' +require 'rspec-system/rake_task' + +begin + require 'puppet_blacksmith/rake_tasks' +rescue LoadError +end + +PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" +PuppetLint.configuration.fail_on_warnings = true + +# Forsake support for Puppet 2.6.2 for the benefit of cleaner code. +# http://puppet-lint.com/checks/class_parameter_defaults/ +PuppetLint.configuration.send('disable_class_parameter_defaults') +# http://puppet-lint.com/checks/class_inherits_from_params_class/ +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +# http://puppet-lint.com/checks/80chars/ +PuppetLint.configuration.send("disable_80chars") + +exclude_paths = [ + "pkg/**/*", + "vendor/**/*", + "spec/**/*", +] +PuppetLint.configuration.ignore_paths = exclude_paths +PuppetSyntax.exclude_paths = exclude_paths + +desc "Run syntax, lint, and spec tests." +task :test => [ + :syntax, + :lint, + :spec, +] diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/init.pp new file mode 100644 index 0000000000..045bada947 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/init.pp @@ -0,0 +1,45 @@ +# == Class: erlang +# +# Module to install an up-to-date version of Erlang from the +# official repositories +# +# === Parameters +# [*version*] +# The package version to install, passed to ensure. +# Defaults to present. +# +class erlang ( + $epel_enable = $erlang::params::epel_enable, + $key_signature = $erlang::params::key_signature, + $local_repo_location = $erlang::params::local_repo_location, + $package_name = $erlang::params::package_name, + $remote_repo_location = $erlang::params::remote_repo_location, + $remote_repo_key_location = $erlang::params::remote_repo_key_location, + $repos = $erlang::params::repos, + $version = 'present', +) inherits erlang::params { + validate_string($version) + + case $::osfamily { + 'Debian' : { + include '::apt' + include '::erlang::repo::apt' + } + 'RedHat' : { + if $epel_enable { + # Include epel as this is a requirement for erlang in RHEL6. + include '::epel' + Class['epel'] -> Package[$package_name] + } + + # This is only needed on RHEL5, RHEL6 has erlang in EPEL. + if $::operatingsystemrelease =~ /^5/ { + include '::erlang::repo::yum' + } + } + default : { + } + } + + package { $package_name: ensure => $version, } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/params.pp new file mode 100644 index 0000000000..9358326cd9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/params.pp @@ -0,0 +1,29 @@ +# == Class: erlang::params +# +# Default paramaters setting repository details for different +# operating systems +# +class erlang::params { + $epel_enable = false + + case $::osfamily { + 'Debian' : { + $key_signature = 'D208507CA14F4FCA' + $package_name = 'erlang-nox' + $remote_repo_key_location = 'http://packages.erlang-solutions.com/debian/erlang_solutions.asc' + $remote_repo_location = 'http://packages.erlang-solutions.com/debian' + $repos = 'contrib' + } + 'RedHat', 'SUSE', 'Archlinux' : { + $package_name = 'erlang' + + if $::operatingsystemrelease =~ /^5/ { + $local_repo_location = '/etc/yum.repos.d/epel-erlang.repo' + $remote_repo_location = 'http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo' + } + } + default : { + fail("The ${module_name} module is not supported on an ${::osfamily} based system.") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/repo/apt.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/repo/apt.pp new file mode 100644 index 0000000000..dc5dbc9c4f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/repo/apt.pp @@ -0,0 +1,41 @@ +# == Class: erlang::repo::apt +# +# Install an apt package repository containing Erlang. +# All parameters have sane default values in erlang::params. +# +# === Parameters +# [*key_signature*] +# The signature for the key used to sign packages in the repository. +# +# [*package_name*] +# Name of the Erlang package in the specified repository. +# +# [*remote_repo_key_location*] +# URL of the public key for the remote repository. +# +# [*remote_repo_location*] +# URL of the remote debian repository. +# +# [*repos*] +# Which of the standard repositories to install from the +# remote repo. For instance main, contrib, restricted. +# +class erlang::repo::apt( + $key_signature = $erlang::key_signature, + $package_name = $erlang::package_name, + $remote_repo_key_location = $erlang::remote_repo_key_location, + $remote_repo_location = $erlang::remote_repo_location, + $repos = $erlang::repos, +) { + + Class['erlang::repo::apt'] -> Package<| title == $package_name |> + + apt::source { 'erlang': + include_src => false, + key => $key_signature, + key_source => $remote_repo_key_location, + location => $remote_repo_location, + repos => $repos, + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/repo/yum.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/repo/yum.pp new file mode 100644 index 0000000000..702e65220b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/manifests/repo/yum.pp @@ -0,0 +1,30 @@ +# == Class: erlang::repo::yum +# +# Install a yum package repository containing Erlang. +# All parameters have sane default values in erlang::params. +# +# === Parameters +# [*local_repo_location*] +# File system location to store the repository details +# +# [*package_name*] +# Name of the Erlang package in the specified repository +# +# [*remote_repo_location*] +# URL of the remote repository +# +class erlang::repo::yum ( + $local_repo_location = $erlang::local_repo_location, + $package_name = $erlang::package_name, + $remote_repo_location = $erlang::remote_repo_location, +) inherits erlang { + + Class['erlang::repo::yum'] -> Package<| title == $package_name |> + + exec { 'erlang-repo-download': + command => "curl -o ${local_repo_location} ${remote_repo_location}", + path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', + creates => $local_repo_location, + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/classes/erlang_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/classes/erlang_spec.rb new file mode 100644 index 0000000000..8708eb1afe --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/classes/erlang_spec.rb @@ -0,0 +1,138 @@ +require 'spec_helper' + +describe 'erlang', :type => :class do + + + context 'on Debian' do + let(:facts) { { + :osfamily => 'Debian', + :lsbdistid => 'debian', + :lsbdistcodename => 'squeeze' + }} + + context 'with no parameters' do + it { should compile.with_all_deps } + it { should contain_package('erlang-nox').with_ensure('present') } + it { should contain_apt__source('erlang').with( + 'key_source' => 'http://packages.erlang-solutions.com/debian/erlang_solutions.asc', + 'key' => 'D208507CA14F4FCA' + ) } + end + + context 'with a custom version' do + let(:params) { {'version' => 'absent' } } + it { should contain_package('erlang-nox').with_ensure('absent') } + end + + context 'with a custom package name' do + let(:params) { {'package_name' => 'not-erlang' } } + it { should contain_package('not-erlang').with_ensure('present') } + end + + context 'with custom repository details' do + let(:params) { { + 'key_signature' => '1234ABCD', + 'repos' => 'main', + 'remote_repo_location' => 'http://example.com/debian', + 'remote_repo_key_location' => 'http://example.com/debian/key.asc', + } } + it { should contain_apt__source('erlang').with( + 'location' => 'http://example.com/debian', + 'key_source' => 'http://example.com/debian/key.asc', + 'key' => '1234ABCD', + 'repos' => 'main' + ) } + end + + end + + context 'on RedHat 5' do + let(:facts) { {:osfamily => 'RedHat', :operatingsystemrelease => '5.9' } } + + context "epel enabled" do + let(:params) {{ :epel_enable => true }} + it { should contain_class('epel') } + end + + context "epel disabled" do + let(:params) {{ :epel_enable => false }} + it { should_not contain_class('epel') } + end + + context 'with no parameters' do + it { should contain_package('erlang').with_ensure('present') } + it { should contain_exec('erlang-repo-download').with( + 'command' => 'curl -o /etc/yum.repos.d/epel-erlang.repo http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo', + 'path' => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin' + ) + } + end + + context 'with a custom repository' do + let(:params) { { + 'local_repo_location' => '/tmp/yum.repos.d/tmp.repo', + 'remote_repo_location' => 'http://example.com/fake.repo', + } } + + it { should contain_exec('erlang-repo-download').with( + 'command' => 'curl -o /tmp/yum.repos.d/tmp.repo http://example.com/fake.repo' + ) + } + end + + context 'with a custom version' do + let(:params) { {'version' => 'absent' } } + it { should contain_package('erlang').with_ensure('absent') } + end + end + + context 'on RedHat 6' do + let(:facts) { {:osfamily => 'RedHat', :operatingsystemrelease => '6.4' } } + + context "epel enabled" do + let(:params) {{ :epel_enable => true }} + it { should contain_class('epel') } + end + + context "epel disabled" do + let(:params) {{ :epel_enable => false }} + it { should_not contain_class('epel') } + end + + context 'with no parameters' do + it { should contain_package('erlang').with_ensure('present') } + end + + context 'with a custom version' do + let(:params) { {'version' => 'absent' } } + it { should contain_package('erlang').with_ensure('absent') } + end + end + + context 'on SUSE' do + let(:facts) {{ :osfamily => 'SUSE', }} + + context 'with no parameters' do + it { should contain_package('erlang').with_ensure('present') } + end + + context 'with a custom version' do + let(:params) { {'version' => 'absent' } } + it { should contain_package('erlang').with_ensure('absent') } + end + end + + context 'on Archlinux' do + let(:facts) {{ :osfamily => 'Archlinux', }} + + context 'with no parameters' do + it { should contain_package('erlang').with_ensure('present') } + end + + context 'with a custom version' do + let(:params) { {'version' => 'absent' } } + it { should contain_package('erlang').with_ensure('absent') } + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/spec_helper.rb new file mode 100644 index 0000000000..2c6f56649a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/spec_helper_system.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/spec_helper_system.rb new file mode 100644 index 0000000000..5c37024856 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/spec_helper_system.rb @@ -0,0 +1,17 @@ +require 'rspec-system/spec_helper' +require 'rspec-system-puppet/helpers' + +include RSpecSystemPuppet::Helpers + +RSpec.configure do |c| + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + c.tty = true + c.include RSpecSystemPuppet::Helpers + + c.before :suite do + puppet_install + puppet_module_install(:source => proj_root, :module_name => 'erlang') + shell('puppet module install puppetlabs-apt') + shell('puppet module install stahnma-epel') + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/system/erlang_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/system/erlang_spec.rb new file mode 100644 index 0000000000..4d5772fa59 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/erlang/spec/system/erlang_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper_system' + +describe 'The erlang puppet module' do + it 'should run without errors' do + pp = <<-EOS + class { 'erlang': + epel_enable => true + } + EOS + + puppet_apply(pp) do |r| + r.exit_code.should == 2 + r.refresh + r.exit_code.should be_zero + end + end + + it 'should install the erl binary into /usr/bin' do + shell 'which erl' do |r| + r.stdout.should =~ /\/usr\/bin\/erl/ + r.stderr.should be_empty + r.exit_code.should be_zero + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/.fixtures.yml new file mode 100644 index 0000000000..0d10d5cec1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/.fixtures.yml @@ -0,0 +1,3 @@ +fixtures: + symlinks: + "firewall": "#{source_dir}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/.nodeset.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/.nodeset.yml new file mode 100644 index 0000000000..767f9cd2f6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/.nodeset.yml @@ -0,0 +1,31 @@ +--- +default_set: 'centos-64-x64' +sets: + 'centos-59-x64': + nodes: + "main.foo.vm": + prefab: 'centos-59-x64' + 'centos-64-x64': + nodes: + "main.foo.vm": + prefab: 'centos-64-x64' + 'fedora-18-x64': + nodes: + "main.foo.vm": + prefab: 'fedora-18-x64' + 'debian-607-x64': + nodes: + "main.foo.vm": + prefab: 'debian-607-x64' + 'debian-70rc1-x64': + nodes: + "main.foo.vm": + prefab: 'debian-70rc1-x64' + 'ubuntu-server-10044-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-10044-x64' + 'ubuntu-server-12042-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-12042-x64' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/.travis.yml new file mode 100644 index 0000000000..0e94c2876c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/.travis.yml @@ -0,0 +1,29 @@ +--- +language: ruby +bundler_args: --without development +script: "bundle exec rake ci SPEC_OPTS='--format documentation'" +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 +env: + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.0.0" + - PUPPET_GEM_VERSION="~> 3.1.0" + - PUPPET_GEM_VERSION="~> 3.2.0" + - PUPPET_GEM_VERSION="~> 3.4.0" +matrix: + fast_finish: true + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.1.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 3.2.0" +notifications: + email: false diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/CHANGELOG.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/CHANGELOG.md new file mode 100644 index 0000000000..daf390e98d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/CHANGELOG.md @@ -0,0 +1,432 @@ +## 2014-05-16 Release 1.1.1 +###Summary + +This release reverts the alphabetical ordering of 1.1.0. We found this caused +a regression in the Openstack modules so in the interest of safety we have +removed this for now. + +## 2014-05-13 Release 1.1.0 +###Summary + +This release has a significant change from previous releases; we now apply the +firewall resources alphabetically by default, removing the need to create pre +and post classes just to enforce ordering. It only effects default ordering +and further information can be found in the README about this. Please test +this in development before rolling into production out of an abundance of +caution. + +We've also added `mask` which is required for --recent in recent (no pun +intended) versions of iptables, as well as connlimit and connmark. This +release has been validated against Ubuntu 14.04 and RHEL7 and should be fully +working on those platforms. + +####Features + +- Apply firewall resources alphabetically. +- Add support for connlimit and connmark. +- Add `mask` as a parameter. (Used exclusively with the recent parameter). + +####Bugfixes + +- Add systemd support for RHEL7. +- Replace &&'s with the correct and in manifests. +- Fix tests on Trusty and RHEL7 +- Fix for Fedora Rawhide. +- Fix boolean flag tests. +- Fix DNAT->SNAT typo in an error message. + +####Known Bugs + +* For Oracle, the `owner` and `socket` parameters require a workaround to function. Please see the Limitations section of the README. + + +## 2014-03-04 Supported Release 1.0.2 +###Summary + +This is a supported release. This release removes a testing symlink that can +cause trouble on systems where /var is on a seperate filesystem from the +modulepath. + +####Features +####Bugfixes +####Known Bugs + +* For Oracle, the `owner` and `socket` parameters require a workaround to function. Please see the Limitations section of the README. + +### Supported release - 2014-03-04 1.0.1 + +####Summary + +An important bugfix was made to the offset calculation for unmanaged rules +to handle rules with 9000+ in the name. + +####Features + +####Bugfixes +- Offset calculations assumed unmanaged rules were numbered 9000+. +- Gracefully fail to manage ip6tables on iptables 1.3.x + +####Known Bugs + +* For Oracle, the `owner` and `socket` parameters require a workaround to function. Please see the Limitations section of the README. + +--- +### 1.0.0 - 2014-02-11 + +No changes, just renumbering to 1.0.0. + +--- +### 0.5.0 - 2014-02-10 + +##### Summary: +This is a bigger release that brings in "recent" connection limiting (think +"port knocking"), firewall chain purging on a per-chain/per-table basis, and +support for a few other use cases. This release also fixes a major bug which +could cause modifications to the wrong rules when unmanaged rules are present. + +##### New Features: +* Add "recent" limiting via parameters `rdest`, `reap`, `recent`, `rhitcount`, + `rname`, `rseconds`, `rsource`, and `rttl` +* Add negation support for source and destination +* Add per-chain/table purging support to `firewallchain` +* IPv4 specific + * Add random port forwarding support + * Add ipsec policy matching via `ipsec_dir` and `ipsec_policy` +* IPv6 specific + * Add support for hop limiting via `hop_limit` parameter + * Add fragmentation matchers via `ishasmorefrags`, `islastfrag`, and `isfirstfrag` + * Add support for conntrack stateful firewall matching via `ctstate` + +##### Bugfixes: +- Boolean fixups allowing false values +- Better detection of unmanaged rules +- Fix multiport rule detection +- Fix sport/dport rule detection +- Make INPUT, OUTPUT, and FORWARD not autorequired for firewall chain filter +- Allow INPUT with the nat table +- Fix `src_range` & `dst_range` order detection +- Documentation clarifications +- Fixes to spec tests + +--------------------------------------- + +### 0.4.2 - 2013-09-10 + +Another attempt to fix the packaging issue. We think we understand exactly +what is failing and this should work properly for the first time. + +--------------------------------------- + +### 0.4.1 - 2013-08-09 + +Bugfix release to fix a packaging issue that may have caused puppet module +install commands to fail. + +--------------------------------------- + +### 0.4.0 - 2013-07-11 + +This release adds support for address type, src/dest ip ranges, and adds +additional testing and bugfixes. + +#### Features +* Add `src_type` and `dst_type` attributes (Nick Stenning) +* Add `src_range` and `dst_range` attributes (Lei Zhang) +* Add SL and SLC operatingsystems as supported (Steve Traylen) + +#### Bugfixes +* Fix parser for bursts other than 5 (Chris Rutter) +* Fix parser for -f in --comment (Georg Koester) +* Add doc headers to class files (Dan Carley) +* Fix lint warnings/errors (Wolf Noble) + +--------------------------------------- + +### 0.3.1 - 2013/6/10 + +This minor release provides some bugfixes and additional tests. + +#### Changes + +* Update tests for rspec-system-puppet 2 (Ken Barber) +* Update rspec-system tests for rspec-system-puppet 1.5 (Ken Barber) +* Ensure all services have 'hasstatus => true' for Puppet 2.6 (Ken Barber) +* Accept pre-existing rule with invalid name (Joe Julian) +* Swap log_prefix and log_level order to match the way it's saved (Ken Barber) +* Fix log test to replicate bug #182 (Ken Barber) +* Split argments while maintaining quoted strings (Joe Julian) +* Add more log param tests (Ken Barber) +* Add extra tests for logging parameters (Ken Barber) +* Clarify OS support (Ken Barber) + +--------------------------------------- + +### 0.3.0 - 2013/4/25 + +This release introduces support for Arch Linux and extends support for Fedora 15 and up. There are also lots of bugs fixed and improved testing to prevent regressions. + +##### Changes + +* Fix error reporting for insane hostnames (Tomas Doran) +* Support systemd on Fedora 15 and up (Eduardo Gutierrez) +* Move examples to docs (Ken Barber) +* Add support for Arch Linux platform (Ingmar Steen) +* Add match rule for fragments (Georg Koester) +* Fix boolean rules being recognized as changed (Georg Koester) +* Same rules now get deleted (Anastasis Andronidis) +* Socket params test (Ken Barber) +* Ensure parameter can disable firewall (Marc Tardif) + +--------------------------------------- + +### 0.2.1 - 2012/3/13 + +This maintenance release introduces the new README layout, and fixes a bug with iptables_persistent_version. + +##### Changes + +* (GH-139) Throw away STDERR from dpkg-query in Fact +* Update README to be consistent with module documentation template +* Fix failing spec tests due to dpkg change in iptables_persistent_version + +--------------------------------------- + +### 0.2.0 - 2012/3/3 + +This release introduces automatic persistence, removing the need for the previous manual dependency requirement for persistent the running rules to the OS persistence file. + +Previously you would have required the following in your site.pp (or some other global location): + + # Always persist firewall rules + exec { 'persist-firewall': + command => $operatingsystem ? { + 'debian' => '/sbin/iptables-save > /etc/iptables/rules.v4', + /(RedHat|CentOS)/ => '/sbin/iptables-save > /etc/sysconfig/iptables', + }, + refreshonly => true, + } + Firewall { + notify => Exec['persist-firewall'], + before => Class['my_fw::post'], + require => Class['my_fw::pre'], + } + Firewallchain { + notify => Exec['persist-firewall'], + } + resources { "firewall": + purge => true + } + +You only need: + + class { 'firewall': } + Firewall { + before => Class['my_fw::post'], + require => Class['my_fw::pre'], + } + +To install pre-requisites and to create dependencies on your pre & post rules. Consult the README for more information. + +##### Changes + +* Firewall class manifests (Dan Carley) +* Firewall and firewallchain persistence (Dan Carley) +* (GH-134) Autorequire iptables related packages (Dan Carley) +* Typo in #persist_iptables OS normalisation (Dan Carley) +* Tests for #persist_iptables (Dan Carley) +* (GH-129) Replace errant return in autoreq block (Dan Carley) + +--------------------------------------- + +### 0.1.1 - 2012/2/28 + +This release primarily fixes changing parameters in 3.x + +##### Changes + +* (GH-128) Change method_missing usage to define_method for 3.x compatibility +* Update travis.yml gem specifications to actually test 2.6 +* Change source in Gemfile to use a specific URL for Ruby 2.0.0 compatibility + +--------------------------------------- + +### 0.1.0 - 2012/2/24 + +This release is somewhat belated, so no summary as there are far too many changes this time around. Hopefully we won't fall this far behind again :-). + +##### Changes + +* Add support for MARK target and set-mark property (Johan Huysmans) +* Fix broken call to super for ruby-1.9.2 in munge (Ken Barber) +* simple fix of the error message for allowed values of the jump property (Daniel Black) +* Adding OSPF(v3) protocol to puppetlabs-firewall (Arnoud Vermeer) +* Display multi-value: port, sport, dport and state command seperated (Daniel Black) +* Require jump=>LOG for log params (Daniel Black) +* Reject and document icmp => "any" (Dan Carley) +* add firewallchain type and iptables_chain provider (Daniel Black) +* Various fixes for firewallchain resource (Ken Barber) +* Modify firewallchain name to be chain:table:protocol (Ken Barber) +* Fix allvalidchain iteration (Ken Barber) +* Firewall autorequire Firewallchains (Dan Carley) +* Tests and docstring for chain autorequire (Dan Carley) +* Fix README so setup instructions actually work (Ken Barber) +* Support vlan interfaces (interface containing ".") (Johan Huysmans) +* Add tests for VLAN support for iniface/outiface (Ken Barber) +* Add the table when deleting rules (Johan Huysmans) +* Fix tests since we are now prefixing -t) +* Changed 'jump' to 'action', commands to lower case (Jason Short) +* Support interface names containing "+" (Simon Deziel) +* Fix for when iptables-save spews out "FATAL" errors (Sharif Nassar) +* Fix for incorrect limit command arguments for ip6tables provider (Michael Hsu) +* Document Util::Firewall.host_to_ip (Dan Carley) +* Nullify addresses with zero prefixlen (Dan Carley) +* Add support for --tcp-flags (Thomas Vander Stichele) +* Make tcp_flags support a feature (Ken Barber) +* OUTPUT is a valid chain for the mangle table (Adam Gibbins) +* Enable travis-ci support (Ken Barber) +* Convert an existing test to CIDR (Dan Carley) +* Normalise iptables-save to CIDR (Dan Carley) +* be clearer about what distributions we support (Ken Barber) +* add gre protocol to list of acceptable protocols (Jason Hancock) +* Added pkttype property (Ashley Penney) +* Fix mark to not repeat rules with iptables 1.4.1+ (Sharif Nassar) +* Stub iptables_version for now so tests run on non-Linux hosts (Ken Barber) +* Stub iptables facts for set_mark tests (Dan Carley) +* Update formatting of README to meet Puppet Labs best practices (Will Hopper) +* Support for ICMP6 type code resolutions (Dan Carley) +* Insert order hash included chains from different tables (Ken Barber) +* rspec 2.11 compatibility (Jonathan Boyett) +* Add missing class declaration in README (sfozz) +* array_matching is contraindicated (Sharif Nassar) +* Convert port Fixnum into strings (Sharif Nassar) +* Update test framework to the modern age (Ken Barber) +* working with ip6tables support (wuwx) +* Remove gemfile.lock and add to gitignore (William Van Hevelingen) +* Update travis and gemfile to be like stdlib travis files (William Van Hevelingen) +* Add support for -m socket option (Ken Barber) +* Add support for single --sport and --dport parsing (Ken Barber) +* Fix tests for Ruby 1.9.3 from 3e13bf3 (Dan Carley) +* Mock Resolv.getaddress in #host_to_ip (Dan Carley) +* Update docs for source and dest - they are not arrays (Ken Barber) + +--------------------------------------- + +### 0.0.4 - 2011/12/05 + +This release adds two new parameters, 'uid' and 'gid'. As a part of the owner module, these params allow you to specify a uid, username, gid, or group got a match: + + firewall { '497 match uid': + port => '123', + proto => 'mangle', + chain => 'OUTPUT', + action => 'drop' + uid => '123' + } + +This release also adds value munging for the 'log_level', 'source', and 'destination' parameters. The 'source' and 'destination' now support hostnames: + + firewall { '498 accept from puppetlabs.com': + port => '123', + proto => 'tcp', + source => 'puppetlabs.com', + action => 'accept' + } + + +The 'log_level' parameter now supports using log level names, such as 'warn', 'debug', and 'panic': + + firewall { '499 logging': + port => '123', + proto => 'udp', + log_level => 'debug', + action => 'drop' + } + +Additional changes include iptables and ip6tables version facts, general whitespace cleanup, and adding additional unit tests. + +##### Changes + +* (#10957) add iptables_version and ip6tables_version facts +* (#11093) Improve log_level property so it converts names to numbers +* (#10723) Munge hostnames and IPs to IPs with CIDR +* (#10718) Add owner-match support +* (#10997) Add fixtures for ipencap +* (#11034) Whitespace cleanup +* (#10690) add port property support to ip6tables + +--------------------------------------- + +### 0.0.3 - 2011/11/12 + +This release introduces a new parameter 'port' which allows you to set both +source and destination ports for a match: + + firewall { "500 allow NTP requests": + port => "123", + proto => "udp", + action => "accept", + } + +We also have the limit parameter finally working: + + firewall { "500 limit HTTP requests": + dport => 80, + proto => tcp, + limit => "60/sec", + burst => 30, + action => accept, + } + +State ordering has been fixed now, and more characters are allowed in the +namevar: + +* Alphabetical +* Numbers +* Punctuation +* Whitespace + +##### Changes + +* (#10693) Ensure -m limit is added for iptables when using 'limit' param +* (#10690) Create new port property +* (#10700) allow additional characters in comment string +* (#9082) Sort iptables --state option values internally to keep it consistent across runs +* (#10324) Remove extraneous whitespace from iptables rule line in spec tests + +--------------------------------------- + +### 0.0.2 - 2011/10/26 + +This is largely a maintanence and cleanup release, but includes the ability to +specify ranges of ports in the sport/dport parameter: + + firewall { "500 allow port range": + dport => ["3000-3030","5000-5050"], + sport => ["1024-65535"], + action => "accept", + } + +##### Changes + +* (#10295) Work around bug #4248 whereby the puppet/util paths are not being loaded correctly on the puppetmaster +* (#10002) Change to dport and sport to handle ranges, and fix handling of name to name to port +* (#10263) Fix tests on Puppet 2.6.x +* (#10163) Cleanup some of the inline documentation and README file to align with general forge usage + +--------------------------------------- + +### 0.0.1 - 2011/10/18 + +Initial release. + +##### Changes + +* (#9362) Create action property and perform transformation for accept, drop, reject value for iptables jump parameter +* (#10088) Provide a customised version of CONTRIBUTING.md +* (#10026) Re-arrange provider and type spec files to align with Puppet +* (#10026) Add aliases for test,specs,tests to Rakefile and provide -T as default +* (#9439) fix parsing and deleting existing rules +* (#9583) Fix provider detection for gentoo and unsupported linuxes for the iptables provider +* (#9576) Stub provider so it works properly outside of Linux +* (#9576) Align spec framework with Puppet core +* and lots of other earlier development tasks ... diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/CONTRIBUTING.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/CONTRIBUTING.md new file mode 100644 index 0000000000..630ba8581e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/CONTRIBUTING.md @@ -0,0 +1,87 @@ +# How to contribute + +Third-party patches are essential for keeping puppet great. We simply can't +access the huge number of platforms and myriad configurations for running +puppet. We want to keep it as easy as possible to contribute changes that +get things working in your environment. There are a few guidelines that we +need contributors to follow so that we can have a chance of keeping on +top of things. + +## Getting Started + +* Make sure you have a [Jira account](http://tickets.puppetlabs.com) +* Make sure you have a [GitHub account](https://github.com/signup/free) +* Submit a ticket for your issue, assuming one does not already exist. + * Clearly describe the issue including steps to reproduce when it is a bug. + * Make sure you fill in the earliest version that you know has the issue. +* Fork the repository on GitHub + +## Making Changes + +* Create a topic branch from where you want to base your work. + * This is usually the master branch. + * Only target release branches if you are certain your fix must be on that + branch. + * To quickly create a topic branch based on master; `git branch + fix/master/my_contribution master` then checkout the new branch with `git + checkout fix/master/my_contribution`. Please avoid working directly on the + `master` branch. +* Make commits of logical units. +* Check for unnecessary whitespace with `git diff --check` before committing. +* Make sure your commit messages are in the proper format. + +```` + (MODULES-1234) Make the example in CONTRIBUTING imperative and concrete + + Without this patch applied the example commit message in the CONTRIBUTING + document is not a concrete example. This is a problem because the + contributor is left to imagine what the commit message should look like + based on a description rather than an example. This patch fixes the + problem by making the example concrete and imperative. + + The first line is a real life imperative statement with a ticket number + from our issue tracker. The body describes the behavior without the patch, + why this is a problem, and how the patch fixes the problem when applied. +```` + +* Make sure you have added the necessary tests for your changes. +* Run _all_ the tests to assure nothing else was accidentally broken. + +## Making Trivial Changes + +### Documentation + +For changes of a trivial nature to comments and documentation, it is not +always necessary to create a new ticket in Jira. In this case, it is +appropriate to start the first line of a commit with '(doc)' instead of +a ticket number. + +```` + (doc) Add documentation commit example to CONTRIBUTING + + There is no example for contributing a documentation commit + to the Puppet repository. This is a problem because the contributor + is left to assume how a commit of this nature may appear. + + The first line is a real life imperative statement with '(doc)' in + place of what would have been the ticket number in a + non-documentation related commit. The body describes the nature of + the new documentation or comments added. +```` + +## Submitting Changes + +* Sign the [Contributor License Agreement](http://links.puppetlabs.com/cla). +* Push your changes to a topic branch in your fork of the repository. +* Submit a pull request to the repository in the puppetlabs organization. +* Update your Jira ticket to mark that you have submitted code and are ready for it to be reviewed (Status: Ready for Merge). + * Include a link to the pull request in the ticket. + +# Additional Resources + +* [More information on contributing](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) +* [Bug tracker (Jira)](http://tickets.puppetlabs.com) +* [Contributor License Agreement](http://links.puppetlabs.com/cla) +* [General GitHub documentation](http://help.github.com/) +* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) +* #puppet-dev IRC channel on freenode.org diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/Gemfile new file mode 100644 index 0000000000..9e6eaa5416 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/Gemfile @@ -0,0 +1,18 @@ +source ENV['GEM_SOURCE'] || "https://rubygems.org" + +group :development, :test do + gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-puppet', :require => false + gem 'serverspec', :require => false + gem 'beaker-rspec', :require => false + gem 'puppet-lint', :require => false + gem 'pry', :require => false +end + +if puppetversion = ENV['PUPPET_GEM_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end + +# vim:ft=ruby diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/LICENSE new file mode 100644 index 0000000000..1d196fc30c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/LICENSE @@ -0,0 +1,25 @@ +Puppet Firewall Module - Puppet module for managing Firewalls + +Copyright (C) 2011-2013 Puppet Labs, Inc. +Copyright (C) 2011 Jonathan Boyett +Copyright (C) 2011 Media Temple, Inc. + +Some of the iptables code was taken from puppet-iptables which was: + +Copyright (C) 2011 Bob.sh Limited +Copyright (C) 2008 Camptocamp Association +Copyright (C) 2007 Dmitri Priimak + +Puppet Labs can be contacted at: info@puppetlabs.com + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/Modulefile new file mode 100644 index 0000000000..975614762f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/Modulefile @@ -0,0 +1,8 @@ +name 'puppetlabs-firewall' +version '1.1.1' +source 'git://github.com/puppetlabs/puppetlabs-firewall.git' +author 'puppetlabs' +license 'ASL 2.0' +summary 'Firewall Module' +description 'Manages Firewalls such as iptables' +project_page 'http://forge.puppetlabs.com/puppetlabs/firewall' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/README.markdown b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/README.markdown new file mode 100644 index 0000000000..24705149e7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/README.markdown @@ -0,0 +1,429 @@ +#firewall + +[](https://travis-ci.org/puppetlabs/puppetlabs-firewall) + +####Table of Contents + +1. [Overview - What is the Firewall module?](#overview) +2. [Module Description - What does the module do?](#module-description) +3. [Setup - The basics of getting started with Firewall](#setup) + * [What Firewall affects](#what-firewall-affects) + * [Setup Requirements](#setup-requirements) + * [Beginning with Firewall](#beginning-with-firewall) + * [Upgrading](#upgrading) +4. [Usage - Configuration and customization options](#usage) + * [Default rules - Setting up general configurations for all firewalls](#default-rules) + * [Application-specific rules - Options for configuring and managing firewalls across applications](#application-specific-rules) + * [Other Rules](#other-rules) +5. [Reference - An under-the-hood peek at what the module is doing](#reference) +6. [Limitations - OS compatibility, etc.](#limitations) +7. [Development - Guide for contributing to the module](#development) + * [Tests - Testing your configuration](#tests) + +##Overview + +The Firewall module lets you manage firewall rules with Puppet. + +##Module Description + +PuppetLabs' Firewall introduces the resource `firewall`, which is used to manage and configure firewall rules from within the Puppet DSL. This module offers support for iptables, ip6tables, and ebtables. + +The module also introduces the resource `firewallchain`, which allows you to manage chains or firewall lists. At the moment, only iptables and ip6tables chains are supported. + +##Setup + +###What Firewall affects: + +* every node running a firewall +* system's firewall settings +* connection settings for managed nodes +* unmanaged resources (get purged) +* site.pp + +###Setup Requirements + +Firewall uses Ruby-based providers, so you must have [pluginsync enabled](http://docs.puppetlabs.com/guides/plugins_in_modules.html#enabling-pluginsync). + +###Beginning with Firewall + +To begin, you need to provide some initial top-scope configuration to ensure your firewall configurations are ordered properly and you do not lock yourself out of your box or lose any configuration. + +Persistence of rules between reboots is handled automatically, although there are known issues with ip6tables on older Debian/Ubuntu, as well as known issues with ebtables. + +In your `site.pp` (or some similarly top-scope file), set up a metatype to purge unmanaged firewall resources. This will clear any existing rules and make sure that only rules defined in Puppet exist on the machine. + + resources { "firewall": + purge => true + } + +Next, set up the default parameters for all of the firewall rules you will be establishing later. These defaults will ensure that the pre and post classes (you will be setting up in just a moment) are run in the correct order to avoid locking you out of your box during the first puppet run. + + Firewall { + before => Class['my_fw::post'], + require => Class['my_fw::pre'], + } + +You also need to declare the `my_fw::pre` & `my_fw::post` classes so that dependencies are satisfied. This can be achieved using an External Node Classifier or the following + + class { ['my_fw::pre', 'my_fw::post']: } + +Finally, you should include the `firewall` class to ensure the correct packages are installed. + + class { 'firewall': } + +Now to create the `my_fw::pre` and `my_fw::post` classes. Firewall acts on your running firewall, making immediate changes as the catalog executes. Defining default pre and post rules allows you provide global defaults for your hosts before and after any custom rules; it is also required to avoid locking yourself out of your own boxes when Puppet runs. This approach employs a whitelist setup, so you can define what rules you want and everything else is ignored rather than removed. + +The `pre` class should be located in `my_fw/manifests/pre.pp` and should contain any default rules to be applied first. + + class my_fw::pre { + Firewall { + require => undef, + } + + # Default firewall rules + firewall { '000 accept all icmp': + proto => 'icmp', + action => 'accept', + }-> + firewall { '001 accept all to lo interface': + proto => 'all', + iniface => 'lo', + action => 'accept', + }-> + firewall { '002 accept related established rules': + proto => 'all', + state => ['RELATED', 'ESTABLISHED'], + action => 'accept', + } + } + +The rules in `pre` should allow basic networking (such as ICMP and TCP), as well as ensure that existing connections are not closed. + +The `post` class should be located in `my_fw/manifests/post.pp` and include any default rules to be applied last. + + class my_fw::post { + firewall { '999 drop all': + proto => 'all', + action => 'drop', + before => undef, + } + } + +To put it all together: the `require` parameter in `Firewall {}` ensures `my_fw::pre` is run before any other rules and the `before` parameter ensures `my_fw::post` is run after any other rules. So the run order is: + +* run the rules in `my_fw::pre` +* run your rules (defined in code) +* run the rules in `my_fw::post` + +###Upgrading + +####Upgrading from version 0.2.0 and newer + +Upgrade the module with the puppet module tool as normal: + + puppet module upgrade puppetlabs/firewall + +####Upgrading from version 0.1.1 and older + +Start by upgrading the module using the puppet module tool: + + puppet module upgrade puppetlabs/firewall + +Previously, you would have required the following in your `site.pp` (or some other global location): + + # Always persist firewall rules + exec { 'persist-firewall': + command => $operatingsystem ? { + 'debian' => '/sbin/iptables-save > /etc/iptables/rules.v4', + /(RedHat|CentOS)/ => '/sbin/iptables-save > /etc/sysconfig/iptables', + }, + refreshonly => true, + } + Firewall { + notify => Exec['persist-firewall'], + before => Class['my_fw::post'], + require => Class['my_fw::pre'], + } + Firewallchain { + notify => Exec['persist-firewall'], + } + resources { "firewall": + purge => true + } + +With the latest version, we now have in-built persistence, so this is no longer needed. However, you will still need some basic setup to define pre & post rules. + + resources { "firewall": + purge => true + } + Firewall { + before => Class['my_fw::post'], + require => Class['my_fw::pre'], + } + class { ['my_fw::pre', 'my_fw::post']: } + class { 'firewall': } + +Consult the the documentation below for more details around the classes `my_fw::pre` and `my_fw::post`. + +##Usage + +There are two kinds of firewall rules you can use with Firewall: default rules and application-specific rules. Default rules apply to general firewall settings, whereas application-specific rules manage firewall settings of a specific application, node, etc. + +All rules employ a numbering system in the resource's title that is used for ordering. When titling your rules, make sure you prefix the rule with a number. + + 000 this runs first + 999 this runs last + +###Default rules + +You can place default rules in either `my_fw::pre` or `my_fw::post`, depending on when you would like them to run. Rules placed in the `pre` class will run first, rules in the `post` class, last. + +Depending on the provider, the title of the rule can be stored using the comment feature of the underlying firewall subsystem. Values can match `/^\d+[[:alpha:][:digit:][:punct:][:space:]]+$/`. + +####Examples of default rules + +Basic accept ICMP request example: + + firewall { "000 accept all icmp requests": + proto => "icmp", + action => "accept", + } + +Drop all: + + firewall { "999 drop all other requests": + action => "drop", + } + +###Application-specific rules + +Puppet doesn't care where you define rules, and this means that you can place +your firewall resources as close to the applications and services that you +manage as you wish. If you use the [roles and profiles +pattern](https://puppetlabs.com/learn/roles-profiles-introduction) then it +would make sense to create your firewall rules in the profiles, so that they +remain close to the services managed by the profile. + +An example of this might be: + +```puppet +class profile::apache { + include apache + apache::vhost { 'mysite': ensure => present } + + firewall { '100 allow http and https access': + port => [80, 443], + proto => tcp, + action => accept, + } +} +``` + + +However, if you're not using that pattern then you can place them directly into +the individual module that manages a service, such as: + +```puppet +class apache { + firewall { '100 allow http and https access': + port => [80, 443], + proto => tcp, + action => accept, + } + # ... the rest of your code ... +} +``` + +This means if someone includes either the profile: + +```puppet +include profile::apache +``` + +Or the module, if you're not using roles and profiles: + +```puppet + include ::apache +``` + +Then they would automatically get appropriate firewall rules. + +###Other rules + +You can also apply firewall rules to specific nodes. Usually, you will want to put the firewall rule in another class and apply that class to a node. But you can apply a rule to a node. + + node 'foo.bar.com' { + firewall { '111 open port 111': + dport => 111 + } + } + +You can also do more complex things with the `firewall` resource. Here we are doing some NAT configuration. + + firewall { '100 snat for network foo2': + chain => 'POSTROUTING', + jump => 'MASQUERADE', + proto => 'all', + outiface => "eth0", + source => '10.1.2.0/24', + table => 'nat', + } + +In the below example, we are creating a new chain and forwarding any port 5000 access to it. + + firewall { '100 forward to MY_CHAIN': + chain => 'INPUT', + jump => 'MY_CHAIN', + } + # The namevar here is in the format chain_name:table:protocol + firewallchain { 'MY_CHAIN:filter:IPv4': + ensure => present, + } + firewall { '100 my rule': + chain => 'MY_CHAIN', + action => 'accept', + proto => 'tcp', + dport => 5000, + } + +###Additional Information + +You can access the inline documentation: + + puppet describe firewall + +Or + + puppet doc -r type + (and search for firewall) + +##Reference + +Classes: + +* [firewall](#class-firewall) + +Types: + +* [firewall](#type-firewall) +* [firewallchain](#type-firewallchain) + +Facts: + +* [ip6tables_version](#fact-ip6tablesversion) +* [iptables_version](#fact-iptablesversion) +* [iptables_persistent_version](#fact-iptablespersistentversion) + +###Class: firewall + +This class is provided to do the basic setup tasks required for using the firewall resources. + +At the moment this takes care of: + +* iptables-persistent package installation + +You should include the class for nodes that need to use the resources in this module. For example + + class { 'firewall': } + +####`ensure` + +Indicates the state of `iptables` on your system, allowing you to disable `iptables` if desired. + +Can either be `running` or `stopped`. Default to `running`. + +###Type: firewall + +This type provides the capability to manage firewall rules within puppet. + +For more documentation on the type, access the 'Types' tab on the Puppet Labs Forge: + + + +###Type:: firewallchain + +This type provides the capability to manage rule chains for firewalls. + +For more documentation on the type, access the 'Types' tab on the Puppet Labs Forge: + + + +###Fact: ip6tables_version + +The module provides a Facter fact that can be used to determine what the default version of ip6tables is for your operating system/distribution. + +###Fact: iptables_version + +The module provides a Facter fact that can be used to determine what the default version of iptables is for your operating system/distribution. + +###Fact: iptables_persistent_version + +Retrieves the version of iptables-persistent from your OS. This is a Debian/Ubuntu specific fact. + +##Limitations + +###SLES + +The `socket` parameter is not supported on SLES. In this release it will cause +the catalog to fail with iptables failures, rather than correctly warn you that +the features are unusable. + +###Oracle Enterprise Linux + +The `socket` and `owner` parameters are unsupported on Oracle Enterprise Linux +when the "Unbreakable" kernel is used. These may function correctly when using +the stock RedHat kernel instead. Declaring either of these parameters on an +unsupported system will result in iptable rules failing to apply. + +###Other + +Bugs can be reported using JIRA issues + + + +##Development + +Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. + +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) + +For this particular module, please also read CONTRIBUTING.md before contributing. + +Currently we support: + +* iptables +* ip6tables +* ebtables (chains only) + +But plans are to support lots of other firewall implementations: + +* FreeBSD (ipf) +* Mac OS X (ipfw) +* OpenBSD (pf) +* Cisco (ASA and basic access lists) + +If you have knowledge in these technologies, know how to code, and wish to contribute to this project, we would welcome the help. + +###Testing + +Make sure you have: + +* rake +* bundler + +Install the necessary gems: + + bundle install + +And run the tests from the root of the source code: + + rake test + +If you have a copy of Vagrant 1.1.0 you can also run the system tests: + + RSPEC_SET=debian-606-x64 rake spec:system + RSPEC_SET=centos-58-x64 rake spec:system + +*Note:* system testing is fairly alpha at this point, your mileage may vary. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/Rakefile new file mode 100644 index 0000000000..8b12070304 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/Rakefile @@ -0,0 +1,14 @@ +require 'puppetlabs_spec_helper/rake_tasks' + +require 'puppet-lint/tasks/puppet-lint' +PuppetLint.configuration.ignore_paths = ['vendor/**/*.pp'] + +task :default do + sh %{rake -T} +end + +desc 'Run reasonably quick tests for CI' +task :ci => [ + :lint, + :spec, +] diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/facter/ip6tables_version.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/facter/ip6tables_version.rb new file mode 100644 index 0000000000..3dce27f70c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/facter/ip6tables_version.rb @@ -0,0 +1,11 @@ +Facter.add(:ip6tables_version) do + confine :kernel => :linux + setcode do + version = Facter::Util::Resolution.exec('ip6tables --version') + if version + version.match(/\d+\.\d+\.\d+/).to_s + else + nil + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/facter/iptables_persistent_version.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/facter/iptables_persistent_version.rb new file mode 100644 index 0000000000..80bf9dea1a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/facter/iptables_persistent_version.rb @@ -0,0 +1,15 @@ +Facter.add(:iptables_persistent_version) do + confine :operatingsystem => %w{Debian Ubuntu} + setcode do + # Throw away STDERR because dpkg >= 1.16.7 will make some noise if the + # package isn't currently installed. + cmd = "dpkg-query -Wf '${Version}' iptables-persistent 2>/dev/null" + version = Facter::Util::Resolution.exec(cmd) + + if version.nil? or !version.match(/\d+\.\d+/) + nil + else + version + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/facter/iptables_version.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/facter/iptables_version.rb new file mode 100644 index 0000000000..6f7ae56474 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/facter/iptables_version.rb @@ -0,0 +1,11 @@ +Facter.add(:iptables_version) do + confine :kernel => :linux + setcode do + version = Facter::Util::Resolution.exec('iptables --version') + if version + version.match(/\d+\.\d+\.\d+/).to_s + else + nil + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewall.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewall.rb new file mode 100644 index 0000000000..c6b0b10bb1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewall.rb @@ -0,0 +1,34 @@ +class Puppet::Provider::Firewall < Puppet::Provider + + # Prefetch our rule list. This is ran once every time before any other + # action (besides initialization of each object). + def self.prefetch(resources) + debug("[prefetch(resources)]") + instances.each do |prov| + if resource = resources[prov.name] || resources[prov.name.downcase] + resource.provider = prov + end + end + end + + # Look up the current status. This allows us to conventiently look up + # existing status with properties[:foo]. + def properties + if @property_hash.empty? + @property_hash = query || {:ensure => :absent} + @property_hash[:ensure] = :absent if @property_hash.empty? + end + @property_hash.dup + end + + # Pull the current state of the list from the full list. We're + # getting some double entendre here.... + def query + self.class.instances.each do |instance| + if instance.name == self.name or instance.name.downcase == self.name + return instance.properties + end + end + nil + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewall/ip6tables.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewall/ip6tables.rb new file mode 100644 index 0000000000..e1ce01af6a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewall/ip6tables.rb @@ -0,0 +1,136 @@ +Puppet::Type.type(:firewall).provide :ip6tables, :parent => :iptables, :source => :iptables do + @doc = "Ip6tables type provider" + + has_feature :iptables + has_feature :connection_limiting + has_feature :hop_limiting + has_feature :rate_limiting + has_feature :recent_limiting + has_feature :snat + has_feature :dnat + has_feature :interface_match + has_feature :icmp_match + has_feature :owner + has_feature :state_match + has_feature :reject_type + has_feature :log_level + has_feature :log_prefix + has_feature :mark + has_feature :tcp_flags + has_feature :pkttype + has_feature :ishasmorefrags + has_feature :islastfrag + has_feature :isfirstfrag + + optional_commands({ + :ip6tables => 'ip6tables', + :ip6tables_save => 'ip6tables-save', + }) + + def initialize(*args) + if Facter.fact('ip6tables_version').value.match /1\.3\.\d/ + raise ArgumentError, 'The ip6tables provider is not supported on version 1.3 of iptables' + else + super + end + end + + def self.iptables(*args) + ip6tables(*args) + end + + def self.iptables_save(*args) + ip6tables_save(*args) + end + + @protocol = "IPv6" + + @resource_map = { + :burst => "--limit-burst", + :connlimit_above => "-m connlimit --connlimit-above", + :connlimit_mask => "--connlimit-mask", + :connmark => "-m connmark --mark", + :ctstate => "-m conntrack --ctstate", + :destination => "-d", + :dport => "-m multiport --dports", + :gid => "-m owner --gid-owner", + :icmp => "-m icmp6 --icmpv6-type", + :iniface => "-i", + :jump => "-j", + :hop_limit => "-m hl --hl-eq", + :limit => "-m limit --limit", + :log_level => "--log-level", + :log_prefix => "--log-prefix", + :name => "-m comment --comment", + :outiface => "-o", + :port => '-m multiport --ports', + :proto => "-p", + :rdest => "--rdest", + :reap => "--reap", + :recent => "-m recent", + :reject => "--reject-with", + :rhitcount => "--hitcount", + :rname => "--name", + :rseconds => "--seconds", + :rsource => "--rsource", + :rttl => "--rttl", + :source => "-s", + :state => "-m state --state", + :sport => "-m multiport --sports", + :table => "-t", + :todest => "--to-destination", + :toports => "--to-ports", + :tosource => "--to-source", + :uid => "-m owner --uid-owner", + :pkttype => "-m pkttype --pkt-type", + :ishasmorefrags => "-m frag --fragid 0 --fragmore", + :islastfrag => "-m frag --fragid 0 --fraglast", + :isfirstfrag => "-m frag --fragid 0 --fragfirst", + } + + # These are known booleans that do not take a value, but we want to munge + # to true if they exist. + @known_booleans = [:ishasmorefrags, :islastfrag, :isfirstfrag, :rsource, :rdest, :reap, :rttl] + + # Create property methods dynamically + (@resource_map.keys << :chain << :table << :action).each do |property| + if @known_booleans.include?(property) then + # The boolean properties default to '' which should be read as false + define_method "#{property}" do + @property_hash[property] = :false if @property_hash[property] == nil + @property_hash[property.to_sym] + end + else + define_method "#{property}" do + @property_hash[property.to_sym] + end + end + + if property == :chain + define_method "#{property}=" do |value| + if @property_hash[:chain] != value + raise ArgumentError, "Modifying the chain for existing rules is not supported." + end + end + else + define_method "#{property}=" do |value| + @property_hash[:needs_change] = true + end + end + end + + # This is the order of resources as they appear in iptables-save output, + # we need it to properly parse and apply rules, if the order of resource + # changes between puppet runs, the changed rules will be re-applied again. + # This order can be determined by going through iptables source code or just tweaking and trying manually + # (Note: on my CentOS 6.4 ip6tables-save returns -m frag on the place + # I put it when calling the command. So compability with manual changes + # not provided with current parser [georg.koester]) + @resource_list = [:table, :source, :destination, :iniface, :outiface, + :proto, :ishasmorefrags, :islastfrag, :isfirstfrag, :gid, :uid, :sport, :dport, + :port, :pkttype, :name, :state, :ctstate, :icmp, :hop_limit, :limit, :burst, + :recent, :rseconds, :reap, :rhitcount, :rttl, :rname, :rsource, :rdest, + :jump, :todest, :tosource, :toports, :log_level, :log_prefix, :reject, + :connlimit_above, :connlimit_mask, :connmark] + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewall/iptables.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewall/iptables.rb new file mode 100644 index 0000000000..5ad10125d7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewall/iptables.rb @@ -0,0 +1,501 @@ +require 'puppet/provider/firewall' +require 'digest/md5' + +Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Firewall do + include Puppet::Util::Firewall + + @doc = "Iptables type provider" + + has_feature :iptables + has_feature :connection_limiting + has_feature :rate_limiting + has_feature :recent_limiting + has_feature :snat + has_feature :dnat + has_feature :interface_match + has_feature :icmp_match + has_feature :owner + has_feature :state_match + has_feature :reject_type + has_feature :log_level + has_feature :log_prefix + has_feature :mark + has_feature :tcp_flags + has_feature :pkttype + has_feature :isfragment + has_feature :socket + has_feature :address_type + has_feature :iprange + has_feature :ipsec_dir + has_feature :ipsec_policy + has_feature :mask + + optional_commands({ + :iptables => 'iptables', + :iptables_save => 'iptables-save', + }) + + defaultfor :kernel => :linux + + iptables_version = Facter.fact('iptables_version').value + if (iptables_version and Puppet::Util::Package.versioncmp(iptables_version, '1.4.1') < 0) + mark_flag = '--set-mark' + else + mark_flag = '--set-xmark' + end + + @protocol = "IPv4" + + @resource_map = { + :burst => "--limit-burst", + :connlimit_above => "-m connlimit --connlimit-above", + :connlimit_mask => "--connlimit-mask", + :connmark => "-m connmark --mark", + :ctstate => "-m conntrack --ctstate", + :destination => "-d", + :dst_type => "-m addrtype --dst-type", + :dst_range => "-m iprange --dst-range", + :dport => ["-m multiport --dports", "--dport"], + :gid => "-m owner --gid-owner", + :icmp => "-m icmp --icmp-type", + :iniface => "-i", + :jump => "-j", + :limit => "-m limit --limit", + :log_level => "--log-level", + :log_prefix => "--log-prefix", + :name => "-m comment --comment", + :outiface => "-o", + :port => '-m multiport --ports', + :proto => "-p", + :random => "--random", + :rdest => "--rdest", + :reap => "--reap", + :recent => "-m recent", + :reject => "--reject-with", + :rhitcount => "--hitcount", + :rname => "--name", + :rseconds => "--seconds", + :rsource => "--rsource", + :rttl => "--rttl", + :set_mark => mark_flag, + :socket => "-m socket", + :source => "-s", + :src_type => "-m addrtype --src-type", + :src_range => "-m iprange --src-range", + :sport => ["-m multiport --sports", "--sport"], + :state => "-m state --state", + :table => "-t", + :tcp_flags => "-m tcp --tcp-flags", + :todest => "--to-destination", + :toports => "--to-ports", + :tosource => "--to-source", + :uid => "-m owner --uid-owner", + :pkttype => "-m pkttype --pkt-type", + :isfragment => "-f", + :ipsec_dir => "-m policy --dir", + :ipsec_policy => "--pol", + :mask => '--mask', + } + + # These are known booleans that do not take a value, but we want to munge + # to true if they exist. + @known_booleans = [ + :isfragment, + :random, + :rdest, + :reap, + :rsource, + :rttl, + :socket + ] + + + # Create property methods dynamically + (@resource_map.keys << :chain << :table << :action).each do |property| + if @known_booleans.include?(property) then + # The boolean properties default to '' which should be read as false + define_method "#{property}" do + @property_hash[property] = :false if @property_hash[property] == nil + @property_hash[property.to_sym] + end + else + define_method "#{property}" do + @property_hash[property.to_sym] + end + end + + if property == :chain + define_method "#{property}=" do |value| + if @property_hash[:chain] != value + raise ArgumentError, "Modifying the chain for existing rules is not supported." + end + end + else + define_method "#{property}=" do |value| + @property_hash[:needs_change] = true + end + end + end + + # This is the order of resources as they appear in iptables-save output, + # we need it to properly parse and apply rules, if the order of resource + # changes between puppet runs, the changed rules will be re-applied again. + # This order can be determined by going through iptables source code or just tweaking and trying manually + @resource_list = [ + :table, :source, :destination, :iniface, :outiface, :proto, :isfragment, + :src_range, :dst_range, :tcp_flags, :gid, :uid, :sport, :dport, :port, + :dst_type, :src_type, :socket, :pkttype, :name, :ipsec_dir, :ipsec_policy, + :state, :ctstate, :icmp, :limit, :burst, :recent, :rseconds, :reap, + :rhitcount, :rttl, :rname, :mask, :rsource, :rdest, :jump, :todest, + :tosource, :toports, :random, :log_prefix, :log_level, :reject, :set_mark, + :connlimit_above, :connlimit_mask, :connmark + ] + + def insert + debug 'Inserting rule %s' % resource[:name] + iptables insert_args + end + + def update + debug 'Updating rule %s' % resource[:name] + iptables update_args + end + + def delete + debug 'Deleting rule %s' % resource[:name] + iptables delete_args + end + + def exists? + properties[:ensure] != :absent + end + + # Flush the property hash once done. + def flush + debug("[flush]") + if @property_hash.delete(:needs_change) + notice("Properties changed - updating rule") + update + end + persist_iptables(self.class.instance_variable_get(:@protocol)) + @property_hash.clear + end + + def self.instances + debug "[instances]" + table = nil + rules = [] + counter = 1 + + # String#lines would be nice, but we need to support Ruby 1.8.5 + iptables_save.split("\n").each do |line| + unless line =~ /^\#\s+|^\:\S+|^COMMIT|^FATAL/ + if line =~ /^\*/ + table = line.sub(/\*/, "") + else + if hash = rule_to_hash(line, table, counter) + rules << new(hash) + counter += 1 + end + end + end + end + rules + end + + def self.rule_to_hash(line, table, counter) + hash = {} + keys = [] + values = line.dup + + #################### + # PRE-PARSE CLUDGING + #################### + + # --tcp-flags takes two values; we cheat by adding " around it + # so it behaves like --comment + values = values.sub(/--tcp-flags (\S*) (\S*)/, '--tcp-flags "\1 \2"') + # we do a similar thing for negated address masks (source and destination). + values = values.sub(/(-\S+) (!)\s?(\S*)/,'\1 "\2 \3"') + # the actual rule will have the ! mark before the option. + values = values.sub(/(!)\s*(-\S+)\s*(\S*)/, '\2 "\1 \3"') + # The match extension for tcp & udp are optional and throws off the @resource_map. + values = values.sub(/-m (tcp|udp) (--(s|d)port|-m multiport)/, '\2') + + # Trick the system for booleans + @known_booleans.each do |bool| + # append "true" because all params are expected to have values + if bool == :isfragment then + # -f requires special matching: + # only replace those -f that are not followed by an l to + # distinguish between -f and the '-f' inside of --tcp-flags. + values = values.sub(/-f(?!l)(?=.*--comment)/, '-f true') + else + values = values.sub(/#{@resource_map[bool]}/, "#{@resource_map[bool]} true") + end + end + + ############ + # Populate parser_list with used value, in the correct order + ############ + map_index={} + @resource_map.each_pair do |map_k,map_v| + [map_v].flatten.each do |v| + ind=values.index(/\s#{v}/) + next unless ind + map_index[map_k]=ind + end + end + # Generate parser_list based on the index of the found option + parser_list=[] + map_index.sort_by{|k,v| v}.each{|mapi| parser_list << mapi.first } + + ############ + # MAIN PARSE + ############ + + # Here we iterate across our values to generate an array of keys + parser_list.reverse.each do |k| + resource_map_key = @resource_map[k] + [resource_map_key].flatten.each do |opt| + if values.slice!(/\s#{opt}/) + keys << k + break + end + end + end + + # Manually remove chain + values.slice!('-A') + keys << :chain + + # Here we generate the main hash + keys.zip(values.scan(/"[^"]*"|\S+/).reverse) { |f, v| hash[f] = v.gsub(/"/, '') } + + ##################### + # POST PARSE CLUDGING + ##################### + + # Normalise all rules to CIDR notation. + [:source, :destination].each do |prop| + next if hash[prop].nil? + m = hash[prop].match(/(!?)\s?(.*)/) + neg = "! " if m[1] == "!" + hash[prop] = "#{neg}#{Puppet::Util::IPCidr.new(m[2]).cidr}" + end + + [:dport, :sport, :port, :state, :ctstate].each do |prop| + hash[prop] = hash[prop].split(',') if ! hash[prop].nil? + end + + # Convert booleans removing the previous cludge we did + @known_booleans.each do |bool| + if hash[bool] != nil then + if hash[bool] != "true" then + raise "Parser error: #{bool} was meant to be a boolean but received value: #{hash[bool]}." + end + end + end + + # Our type prefers hyphens over colons for ranges so ... + # Iterate across all ports replacing colons with hyphens so that ranges match + # the types expectations. + [:dport, :sport, :port].each do |prop| + next unless hash[prop] + hash[prop] = hash[prop].collect do |elem| + elem.gsub(/:/,'-') + end + end + + # States should always be sorted. This ensures that the output from + # iptables-save and user supplied resources is consistent. + hash[:state] = hash[:state].sort unless hash[:state].nil? + hash[:ctstate] = hash[:ctstate].sort unless hash[:ctstate].nil? + + # This forces all existing, commentless rules or rules with invalid comments to be moved + # to the bottom of the stack. + # Puppet-firewall requires that all rules have comments (resource names) and match this + # regex and will fail if a rule in iptables does not have a comment. We get around this + # by appending a high level + if ! hash[:name] + num = 9000 + counter + hash[:name] = "#{num} #{Digest::MD5.hexdigest(line)}" + elsif not /^\d+[[:alpha:][:digit:][:punct:][:space:]]+$/ =~ hash[:name] + num = 9000 + counter + hash[:name] = "#{num} #{/([[:alpha:][:digit:][:punct:][:space:]]+)/.match(hash[:name])[1]}" + end + + # Iptables defaults to log_level '4', so it is omitted from the output of iptables-save. + # If the :jump value is LOG and you don't have a log-level set, we assume it to be '4'. + if hash[:jump] == 'LOG' && ! hash[:log_level] + hash[:log_level] = '4' + end + + # Iptables defaults to burst '5', so it is ommitted from the output of iptables-save. + # If the :limit value is set and you don't have a burst set, we assume it to be '5'. + if hash[:limit] && ! hash[:burst] + hash[:burst] = '5' + end + + hash[:line] = line + hash[:provider] = self.name.to_s + hash[:table] = table + hash[:ensure] = :present + + # Munge some vars here ... + + # Proto should equal 'all' if undefined + hash[:proto] = "all" if !hash.include?(:proto) + + # If the jump parameter is set to one of: ACCEPT, REJECT or DROP then + # we should set the action parameter instead. + if ['ACCEPT','REJECT','DROP'].include?(hash[:jump]) then + hash[:action] = hash[:jump].downcase + hash.delete(:jump) + end + + hash + end + + def insert_args + args = [] + args << ["-I", resource[:chain], insert_order] + args << general_args + args + end + + def update_args + args = [] + args << ["-R", resource[:chain], insert_order] + args << general_args + args + end + + def delete_args + # Split into arguments + line = properties[:line].gsub(/\-A/, '-D').split(/\s(?=(?:[^"]|"[^"]*")*$)/).map{|v| v.gsub(/"/, '')} + line.unshift("-t", properties[:table]) + end + + # This method takes the resource, and attempts to generate the command line + # arguments for iptables. + def general_args + debug "Current resource: %s" % resource.class + + args = [] + resource_list = self.class.instance_variable_get('@resource_list') + resource_map = self.class.instance_variable_get('@resource_map') + known_booleans = self.class.instance_variable_get('@known_booleans') + + resource_list.each do |res| + resource_value = nil + if (resource[res]) then + resource_value = resource[res] + # If socket is true then do not add the value as -m socket is standalone + if known_booleans.include?(res) then + if resource[res] == :true then + resource_value = nil + else + # If the property is not :true then we don't want to add the value + # to the args list + next + end + end + elsif res == :jump and resource[:action] then + # In this case, we are substituting jump for action + resource_value = resource[:action].to_s.upcase + else + next + end + + args << [resource_map[res]].flatten.first.split(' ') + + # On negations, the '!' has to be before the option (eg: "! -d 1.2.3.4") + if resource_value.is_a?(String) and resource_value.sub!(/^!\s*/, '') then + # we do this after adding the 'dash' argument because of ones like "-m multiport --dports", where we want it before the "--dports" but after "-m multiport". + # so we insert before whatever the last argument is + args.insert(-2, '!') + end + + + # For sport and dport, convert hyphens to colons since the type + # expects hyphens for ranges of ports. + if [:sport, :dport, :port].include?(res) then + resource_value = resource_value.collect do |elem| + elem.gsub(/-/, ':') + end + end + + # our tcp_flags takes a single string with comma lists separated + # by space + # --tcp-flags expects two arguments + if res == :tcp_flags + one, two = resource_value.split(' ') + args << one + args << two + elsif resource_value.is_a?(Array) + args << resource_value.join(',') + elsif !resource_value.nil? + args << resource_value + end + end + + args + end + + def insert_order + debug("[insert_order]") + rules = [] + + # Find list of current rules based on chain and table + self.class.instances.each do |rule| + if rule.chain == resource[:chain].to_s and rule.table == resource[:table].to_s + rules << rule.name + end + end + + # No rules at all? Just bail now. + return 1 if rules.empty? + + # Add our rule to the end of the array of known rules + my_rule = resource[:name].to_s + rules << my_rule + + unmanaged_rule_regex = /^9[0-9]{3}\s[a-f0-9]{32}$/ + # Find if this is a new rule or an existing rule, then find how many + # unmanaged rules preceed it. + if rules.length == rules.uniq.length + # This is a new rule so find its ordered location. + new_rule_location = rules.sort.uniq.index(my_rule) + if new_rule_location == 0 + # The rule will be the first rule in the chain because nothing came + # before it. + offset_rule = rules[0] + else + # This rule will come after other managed rules, so find the rule + # immediately preceeding it. + offset_rule = rules.sort.uniq[new_rule_location - 1] + end + else + # This is a pre-existing rule, so find the offset from the original + # ordering. + offset_rule = my_rule + end + # Count how many unmanaged rules are ahead of the target rule so we know + # how much to add to the insert order + unnamed_offset = rules[0..rules.index(offset_rule)].inject(0) do |sum,rule| + # This regex matches the names given to unmanaged rules (a number + # 9000-9999 followed by an MD5 hash). + sum + (rule.match(unmanaged_rule_regex) ? 1 : 0) + end + + # We want our rule to come before unmanaged rules if it's not a 9-rule + if offset_rule.match(unmanaged_rule_regex) and ! my_rule.match(/^9/) + unnamed_offset -= 1 + end + + # Insert our new or updated rule in the correct order of named rules, but + # offset for unnamed rules. + rules.reject{|r|r.match(unmanaged_rule_regex)}.sort.index(my_rule) + 1 + unnamed_offset + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewallchain/iptables_chain.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewallchain/iptables_chain.rb new file mode 100644 index 0000000000..29fbc1f6b8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/provider/firewallchain/iptables_chain.rb @@ -0,0 +1,178 @@ +Puppet::Type.type(:firewallchain).provide :iptables_chain do + include Puppet::Util::Firewall + + @doc = "Iptables chain provider" + + has_feature :iptables_chain + has_feature :policy + + optional_commands({ + :iptables => 'iptables', + :iptables_save => 'iptables-save', + :ip6tables => 'ip6tables', + :ip6tables_save => 'ip6tables-save', + :ebtables => 'ebtables', + :ebtables_save => 'ebtables-save', + }) + + defaultfor :kernel => :linux + + # chain name is greedy so we anchor from the end. + # [\d+:\d+] doesn't exist on ebtables + Mapping = { + :IPv4 => { + :tables => method(:iptables), + :save => method(:iptables_save), + :re => /^:(.+)\s(\S+)\s\[\d+:\d+\]$/, + }, + :IPv6 => { + :tables => method(:ip6tables), + :save => method(:ip6tables_save), + :re => /^:(.+)\s(\S+)\s\[\d+:\d+\]$/, + }, + :ethernet => { + :tables => method(:ebtables), + :save => method(:ebtables_save), + :re => /^:(.+)\s(\S+)$/, + } + } + InternalChains = /^(PREROUTING|POSTROUTING|BROUTING|INPUT|FORWARD|OUTPUT)$/ + Tables = 'nat|mangle|filter|raw|rawpost|broute' + Nameformat = /^(.+):(#{Tables}):(IP(v[46])?|ethernet)$/ + + def create + allvalidchains do |t, chain, table, protocol| + if chain =~ InternalChains + # can't create internal chains + warning "Attempting to create internal chain #{@resource[:name]}" + end + if properties[:ensure] == protocol + debug "Skipping Inserting chain #{chain} on table #{table} (#{protocol}) already exists" + else + debug "Inserting chain #{chain} on table #{table} (#{protocol}) using #{t}" + t.call ['-t',table,'-N',chain] + unless @resource[:policy].nil? + t.call ['-t',table,'-P',chain,@resource[:policy].to_s.upcase] + end + end + end + end + + def destroy + allvalidchains do |t, chain, table| + if chain =~ InternalChains + # can't delete internal chains + warning "Attempting to destroy internal chain #{@resource[:name]}" + end + debug "Deleting chain #{chain} on table #{table}" + t.call ['-t',table,'-X',chain] + end + end + + def exists? + allvalidchains do |t, chain| + if chain =~ InternalChains + # If the chain isn't present, it's likely because the module isn't loaded. + # If this is true, then we fall into 2 cases + # 1) It'll be loaded on demand + # 2) It won't be loaded on demand, and we throw an error + # This is the intended behavior as it's not the provider's job to load kernel modules + # So we pretend it exists... + return true + end + end + properties[:ensure] == :present + end + + def policy=(value) + return if value == :empty + allvalidchains do |t, chain, table| + p = ['-t',table,'-P',chain,value.to_s.upcase] + debug "[set policy] #{t} #{p}" + t.call p + end + end + + def policy + debug "[get policy] #{@resource[:name]} =#{@property_hash[:policy].to_s.downcase}" + return @property_hash[:policy].to_s.downcase + end + + def self.prefetch(resources) + debug("[prefetch(resources)]") + instances.each do |prov| + if resource = resources[prov.name] + resource.provider = prov + end + end + end + + def flush + debug("[flush]") + persist_iptables(@resource[:name].match(Nameformat)[3]) + # Clear the property hash so we re-initialize with updated values + @property_hash.clear + end + + # Look up the current status. This allows us to conventiently look up + # existing status with properties[:foo]. + def properties + if @property_hash.empty? + @property_hash = query || {:ensure => :absent} + end + @property_hash.dup + end + + # Pull the current state of the list from the full list. + def query + self.class.instances.each do |instance| + if instance.name == self.name + debug "query found #{self.name}" % instance.properties.inspect + return instance.properties + end + end + nil + end + + def self.instances + debug "[instances]" + table = nil + chains = [] + + Mapping.each { |p, c| + begin + c[:save].call.each_line do |line| + if line =~ c[:re] then + name = $1 + ':' + (table == 'filter' ? 'filter' : table) + ':' + p.to_s + policy = $2 == '-' ? nil : $2.downcase.to_sym + + chains << new({ + :name => name, + :policy => policy, + :ensure => :present, + }) + + debug "[instance] '#{name}' #{policy}" + elsif line =~ /^\*(\S+)/ + table = $1 + else + next + end + end + rescue Puppet::Error + # ignore command not found for ebtables or anything that doesn't exist + end + } + + chains + end + + def allvalidchains + @resource[:name].match(Nameformat) + chain = $1 + table = $2 + protocol = $3 + yield Mapping[protocol.to_sym][:tables],chain,table,protocol.to_sym + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/type/firewall.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/type/firewall.rb new file mode 100644 index 0000000000..22afbd21e2 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/type/firewall.rb @@ -0,0 +1,1077 @@ +# See: #10295 for more details. +# +# This is a workaround for bug: #4248 whereby ruby files outside of the normal +# provider/type path do not load until pluginsync has occured on the puppetmaster +# +# In this case I'm trying the relative path first, then falling back to normal +# mechanisms. This should be fixed in future versions of puppet but it looks +# like we'll need to maintain this for some time perhaps. +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..","..")) +require 'puppet/util/firewall' + +Puppet::Type.newtype(:firewall) do + include Puppet::Util::Firewall + + @doc = <<-EOS + This type provides the capability to manage firewall rules within + puppet. + + **Autorequires:** + + If Puppet is managing the iptables or ip6tables chains specified in the + `chain` or `jump` parameters, the firewall resource will autorequire + those firewallchain resources. + + If Puppet is managing the iptables or iptables-persistent packages, and + the provider is iptables or ip6tables, the firewall resource will + autorequire those packages to ensure that any required binaries are + installed. + EOS + + feature :connection_limiting, "Connection limiting features." + feature :hop_limiting, "Hop limiting features." + feature :rate_limiting, "Rate limiting features." + feature :recent_limiting, "The netfilter recent module" + feature :snat, "Source NATing" + feature :dnat, "Destination NATing" + feature :interface_match, "Interface matching" + feature :icmp_match, "Matching ICMP types" + feature :owner, "Matching owners" + feature :state_match, "Matching stateful firewall states" + feature :reject_type, "The ability to control reject messages" + feature :log_level, "The ability to control the log level" + feature :log_prefix, "The ability to add prefixes to log messages" + feature :mark, "Match or Set the netfilter mark value associated with the packet" + feature :tcp_flags, "The ability to match on particular TCP flag settings" + feature :pkttype, "Match a packet type" + feature :socket, "Match open sockets" + feature :isfragment, "Match fragments" + feature :address_type, "The ability match on source or destination address type" + feature :iprange, "The ability match on source or destination IP range " + feature :ishasmorefrags, "Match a non-last fragment of a fragmented ipv6 packet - might be first" + feature :islastfrag, "Match the last fragment of an ipv6 packet" + feature :isfirstfrag, "Match the first fragment of a fragmented ipv6 packet" + feature :ipsec_policy, "Match IPsec policy" + feature :ipsec_dir, "Match IPsec policy direction" + + # provider specific features + feature :iptables, "The provider provides iptables features." + + ensurable do + desc <<-EOS + Manage the state of this rule. The default action is *present*. + EOS + + newvalue(:present) do + provider.insert + end + + newvalue(:absent) do + provider.delete + end + + defaultto :present + end + + newparam(:name) do + desc <<-EOS + The canonical name of the rule. This name is also used for ordering + so make sure you prefix the rule with a number: + + 000 this runs first + 999 this runs last + + Depending on the provider, the name of the rule can be stored using + the comment feature of the underlying firewall subsystem. + EOS + isnamevar + + # Keep rule names simple - they must start with a number + newvalues(/^\d+[[:alpha:][:digit:][:punct:][:space:]]+$/) + end + + newproperty(:action) do + desc <<-EOS + This is the action to perform on a match. Can be one of: + + * accept - the packet is accepted + * reject - the packet is rejected with a suitable ICMP response + * drop - the packet is dropped + + If you specify no value it will simply match the rule but perform no + action unless you provide a provider specific parameter (such as *jump*). + EOS + newvalues(:accept, :reject, :drop) + end + + # Generic matching properties + newproperty(:source) do + desc <<-EOS + The source address. For example: + + source => '192.168.2.0/24' + + You can also negate a mask by putting ! in front. For example: + + source => '! 192.168.2.0/24' + + The source can also be an IPv6 address if your provider supports it. + EOS + + munge do |value| + begin + @resource.host_to_mask(value) + rescue Exception => e + self.fail("host_to_ip failed for #{value}, exception #{e}") + end + end + end + + # Source IP range + newproperty(:src_range, :required_features => :iprange) do + desc <<-EOS + The source IP range. For example: + + src_range => '192.168.1.1-192.168.1.10' + + The source IP range is must in 'IP1-IP2' format. + EOS + + newvalues(/^((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)-((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)/) + end + + newproperty(:destination) do + desc <<-EOS + The destination address to match. For example: + + destination => '192.168.1.0/24' + + You can also negate a mask by putting ! in front. For example: + + destination => '! 192.168.2.0/24' + + The destination can also be an IPv6 address if your provider supports it. + EOS + + munge do |value| + begin + @resource.host_to_mask(value) + rescue Exception => e + self.fail("host_to_ip failed for #{value}, exception #{e}") + end + end + end + + # Destination IP range + newproperty(:dst_range, :required_features => :iprange) do + desc <<-EOS + The destination IP range. For example: + + dst_range => '192.168.1.1-192.168.1.10' + + The destination IP range is must in 'IP1-IP2' format. + EOS + + newvalues(/^((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)-((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)/) + end + + newproperty(:sport, :array_matching => :all) do + desc <<-EOS + The source port to match for this filter (if the protocol supports + ports). Will accept a single element or an array. + + For some firewall providers you can pass a range of ports in the format: + + - + + For example: + + 1-1024 + + This would cover ports 1 to 1024. + EOS + + munge do |value| + @resource.string_to_port(value, :proto) + end + + def is_to_s(value) + should_to_s(value) + end + + def should_to_s(value) + value = [value] unless value.is_a?(Array) + value.join(',') + end + end + + newproperty(:dport, :array_matching => :all) do + desc <<-EOS + The destination port to match for this filter (if the protocol supports + ports). Will accept a single element or an array. + + For some firewall providers you can pass a range of ports in the format: + + - + + For example: + + 1-1024 + + This would cover ports 1 to 1024. + EOS + + munge do |value| + @resource.string_to_port(value, :proto) + end + + def is_to_s(value) + should_to_s(value) + end + + def should_to_s(value) + value = [value] unless value.is_a?(Array) + value.join(',') + end + end + + newproperty(:port, :array_matching => :all) do + desc <<-EOS + The destination or source port to match for this filter (if the protocol + supports ports). Will accept a single element or an array. + + For some firewall providers you can pass a range of ports in the format: + + - + + For example: + + 1-1024 + + This would cover ports 1 to 1024. + EOS + + munge do |value| + @resource.string_to_port(value, :proto) + end + + def is_to_s(value) + should_to_s(value) + end + + def should_to_s(value) + value = [value] unless value.is_a?(Array) + value.join(',') + end + end + + newproperty(:dst_type, :required_features => :address_type) do + desc <<-EOS + The destination address type. For example: + + dst_type => 'LOCAL' + + Can be one of: + + * UNSPEC - an unspecified address + * UNICAST - a unicast address + * LOCAL - a local address + * BROADCAST - a broadcast address + * ANYCAST - an anycast packet + * MULTICAST - a multicast address + * BLACKHOLE - a blackhole address + * UNREACHABLE - an unreachable address + * PROHIBIT - a prohibited address + * THROW - undocumented + * NAT - undocumented + * XRESOLVE - undocumented + EOS + + newvalues(:UNSPEC, :UNICAST, :LOCAL, :BROADCAST, :ANYCAST, :MULTICAST, + :BLACKHOLE, :UNREACHABLE, :PROHIBIT, :THROW, :NAT, :XRESOLVE) + end + + newproperty(:src_type, :required_features => :address_type) do + desc <<-EOS + The source address type. For example: + + src_type => 'LOCAL' + + Can be one of: + + * UNSPEC - an unspecified address + * UNICAST - a unicast address + * LOCAL - a local address + * BROADCAST - a broadcast address + * ANYCAST - an anycast packet + * MULTICAST - a multicast address + * BLACKHOLE - a blackhole address + * UNREACHABLE - an unreachable address + * PROHIBIT - a prohibited address + * THROW - undocumented + * NAT - undocumented + * XRESOLVE - undocumented + EOS + + newvalues(:UNSPEC, :UNICAST, :LOCAL, :BROADCAST, :ANYCAST, :MULTICAST, + :BLACKHOLE, :UNREACHABLE, :PROHIBIT, :THROW, :NAT, :XRESOLVE) + end + + newproperty(:proto) do + desc <<-EOS + The specific protocol to match for this rule. By default this is + *tcp*. + EOS + + newvalues(:tcp, :udp, :icmp, :"ipv6-icmp", :esp, :ah, :vrrp, :igmp, :ipencap, :ospf, :gre, :all) + defaultto "tcp" + end + + # tcp-specific + newproperty(:tcp_flags, :required_features => :tcp_flags) do + desc <<-EOS + Match when the TCP flags are as specified. + Is a string with a list of comma-separated flag names for the mask, + then a space, then a comma-separated list of flags that should be set. + The flags are: SYN ACK FIN RST URG PSH ALL NONE + Note that you specify them in the order that iptables --list-rules + would list them to avoid having puppet think you changed the flags. + Example: FIN,SYN,RST,ACK SYN matches packets with the SYN bit set and the + ACK,RST and FIN bits cleared. Such packets are used to request + TCP connection initiation. + EOS + end + + + # Iptables specific + newproperty(:chain, :required_features => :iptables) do + desc <<-EOS + Name of the chain to use. Can be one of the built-ins: + + * INPUT + * FORWARD + * OUTPUT + * PREROUTING + * POSTROUTING + + Or you can provide a user-based chain. + + The default value is 'INPUT'. + EOS + + defaultto "INPUT" + newvalue(/^[a-zA-Z0-9\-_]+$/) + end + + newproperty(:table, :required_features => :iptables) do + desc <<-EOS + Table to use. Can be one of: + + * nat + * mangle + * filter + * raw + * rawpost + + By default the setting is 'filter'. + EOS + + newvalues(:nat, :mangle, :filter, :raw, :rawpost) + defaultto "filter" + end + + newproperty(:jump, :required_features => :iptables) do + desc <<-EOS + The value for the iptables --jump parameter. Normal values are: + + * QUEUE + * RETURN + * DNAT + * SNAT + * LOG + * MASQUERADE + * REDIRECT + * MARK + + But any valid chain name is allowed. + + For the values ACCEPT, DROP and REJECT you must use the generic + 'action' parameter. This is to enfore the use of generic parameters where + possible for maximum cross-platform modelling. + + If you set both 'accept' and 'jump' parameters, you will get an error as + only one of the options should be set. + EOS + + validate do |value| + unless value =~ /^[a-zA-Z0-9\-_]+$/ + raise ArgumentError, <<-EOS + Jump destination must consist of alphanumeric characters, an + underscore or a yphen. + EOS + end + + if ["accept","reject","drop"].include?(value.downcase) + raise ArgumentError, <<-EOS + Jump destination should not be one of ACCEPT, REJECT or DROP. Use + the action property instead. + EOS + end + + end + end + + # Interface specific matching properties + newproperty(:iniface, :required_features => :interface_match) do + desc <<-EOS + Input interface to filter on. + EOS + newvalues(/^[a-zA-Z0-9\-\._\+]+$/) + end + + newproperty(:outiface, :required_features => :interface_match) do + desc <<-EOS + Output interface to filter on. + EOS + newvalues(/^[a-zA-Z0-9\-\._\+]+$/) + end + + # NAT specific properties + newproperty(:tosource, :required_features => :snat) do + desc <<-EOS + When using jump => "SNAT" you can specify the new source address using + this parameter. + EOS + end + + newproperty(:todest, :required_features => :dnat) do + desc <<-EOS + When using jump => "DNAT" you can specify the new destination address + using this paramter. + EOS + end + + newproperty(:toports, :required_features => :dnat) do + desc <<-EOS + For DNAT this is the port that will replace the destination port. + EOS + end + + newproperty(:random, :required_features => :dnat) do + desc <<-EOS + When using a jump value of "MASQUERADE", "DNAT", "REDIRECT", or "SNAT" + this boolean will enable randomized port mapping. + EOS + + newvalues(:true, :false) + end + + # Reject ICMP type + newproperty(:reject, :required_features => :reject_type) do + desc <<-EOS + When combined with jump => "REJECT" you can specify a different icmp + response to be sent back to the packet sender. + EOS + end + + # Logging properties + newproperty(:log_level, :required_features => :log_level) do + desc <<-EOS + When combined with jump => "LOG" specifies the system log level to log + to. + EOS + + munge do |value| + if value.kind_of?(String) + value = @resource.log_level_name_to_number(value) + else + value + end + + if value == nil && value != "" + self.fail("Unable to determine log level") + end + value + end + end + + newproperty(:log_prefix, :required_features => :log_prefix) do + desc <<-EOS + When combined with jump => "LOG" specifies the log prefix to use when + logging. + EOS + end + + # ICMP matching property + newproperty(:icmp, :required_features => :icmp_match) do + desc <<-EOS + When matching ICMP packets, this is the type of ICMP packet to match. + + A value of "any" is not supported. To achieve this behaviour the + parameter should simply be omitted or undefined. + EOS + + validate do |value| + if value == "any" + raise ArgumentError, + "Value 'any' is not valid. This behaviour should be achieved " \ + "by omitting or undefining the ICMP parameter." + end + end + + munge do |value| + if value.kind_of?(String) + # ICMP codes differ between IPv4 and IPv6. + case @resource[:provider] + when :iptables + protocol = 'inet' + when :ip6tables + protocol = 'inet6' + else + self.fail("cannot work out protocol family") + end + + value = @resource.icmp_name_to_number(value, protocol) + else + value + end + + if value == nil && value != "" + self.fail("cannot work out icmp type") + end + value + end + end + + newproperty(:state, :array_matching => :all, :required_features => + :state_match) do + + desc <<-EOS + Matches a packet based on its state in the firewall stateful inspection + table. Values can be: + + * INVALID + * ESTABLISHED + * NEW + * RELATED + EOS + + newvalues(:INVALID,:ESTABLISHED,:NEW,:RELATED) + + # States should always be sorted. This normalizes the resource states to + # keep it consistent with the sorted result from iptables-save. + def should=(values) + @should = super(values).sort_by {|sym| sym.to_s} + end + + def is_to_s(value) + should_to_s(value) + end + + def should_to_s(value) + value = [value] unless value.is_a?(Array) + value.join(',') + end + end + + newproperty(:ctstate, :array_matching => :all, :required_features => + :state_match) do + + desc <<-EOS + Matches a packet based on its state in the firewall stateful inspection + table, using the conntrack module. Values can be: + + * INVALID + * ESTABLISHED + * NEW + * RELATED + EOS + + newvalues(:INVALID,:ESTABLISHED,:NEW,:RELATED) + + # States should always be sorted. This normalizes the resource states to + # keep it consistent with the sorted result from iptables-save. + def should=(values) + @should = super(values).sort_by {|sym| sym.to_s} + end + + def is_to_s(value) + should_to_s(value) + end + + def should_to_s(value) + value = [value] unless value.is_a?(Array) + value.join(',') + end + end + + + # Connection mark + newproperty(:connmark, :required_features => :mark) do + desc <<-EOS + Match the Netfilter mark value associated with the packet. Accepts either of: + mark/mask or mark. These will be converted to hex if they are not already. + EOS + munge do |value| + int_or_hex = '[a-fA-F0-9x]' + match = value.to_s.match("(#{int_or_hex}+)(/)?(#{int_or_hex}+)?") + mark = @resource.to_hex32(match[1]) + + # Values that can't be converted to hex. + # Or contain a trailing slash with no mask. + if mark.nil? or (mark and match[2] and match[3].nil?) + raise ArgumentError, "MARK value must be integer or hex between 0 and 0xffffffff" + end + + # There should not be a mask on connmark + unless match[3].nil? + raise ArgumentError, "iptables does not support masks on MARK match rules" + end + value = mark + + value + end + end + + # Connection limiting properties + newproperty(:connlimit_above, :required_features => :connection_limiting) do + desc <<-EOS + Connection limiting value for matched connections above n. + EOS + newvalue(/^\d+$/) + end + + newproperty(:connlimit_mask, :required_features => :connection_limiting) do + desc <<-EOS + Connection limiting by subnet mask for matched connections. + IPv4: 0-32 + IPv6: 0-128 + EOS + newvalue(/^\d+$/) + end + + # Hop limiting properties + newproperty(:hop_limit, :required_features => :hop_limiting) do + desc <<-EOS + Hop limiting value for matched packets. + EOS + newvalue(/^\d+$/) + end + + # Rate limiting properties + newproperty(:limit, :required_features => :rate_limiting) do + desc <<-EOS + Rate limiting value for matched packets. The format is: + rate/[/second/|/minute|/hour|/day]. + + Example values are: '50/sec', '40/min', '30/hour', '10/day'." + EOS + end + + newproperty(:burst, :required_features => :rate_limiting) do + desc <<-EOS + Rate limiting burst value (per second) before limit checks apply. + EOS + newvalue(/^\d+$/) + end + + newproperty(:uid, :required_features => :owner) do + desc <<-EOS + UID or Username owner matching rule. Accepts a string argument + only, as iptables does not accept multiple uid in a single + statement. + EOS + end + + newproperty(:gid, :required_features => :owner) do + desc <<-EOS + GID or Group owner matching rule. Accepts a string argument + only, as iptables does not accept multiple gid in a single + statement. + EOS + end + + newproperty(:set_mark, :required_features => :mark) do + desc <<-EOS + Set the Netfilter mark value associated with the packet. Accepts either of: + mark/mask or mark. These will be converted to hex if they are not already. + EOS + + munge do |value| + int_or_hex = '[a-fA-F0-9x]' + match = value.to_s.match("(#{int_or_hex}+)(/)?(#{int_or_hex}+)?") + mark = @resource.to_hex32(match[1]) + + # Values that can't be converted to hex. + # Or contain a trailing slash with no mask. + if mark.nil? or (mark and match[2] and match[3].nil?) + raise ArgumentError, "MARK value must be integer or hex between 0 and 0xffffffff" + end + + # Old iptables does not support a mask. New iptables will expect one. + iptables_version = Facter.fact('iptables_version').value + mask_required = (iptables_version and Puppet::Util::Package.versioncmp(iptables_version, '1.4.1') >= 0) + + if mask_required + if match[3].nil? + value = "#{mark}/0xffffffff" + else + mask = @resource.to_hex32(match[3]) + if mask.nil? + raise ArgumentError, "MARK mask must be integer or hex between 0 and 0xffffffff" + end + value = "#{mark}/#{mask}" + end + else + unless match[3].nil? + raise ArgumentError, "iptables version #{iptables_version} does not support masks on MARK rules" + end + value = mark + end + + value + end + end + + newproperty(:pkttype, :required_features => :pkttype) do + desc <<-EOS + Sets the packet type to match. + EOS + + newvalues(:unicast, :broadcast, :multicast) + end + + newproperty(:isfragment, :required_features => :isfragment) do + desc <<-EOS + Set to true to match tcp fragments (requires type to be set to tcp) + EOS + + newvalues(:true, :false) + end + + newproperty(:recent, :required_features => :recent_limiting) do + desc <<-EOS + Enable the recent module. Takes as an argument one of set, update, + rcheck or remove. For example: + + # If anyone's appeared on the 'badguy' blacklist within + # the last 60 seconds, drop their traffic, and update the timestamp. + firewall { '100 Drop badguy traffic': + recent => 'update', + rseconds => 60, + rsource => true, + rname => 'badguy', + action => 'DROP', + chain => 'FORWARD', + } + # No-one should be sending us traffic on eth0 from localhost + # Blacklist them + firewall { '101 blacklist strange traffic': + recent => 'set', + rsource => true, + rname => 'badguy', + destination => '127.0.0.0/8', + iniface => 'eth0', + action => 'DROP', + chain => 'FORWARD', + } + EOS + + newvalues(:set, :update, :rcheck, :remove) + munge do |value| + value = "--" + value + end + end + + newproperty(:rdest, :required_features => :recent_limiting) do + desc <<-EOS + Recent module; add the destination IP address to the list. + Must be boolean true. + EOS + + newvalues(:true, :false) + end + + newproperty(:rsource, :required_features => :recent_limiting) do + desc <<-EOS + Recent module; add the source IP address to the list. + Must be boolean true. + EOS + + newvalues(:true, :false) + end + + newproperty(:rname, :required_features => :recent_limiting) do + desc <<-EOS + Recent module; The name of the list. Takes a string argument. + EOS + end + + newproperty(:rseconds, :required_features => :recent_limiting) do + desc <<-EOS + Recent module; used in conjunction with one of `recent => 'rcheck'` or + `recent => 'update'`. When used, this will narrow the match to only + happen when the address is in the list and was seen within the last given + number of seconds. + EOS + end + + newproperty(:reap, :required_features => :recent_limiting) do + desc <<-EOS + Recent module; can only be used in conjunction with the `rseconds` + attribute. When used, this will cause entries older than 'seconds' to be + purged. Must be boolean true. + EOS + + newvalues(:true, :false) + end + + newproperty(:rhitcount, :required_features => :recent_limiting) do + desc <<-EOS + Recent module; used in conjunction with `recent => 'update'` or `recent + => 'rcheck'. When used, this will narrow the match to only happen when + the address is in the list and packets had been received greater than or + equal to the given value. + EOS + end + + newproperty(:rttl, :required_features => :recent_limiting) do + desc <<-EOS + Recent module; may only be used in conjunction with one of `recent => + 'rcheck'` or `recent => 'update'`. When used, this will narrow the match + to only happen when the address is in the list and the TTL of the current + packet matches that of the packet which hit the `recent => 'set'` rule. + This may be useful if you have problems with people faking their source + address in order to DoS you via this module by disallowing others access + to your site by sending bogus packets to you. Must be boolean true. + EOS + + newvalues(:true, :false) + end + + newproperty(:socket, :required_features => :socket) do + desc <<-EOS + If true, matches if an open socket can be found by doing a coket lookup + on the packet. + EOS + + newvalues(:true, :false) + end + + newproperty(:ishasmorefrags, :required_features => :ishasmorefrags) do + desc <<-EOS + If true, matches if the packet has it's 'more fragments' bit set. ipv6. + EOS + + newvalues(:true, :false) + end + + newproperty(:islastfrag, :required_features => :islastfrag) do + desc <<-EOS + If true, matches if the packet is the last fragment. ipv6. + EOS + + newvalues(:true, :false) + end + + newproperty(:isfirstfrag, :required_features => :isfirstfrag) do + desc <<-EOS + If true, matches if the packet is the first fragment. + Sadly cannot be negated. ipv6. + EOS + + newvalues(:true, :false) + end + + newproperty(:ipsec_policy, :required_features => :ipsec_policy) do + desc <<-EOS + Sets the ipsec policy type + EOS + + newvalues(:none, :ipsec) + end + + newproperty(:ipsec_dir, :required_features => :ipsec_dir) do + desc <<-EOS + Sets the ipsec policy direction + EOS + + newvalues(:in, :out) + end + + newproperty(:mask, :required_features => :mask) do + desc <<-EOS + Sets the mask to use when `recent` is enabled. + EOS + end + + newparam(:line) do + desc <<-EOS + Read-only property for caching the rule line. + EOS + end + + autorequire(:firewallchain) do + reqs = [] + protocol = nil + + case value(:provider) + when :iptables + protocol = "IPv4" + when :ip6tables + protocol = "IPv6" + end + + unless protocol.nil? + table = value(:table) + [value(:chain), value(:jump)].each do |chain| + reqs << "#{chain}:#{table}:#{protocol}" unless ( chain.nil? || (['INPUT', 'OUTPUT', 'FORWARD'].include?(chain) && table == :filter) ) + end + end + + reqs + end + + # Classes would be a better abstraction, pending: + # http://projects.puppetlabs.com/issues/19001 + autorequire(:package) do + case value(:provider) + when :iptables, :ip6tables + %w{iptables iptables-persistent} + else + [] + end + end + + validate do + debug("[validate]") + + # TODO: this is put here to skip validation if ensure is not set. This + # is because there is a revalidation stage called later where the values + # are not set correctly. I tried tracing it - but have put in this + # workaround instead to skip. Must get to the bottom of this. + if ! value(:ensure) + return + end + + # First we make sure the chains and tables are valid combinations + if value(:table).to_s == "filter" && + value(:chain) =~ /PREROUTING|POSTROUTING/ + + self.fail "PREROUTING and POSTROUTING cannot be used in table 'filter'" + end + + if value(:table).to_s == "nat" && value(:chain) =~ /INPUT|FORWARD/ + self.fail "INPUT and FORWARD cannot be used in table 'nat'" + end + + if value(:table).to_s == "raw" && + value(:chain) =~ /INPUT|FORWARD|POSTROUTING/ + + self.fail "INPUT, FORWARD and POSTROUTING cannot be used in table raw" + end + + # Now we analyse the individual properties to make sure they apply to + # the correct combinations. + if value(:iniface) + unless value(:chain).to_s =~ /INPUT|FORWARD|PREROUTING/ + self.fail "Parameter iniface only applies to chains " \ + "INPUT,FORWARD,PREROUTING" + end + end + + if value(:outiface) + unless value(:chain).to_s =~ /OUTPUT|FORWARD|POSTROUTING/ + self.fail "Parameter outiface only applies to chains " \ + "OUTPUT,FORWARD,POSTROUTING" + end + end + + if value(:uid) + unless value(:chain).to_s =~ /OUTPUT|POSTROUTING/ + self.fail "Parameter uid only applies to chains " \ + "OUTPUT,POSTROUTING" + end + end + + if value(:gid) + unless value(:chain).to_s =~ /OUTPUT|POSTROUTING/ + self.fail "Parameter gid only applies to chains " \ + "OUTPUT,POSTROUTING" + end + end + + if value(:set_mark) + unless value(:jump).to_s =~ /MARK/ && + value(:chain).to_s =~ /PREROUTING|OUTPUT/ && + value(:table).to_s =~ /mangle/ + self.fail "Parameter set_mark only applies to " \ + "the PREROUTING or OUTPUT chain of the mangle table and when jump => MARK" + end + end + + if value(:dport) + unless value(:proto).to_s =~ /tcp|udp|sctp/ + self.fail "[%s] Parameter dport only applies to sctp, tcp and udp " \ + "protocols. Current protocol is [%s] and dport is [%s]" % + [value(:name), should(:proto), should(:dport)] + end + end + + if value(:jump).to_s == "DNAT" + unless value(:table).to_s =~ /nat/ + self.fail "Parameter jump => DNAT only applies to table => nat" + end + + unless value(:todest) + self.fail "Parameter jump => DNAT must have todest parameter" + end + end + + if value(:jump).to_s == "SNAT" + unless value(:table).to_s =~ /nat/ + self.fail "Parameter jump => SNAT only applies to table => nat" + end + + unless value(:tosource) + self.fail "Parameter jump => SNAT must have tosource parameter" + end + end + + if value(:jump).to_s == "REDIRECT" + unless value(:toports) + self.fail "Parameter jump => REDIRECT missing mandatory toports " \ + "parameter" + end + end + + if value(:jump).to_s == "MASQUERADE" + unless value(:table).to_s =~ /nat/ + self.fail "Parameter jump => MASQUERADE only applies to table => nat" + end + end + + if value(:log_prefix) || value(:log_level) + unless value(:jump).to_s == "LOG" + self.fail "Parameter log_prefix and log_level require jump => LOG" + end + end + + if value(:burst) && ! value(:limit) + self.fail "burst makes no sense without limit" + end + + if value(:action) && value(:jump) + self.fail "Only one of the parameters 'action' and 'jump' can be set" + end + + if value(:connlimit_mask) && ! value(:connlimit_above) + self.fail "Parameter 'connlimit_mask' requires 'connlimit_above'" + end + + if value(:mask) && ! value(:recent) + self.fail "Mask can only be set if recent is enabled." + end + + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/type/firewallchain.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/type/firewallchain.rb new file mode 100644 index 0000000000..3e3c5d1370 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/type/firewallchain.rb @@ -0,0 +1,222 @@ +# This is a workaround for bug: #4248 whereby ruby files outside of the normal +# provider/type path do not load until pluginsync has occured on the puppetmaster +# +# In this case I'm trying the relative path first, then falling back to normal +# mechanisms. This should be fixed in future versions of puppet but it looks +# like we'll need to maintain this for some time perhaps. +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..","..")) +require 'puppet/util/firewall' + +Puppet::Type.newtype(:firewallchain) do + include Puppet::Util::Firewall + + @doc = <<-EOS + This type provides the capability to manage rule chains for firewalls. + + Currently this supports only iptables, ip6tables and ebtables on Linux. And + provides support for setting the default policy on chains and tables that + allow it. + + **Autorequires:** + If Puppet is managing the iptables or iptables-persistent packages, and + the provider is iptables_chain, the firewall resource will autorequire + those packages to ensure that any required binaries are installed. + EOS + + feature :iptables_chain, "The provider provides iptables chain features." + feature :policy, "Default policy (inbuilt chains only)" + + ensurable do + defaultvalues + defaultto :present + end + + newparam(:name) do + desc <<-EOS + The canonical name of the chain. + + For iptables the format must be {chain}:{table}:{protocol}. + EOS + isnamevar + + validate do |value| + if value !~ Nameformat then + raise ArgumentError, "Inbuilt chains must be in the form {chain}:{table}:{protocol} where {table} is one of FILTER, NAT, MANGLE, RAW, RAWPOST, BROUTE or empty (alias for filter), chain can be anything without colons or one of PREROUTING, POSTROUTING, BROUTING, INPUT, FORWARD, OUTPUT for the inbuilt chains, and {protocol} being IPv4, IPv6, ethernet (ethernet bridging) got '#{value}' table:'#{$1}' chain:'#{$2}' protocol:'#{$3}'" + else + chain = $1 + table = $2 + protocol = $3 + case table + when 'filter' + if chain =~ /^(PREROUTING|POSTROUTING|BROUTING)$/ + raise ArgumentError, "INPUT, OUTPUT and FORWARD are the only inbuilt chains that can be used in table 'filter'" + end + when 'mangle' + if chain =~ InternalChains && chain == 'BROUTING' + raise ArgumentError, "PREROUTING, POSTROUTING, INPUT, FORWARD and OUTPUT are the only inbuilt chains that can be used in table 'mangle'" + end + when 'nat' + if chain =~ /^(BROUTING|FORWARD)$/ + raise ArgumentError, "PREROUTING, POSTROUTING, INPUT, and OUTPUT are the only inbuilt chains that can be used in table 'nat'" + end + if protocol =~/^(IP(v6)?)?$/ + raise ArgumentError, "table nat isn't valid in IPv6. You must specify ':IPv4' as the name suffix" + end + when 'raw' + if chain =~ /^(POSTROUTING|BROUTING|INPUT|FORWARD)$/ + raise ArgumentError,'PREROUTING and OUTPUT are the only inbuilt chains in the table \'raw\'' + end + when 'broute' + if protocol != 'ethernet' + raise ArgumentError,'BROUTE is only valid with protocol \'ethernet\'' + end + if chain =~ /^PREROUTING|POSTROUTING|INPUT|FORWARD|OUTPUT$/ + raise ArgumentError,'BROUTING is the only inbuilt chain allowed on on table \'broute\'' + end + end + if chain == 'BROUTING' && ( protocol != 'ethernet' || table!='broute') + raise ArgumentError,'BROUTING is the only inbuilt chain allowed on on table \'BROUTE\' with protocol \'ethernet\' i.e. \'broute:BROUTING:enternet\'' + end + end + end + end + + newproperty(:policy) do + desc <<-EOS + This is the action to when the end of the chain is reached. + It can only be set on inbuilt chains (INPUT, FORWARD, OUTPUT, + PREROUTING, POSTROUTING) and can be one of: + + * accept - the packet is accepted + * drop - the packet is dropped + * queue - the packet is passed userspace + * return - the packet is returned to calling (jump) queue + or the default of inbuilt chains + EOS + newvalues(:accept, :drop, :queue, :return) + defaultto do + # ethernet chain have an ACCEPT default while other haven't got an + # allowed value + if @resource[:name] =~ /:ethernet$/ + :accept + else + nil + end + end + end + + newparam(:purge, :boolean => true) do + desc <<-EOS + Purge unmanaged firewall rules in this chain + EOS + newvalues(:false, :true) + defaultto :false + end + + newparam(:ignore) do + desc <<-EOS + Regex to perform on firewall rules to exempt unmanaged rules from purging (when enabled). + This is matched against the output of `iptables-save`. + + This can be a single regex, or an array of them. + To support flags, use the ruby inline flag mechanism. + Meaning a regex such as + /foo/i + can be written as + '(?i)foo' or '(?i:foo)' + + Full example: + firewallchain { 'INPUT:filter:IPv4': + purge => true, + ignore => [ + '-j fail2ban-ssh', # ignore the fail2ban jump rule + '--comment "[^"]*(?i:ignore)[^"]*"', # ignore any rules with "ignore" (case insensitive) in the comment in the rule + ], + } + EOS + + validate do |value| + unless value.is_a?(Array) or value.is_a?(String) or value == false + self.devfail "Ignore must be a string or an Array" + end + end + munge do |patterns| # convert into an array of {Regex}es + patterns = [patterns] if patterns.is_a?(String) + patterns.map{|p| Regexp.new(p)} + end + end + + # Classes would be a better abstraction, pending: + # http://projects.puppetlabs.com/issues/19001 + autorequire(:package) do + case value(:provider) + when :iptables_chain + %w{iptables iptables-persistent} + else + [] + end + end + + validate do + debug("[validate]") + + value(:name).match(Nameformat) + chain = $1 + table = $2 + protocol = $3 + + # Check that we're not removing an internal chain + if chain =~ InternalChains && value(:ensure) == :absent + self.fail "Cannot remove in-built chains" + end + + if value(:policy).nil? && protocol == 'ethernet' + self.fail "you must set a non-empty policy on all ethernet table chains" + end + + # Check that we're not setting a policy on a user chain + if chain !~ InternalChains && + !value(:policy).nil? && + protocol != 'ethernet' + + self.fail "policy can only be set on in-built chains (with the exception of ethernet chains) (table:#{table} chain:#{chain} protocol:#{protocol})" + end + + # no DROP policy on nat table + if table == 'nat' && + value(:policy) == :drop + + self.fail 'The "nat" table is not intended for filtering, the use of DROP is therefore inhibited' + end + end + + def generate + return [] unless self.purge? + + value(:name).match(Nameformat) + chain = $1 + table = $2 + protocol = $3 + + provider = case protocol + when 'IPv4' + :iptables + when 'IPv6' + :ip6tables + end + + # gather a list of all rules present on the system + rules_resources = Puppet::Type.type(:firewall).instances + + # Keep only rules in this chain + rules_resources.delete_if { |res| (res[:provider] != provider or res.provider.properties[:table].to_s != table or res.provider.properties[:chain] != chain) } + + # Remove rules which match our ignore filter + rules_resources.delete_if {|res| value(:ignore).find_index{|f| res.provider.properties[:line].match(f)}} if value(:ignore) + + # We mark all remaining rules for deletion, and then let the catalog override us on rules which should be present + rules_resources.each {|res| res[:ensure] = :absent} + + rules_resources + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/util/firewall.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/util/firewall.rb new file mode 100644 index 0000000000..aa26d3bc70 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/util/firewall.rb @@ -0,0 +1,225 @@ +require 'socket' +require 'resolv' +require 'puppet/util/ipcidr' + +# Util module for puppetlabs-firewall +module Puppet::Util::Firewall + # Translate the symbolic names for icmp packet types to integers + def icmp_name_to_number(value_icmp, protocol) + if value_icmp =~ /\d{1,2}$/ + value_icmp + elsif protocol == 'inet' + case value_icmp + when "echo-reply" then "0" + when "destination-unreachable" then "3" + when "source-quench" then "4" + when "redirect" then "6" + when "echo-request" then "8" + when "router-advertisement" then "9" + when "router-solicitation" then "10" + when "time-exceeded" then "11" + when "parameter-problem" then "12" + when "timestamp-request" then "13" + when "timestamp-reply" then "14" + when "address-mask-request" then "17" + when "address-mask-reply" then "18" + else nil + end + elsif protocol == 'inet6' + case value_icmp + when "destination-unreachable" then "1" + when "time-exceeded" then "3" + when "parameter-problem" then "4" + when "echo-request" then "128" + when "echo-reply" then "129" + when "router-solicitation" then "133" + when "router-advertisement" then "134" + when "redirect" then "137" + else nil + end + else + raise ArgumentError, "unsupported protocol family '#{protocol}'" + end + end + + # Convert log_level names to their respective numbers + def log_level_name_to_number(value) + #TODO make this 0-7 only + if value =~ /\d/ + value + else + case value + when "panic" then "0" + when "alert" then "1" + when "crit" then "2" + when "err" then "3" + when "error" then "3" + when "warn" then "4" + when "warning" then "4" + when "not" then "5" + when "notice" then "5" + when "info" then "6" + when "debug" then "7" + else nil + end + end + end + + # This method takes a string and a protocol and attempts to convert + # it to a port number if valid. + # + # If the string already contains a port number or perhaps a range of ports + # in the format 22:1000 for example, it simply returns the string and does + # nothing. + def string_to_port(value, proto) + proto = proto.to_s + unless proto =~ /^(tcp|udp)$/ + proto = 'tcp' + end + + if value.kind_of?(String) + if value.match(/^\d+(-\d+)?$/) + return value + else + return Socket.getservbyname(value, proto).to_s + end + else + Socket.getservbyname(value.to_s, proto).to_s + end + end + + # Takes an address and returns it in CIDR notation. + # + # If the address is: + # + # - A hostname: + # It will be resolved + # - An IPv4 address: + # It will be qualified with a /32 CIDR notation + # - An IPv6 address: + # It will be qualified with a /128 CIDR notation + # - An IP address with a CIDR notation: + # It will be normalised + # - An IP address with a dotted-quad netmask: + # It will be converted to CIDR notation + # - Any address with a resulting prefix length of zero: + # It will return nil which is equivilent to not specifying an address + # + def host_to_ip(value) + begin + value = Puppet::Util::IPCidr.new(value) + rescue + value = Puppet::Util::IPCidr.new(Resolv.getaddress(value)) + end + + return nil if value.prefixlen == 0 + value.cidr + end + + # Takes an address mask and converts the host portion to CIDR notation. + # + # This takes into account you can negate a mask but follows all rules + # defined in host_to_ip for the host/address part. + # + def host_to_mask(value) + match = value.match /(!)\s?(.*)$/ + return host_to_ip(value) unless match + + cidr = host_to_ip(match[2]) + return nil if cidr == nil + "#{match[1]} #{cidr}" + end + + # Validates the argument is int or hex, and returns valid hex + # conversion of the value or nil otherwise. + def to_hex32(value) + begin + value = Integer(value) + if value.between?(0, 0xffffffff) + return '0x' + value.to_s(16) + end + rescue ArgumentError + # pass + end + return nil + end + + def persist_iptables(proto) + debug("[persist_iptables]") + + # Basic normalisation for older Facter + os_key = Facter.value(:osfamily) + os_key ||= case Facter.value(:operatingsystem) + when 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'SL', 'SLC', 'Ascendos', 'CloudLinux', 'PSBM', 'OracleLinux', 'OVS', 'OEL', 'Amazon', 'XenServer' + 'RedHat' + when 'Debian', 'Ubuntu' + 'Debian' + else + Facter.value(:operatingsystem) + end + + # Older iptables-persistent doesn't provide save action. + if os_key == 'Debian' + persist_ver = Facter.value(:iptables_persistent_version) + if (persist_ver and Puppet::Util::Package.versioncmp(persist_ver, '0.5.0') < 0) + os_key = 'Debian_manual' + end + end + + # Fedora 15 and newer use systemd to persist iptable rules + if os_key == 'RedHat' && Facter.value(:operatingsystem) == 'Fedora' && Facter.value(:operatingsystemrelease).to_i >= 15 + os_key = 'Fedora' + end + + # RHEL 7 and newer also use systemd to persist iptable rules + if os_key == 'RedHat' && Facter.value(:operatingsystem) == 'RedHat' && Facter.value(:operatingsystemrelease).to_i >= 7 + os_key = 'Fedora' + end + + cmd = case os_key.to_sym + when :RedHat + case proto.to_sym + when :IPv4 + %w{/sbin/service iptables save} + when :IPv6 + %w{/sbin/service ip6tables save} + end + when :Fedora + case proto.to_sym + when :IPv4 + %w{/usr/libexec/iptables/iptables.init save} + when :IPv6 + %w{/usr/libexec/iptables/ip6tables.init save} + end + when :Debian + case proto.to_sym + when :IPv4, :IPv6 + %w{/usr/sbin/service iptables-persistent save} + end + when :Debian_manual + case proto.to_sym + when :IPv4 + ["/bin/sh", "-c", "/sbin/iptables-save > /etc/iptables/rules"] + end + when :Archlinux + case proto.to_sym + when :IPv4 + ["/bin/sh", "-c", "/usr/sbin/iptables-save > /etc/iptables/iptables.rules"] + when :IPv6 + ["/bin/sh", "-c", "/usr/sbin/ip6tables-save > /etc/iptables/ip6tables.rules"] + end + end + + # Catch unsupported OSs from the case statement above. + if cmd.nil? + debug('firewall: Rule persistence is not supported for this type/OS') + return + end + + begin + execute(cmd) + rescue Puppet::ExecutionFailure => detail + warning("Unable to persist firewall rules: #{detail}") + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/util/ipcidr.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/util/ipcidr.rb new file mode 100644 index 0000000000..87e8d5e372 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/lib/puppet/util/ipcidr.rb @@ -0,0 +1,42 @@ +require 'ipaddr' + +# IPCidr object wrapper for IPAddr +module Puppet + module Util + class IPCidr < IPAddr + def initialize(ipaddr) + begin + super(ipaddr) + rescue ArgumentError => e + if e.message =~ /invalid address/ + raise ArgumentError, "Invalid address from IPAddr.new: #{ipaddr}" + else + raise e + end + end + end + + def netmask + _to_string(@mask_addr) + end + + def prefixlen + m = case @family + when Socket::AF_INET + IN4MASK + when Socket::AF_INET6 + IN6MASK + else + raise "unsupported address family" + end + return $1.length if /\A(1*)(0*)\z/ =~ (@mask_addr & m).to_s(2) + raise "bad addr_mask format" + end + + def cidr + cidr = sprintf("%s/%s", self.to_s, self.prefixlen) + cidr + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/init.pp new file mode 100644 index 0000000000..759f328235 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/init.pp @@ -0,0 +1,36 @@ +# = Class: firewall +# +# Manages packages and services required by the firewall type/provider. +# +# This class includes the appropriate sub-class for your operating system, +# where supported. +# +# == Parameters: +# +# [*ensure*] +# Ensure parameter passed onto Service[] resources. +# Default: running +# +class firewall ( + $ensure = running +) { + case $ensure { + /^(running|stopped)$/: { + # Do nothing. + } + default: { + fail("${title}: Ensure value '${ensure}' is not supported") + } + } + + case $::kernel { + 'Linux': { + class { "${title}::linux": + ensure => $ensure, + } + } + default: { + fail("${title}: Kernel '${::kernel}' is not currently supported") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux.pp new file mode 100644 index 0000000000..7c4f3a80b5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux.pp @@ -0,0 +1,51 @@ +# = Class: firewall::linux +# +# Installs the `iptables` package for Linux operating systems and includes +# the appropriate sub-class for any distribution specific services and +# additional packages. +# +# == Parameters: +# +# [*ensure*] +# Ensure parameter passed onto Service[] resources. When `running` the +# service will be started on boot, and when `stopped` it will not. +# Default: running +# +class firewall::linux ( + $ensure = running +) { + $enable = $ensure ? { + running => true, + stopped => false, + } + + package { 'iptables': + ensure => present, + } + + case $::operatingsystem { + 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'SL', 'SLC', 'Ascendos', + 'CloudLinux', 'PSBM', 'OracleLinux', 'OVS', 'OEL', 'Amazon', 'XenServer': { + class { "${title}::redhat": + ensure => $ensure, + enable => $enable, + require => Package['iptables'], + } + } + 'Debian', 'Ubuntu': { + class { "${title}::debian": + ensure => $ensure, + enable => $enable, + require => Package['iptables'], + } + } + 'Archlinux': { + class { "${title}::archlinux": + ensure => $ensure, + enable => $enable, + require => Package['iptables'], + } + } + default: {} + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux/archlinux.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux/archlinux.pp new file mode 100644 index 0000000000..546a5a80fe --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux/archlinux.pp @@ -0,0 +1,41 @@ +# = Class: firewall::linux::archlinux +# +# Manages `iptables` and `ip6tables` services, and creates files used for +# persistence, on Arch Linux systems. +# +# == Parameters: +# +# [*ensure*] +# Ensure parameter passed onto Service[] resources. +# Default: running +# +# [*enable*] +# Enable parameter passed onto Service[] resources. +# Default: true +# +class firewall::linux::archlinux ( + $ensure = 'running', + $enable = true +) { + service { 'iptables': + ensure => $ensure, + enable => $enable, + hasstatus => true, + } + + service { 'ip6tables': + ensure => $ensure, + enable => $enable, + hasstatus => true, + } + + file { '/etc/iptables/iptables.rules': + ensure => present, + before => Service['iptables'], + } + + file { '/etc/iptables/ip6tables.rules': + ensure => present, + before => Service['ip6tables'], + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux/debian.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux/debian.pp new file mode 100644 index 0000000000..4d28bc482e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux/debian.pp @@ -0,0 +1,44 @@ +# = Class: firewall::linux::debian +# +# Installs the `iptables-persistent` package for Debian-alike systems. This +# allows rules to be stored to file and restored on boot. +# +# == Parameters: +# +# [*ensure*] +# Ensure parameter passed onto Service[] resources. +# Default: running +# +# [*enable*] +# Enable parameter passed onto Service[] resources. +# Default: true +# +class firewall::linux::debian ( + $ensure = running, + $enable = true +) { + package { 'iptables-persistent': + ensure => present, + } + + if($::operatingsystemrelease =~ /^6\./ and $enable == true + and versioncmp($::iptables_persistent_version, '0.5.0') < 0 ) { + # This fixes a bug in the iptables-persistent LSB headers in 6.x, without it + # we lose idempotency + exec { 'iptables-persistent-enable': + logoutput => on_failure, + command => '/usr/sbin/update-rc.d iptables-persistent enable', + unless => '/usr/bin/test -f /etc/rcS.d/S*iptables-persistent', + require => Package['iptables-persistent'], + } + } else { + # This isn't a real service/daemon. The start action loads rules, so just + # needs to be called on system boot. + service { 'iptables-persistent': + ensure => undef, + enable => $enable, + hasstatus => true, + require => Package['iptables-persistent'], + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux/redhat.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux/redhat.pp new file mode 100644 index 0000000000..f697d211b9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/manifests/linux/redhat.pp @@ -0,0 +1,40 @@ +# = Class: firewall::linux::redhat +# +# Manages the `iptables` service on RedHat-alike systems. +# +# == Parameters: +# +# [*ensure*] +# Ensure parameter passed onto Service[] resources. +# Default: running +# +# [*enable*] +# Enable parameter passed onto Service[] resources. +# Default: true +# +class firewall::linux::redhat ( + $ensure = running, + $enable = true +) { + + # RHEL 7 and later and Fedora 15 and later require the iptables-services + # package, which provides the /usr/libexec/iptables/iptables.init used by + # lib/puppet/util/firewall.rb. + if $::operatingsystem == RedHat and $::operatingsystemrelease >= 7 { + package { 'iptables-services': + ensure => present, + } + } + + if ($::operatingsystem == 'Fedora' and (( $::operatingsystemrelease =~ /^\d+/ and $::operatingsystemrelease >= 15 ) or $::operatingsystemrelease == "Rawhide")) { + package { 'iptables-services': + ensure => present, + } + } + + service { 'iptables': + ensure => $ensure, + enable => $enable, + hasstatus => true, + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/metadata.json b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/metadata.json new file mode 100644 index 0000000000..40fb8612bd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/metadata.json @@ -0,0 +1,64 @@ +{ + "name": "puppetlabs-firewall", + "version": "1.1.1", + "source": "https://github.com/puppetlabs/puppetlabs-firewall", + "author": "Puppet Labs", + "license": "Apache-2.0", + "project_page": "https://github.com/puppetlabs/puppetlabs-firewall", + "summary": "Manages Firewalls such as iptable", + "operatingsystem_support": [ + { + "operatingsystem": "RedHat", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "CentOS", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "OracleLinux", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "Scientific", + "operatingsystemrelease": [ + "5", + "6" + ] + }, + { + "operatingsystem": "SLES", + "operatingsystemrelease": [ + "11 SP1" + ] + }, + { + "operatingsystem": "Debian", + "operatingsystemrelease": [ + "6", + "7" + ] + }, + { + "operatingsystem": "Ubuntu", + "operatingsystemrelease": [ + "10.04", + "12.04" + ] + } + ], + "requirements": [ + { "name": "pe", "version_requirement": "3.2.x" }, + { "name": "puppet", "version_requirement": "3.x" } + ], + "dependencies": [] +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/change_source_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/change_source_spec.rb new file mode 100644 index 0000000000..cdb4eab354 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/change_source_spec.rb @@ -0,0 +1,77 @@ +require 'spec_helper_acceptance' + +describe 'firewall type' do + describe 'reset' do + it 'deletes all rules' do + shell('iptables --flush; iptables -t nat --flush; iptables -t mangle --flush') + end + end + + describe 'when unmanaged rules exist' do + it 'applies with 8.0.0.1 first' do + pp = <<-EOS + class { '::firewall': } + firewall { '101 test source changes': + proto => tcp, + port => '101', + action => accept, + source => '8.0.0.1', + } + firewall { '100 test source static': + proto => tcp, + port => '100', + action => accept, + source => '8.0.0.2', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'adds a unmanaged rule without a comment' do + shell('iptables -A INPUT -t filter -s 8.0.0.3/32 -p tcp -m multiport --ports 102 -j ACCEPT') + expect(shell('iptables-save').stdout).to match(/-A INPUT -s 8\.0\.0\.3(\/32)? -p tcp -m multiport --ports 102 -j ACCEPT/) + end + + it 'contains the changable 8.0.0.1 rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -s 8\.0\.0\.1(\/32)? -p tcp -m multiport --ports 101 -m comment --comment "101 test source changes" -j ACCEPT/) + end + end + it 'contains the static 8.0.0.2 rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -s 8\.0\.0\.2(\/32)? -p tcp -m multiport --ports 100 -m comment --comment "100 test source static" -j ACCEPT/) + end + end + + it 'changes to 8.0.0.4 second' do + pp = <<-EOS + class { '::firewall': } + firewall { '101 test source changes': + proto => tcp, + port => '101', + action => accept, + source => '8.0.0.4', + } + EOS + + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/Notice: \/Stage\[main\]\/Main\/Firewall\[101 test source changes\]\/source: source changed '8\.0\.0\.1\/32' to '8\.0\.0\.4\/32'/) + end + + it 'does not contain the old changing 8.0.0.1 rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/8\.0\.0\.1/) + end + end + it 'contains the staic 8.0.0.2 rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -s 8\.0\.0\.2(\/32)? -p tcp -m multiport --ports 100 -m comment --comment "100 test source static" -j ACCEPT/) + end + end + it 'contains the changing new 8.0.0.4 rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -s 8\.0\.0\.4(\/32)? -p tcp -m multiport --ports 101 -m comment --comment "101 test source changes" -j ACCEPT/) + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/class_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/class_spec.rb new file mode 100644 index 0000000000..aaf05a1f53 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/class_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper_acceptance' + +describe "firewall class:" do + it 'should run successfully' do + pp = "class { 'firewall': }" + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + + it 'ensure => stopped:' do + pp = "class { 'firewall': ensure => stopped }" + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + + it 'ensure => running:' do + pp = "class { 'firewall': ensure => running }" + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/connlimit_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/connlimit_spec.rb new file mode 100644 index 0000000000..ce6cab4ed7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/connlimit_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper_acceptance' + +describe 'firewall type' do + + describe 'connlimit_above' do + context '10' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '500 - test': + proto => tcp, + dport => '22', + connlimit_above => '10', + action => reject, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + #connlimit-saddr is added in Ubuntu 14.04. + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --dports 22 -m comment --comment "500 - test" -m connlimit --connlimit-above 10 --connlimit-mask 32 (--connlimit-saddr )?-j REJECT --reject-with icmp-port-unreachable/) + end + end + end + end + + describe 'connlimit_mask' do + context '24' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '501 - test': + proto => tcp, + dport => '22', + connlimit_above => '10', + connlimit_mask => '24', + action => reject, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + #connlimit-saddr is added in Ubuntu 14.04. + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --dports 22 -m comment --comment "501 - test" -m connlimit --connlimit-above 10 --connlimit-mask 24 (--connlimit-saddr )?-j REJECT --reject-with icmp-port-unreachable/) + end + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/connmark_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/connmark_spec.rb new file mode 100644 index 0000000000..959efbdfa7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/connmark_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper_acceptance' + +describe 'firewall type' do + + describe 'connmark' do + context '50' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '502 - test': + proto => 'all', + connmark => '0x1', + action => reject, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -m comment --comment "502 - test" -m connmark --mark 0x1 -j REJECT --reject-with icmp-port-unreachable/) + end + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/firewall_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/firewall_spec.rb new file mode 100644 index 0000000000..5353e104d5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/firewall_spec.rb @@ -0,0 +1,1618 @@ +require 'spec_helper_acceptance' + +describe 'firewall type' do + + describe 'reset' do + it 'deletes all rules' do + shell('iptables --flush; iptables -t nat --flush; iptables -t mangle --flush') + end + end + + describe 'name' do + context 'valid' do + it 'applies cleanly' do + pp = <<-EOS + class { '::firewall': } + firewall { '001 - test': ensure => present } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + end + + context 'invalid' do + it 'fails' do + pp = <<-EOS + class { '::firewall': } + firewall { 'test': ensure => present } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Invalid value "test"./) + end + end + end + end + + describe 'ensure' do + context 'default' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '555 - test': + proto => tcp, + port => '555', + action => accept, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 555 -m comment --comment "555 - test" -j ACCEPT/) + end + end + end + + context 'present' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '555 - test': + ensure => present, + proto => tcp, + port => '555', + action => accept, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 555 -m comment --comment "555 - test" -j ACCEPT/) + end + end + end + + context 'absent' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '555 - test': + ensure => absent, + proto => tcp, + port => '555', + action => accept, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should not contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m multiport --ports 555 -m comment --comment "555 - test" -j ACCEPT/) + end + end + end + end + + describe 'source' do + context '192.168.2.0/24' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '556 - test': + proto => tcp, + port => '556', + action => accept, + source => '192.168.2.0/24', + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -s 192.168.2.0\/(24|255\.255\.255\.0) -p tcp -m multiport --ports 556 -m comment --comment "556 - test" -j ACCEPT/) + end + end + end + + context '! 192.168.2.0/24' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '556 - test': + proto => tcp, + port => '556', + action => accept, + source => '! 192.168.2.0/24', + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT (! -s|-s !) 192.168.2.0\/(24|255\.255\.255\.0) -p tcp -m multiport --ports 556 -m comment --comment "556 - test" -j ACCEPT/) + end + end + end + + # Invalid address + context '256.168.2.0/24' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '556 - test': + proto => tcp, + port => '556', + action => accept, + source => '256.168.2.0/24', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/host_to_ip failed for 256.168.2.0\/(24|255\.255\.255\.0)/) + end + end + + it 'should not contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -s 256.168.2.0\/(24|255\.255\.255\.0) -p tcp -m multiport --ports 556 -m comment --comment "556 - test" -j ACCEPT/) + end + end + end + end + + describe 'src_range' do + context '192.168.1.1-192.168.1.10' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '557 - test': + proto => tcp, + port => '557', + action => accept, + src_range => '192.168.1.1-192.168.1.10', + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m iprange --src-range 192.168.1.1-192.168.1.10 -m multiport --ports 557 -m comment --comment "557 - test" -j ACCEPT/) + end + end + end + + # Invalid IP + context '392.168.1.1-192.168.1.10' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '557 - test': + proto => tcp, + port => '557', + action => accept, + src_range => '392.168.1.1-192.168.1.10', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Invalid value "392.168.1.1-192.168.1.10"/) + end + end + + it 'should not contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m iprange --src-range 392.168.1.1-192.168.1.10 -m multiport --ports 557 -m comment --comment "557 - test" -j ACCEPT/) + end + end + end + end + + describe 'destination' do + context '192.168.2.0/24' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '558 - test': + proto => tcp, + port => '558', + action => accept, + destination => '192.168.2.0/24', + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -d 192.168.2.0\/(24|255\.255\.255\.0) -p tcp -m multiport --ports 558 -m comment --comment "558 - test" -j ACCEPT/) + end + end + end + + context '! 192.168.2.0/24' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '558 - test': + proto => tcp, + port => '558', + action => accept, + destination => '! 192.168.2.0/24', + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT (! -d|-d !) 192.168.2.0\/(24|255\.255\.255\.0) -p tcp -m multiport --ports 558 -m comment --comment "558 - test" -j ACCEPT/) + end + end + end + + # Invalid address + context '256.168.2.0/24' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '558 - test': + proto => tcp, + port => '558', + action => accept, + destination => '256.168.2.0/24', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/host_to_ip failed for 256.168.2.0\/(24|255\.255\.255\.0)/) + end + end + + it 'should not contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -d 256.168.2.0\/(24|255\.255\.255\.0) -p tcp -m multiport --ports 558 -m comment --comment "558 - test" -j ACCEPT/) + end + end + end + end + + describe 'dst_range' do + context '192.168.1.1-192.168.1.10' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '559 - test': + proto => tcp, + port => '559', + action => accept, + dst_range => '192.168.1.1-192.168.1.10', + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m iprange --dst-range 192.168.1.1-192.168.1.10 -m multiport --ports 559 -m comment --comment "559 - test" -j ACCEPT/) + end + end + end + + # Invalid IP + context '392.168.1.1-192.168.1.10' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '559 - test': + proto => tcp, + port => '559', + action => accept, + dst_range => '392.168.1.1-192.168.1.10', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Invalid value "392.168.1.1-192.168.1.10"/) + end + end + + it 'should not contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m iprange --dst-range 392.168.1.1-192.168.1.10 -m multiport --ports 559 -m comment --comment "559 - test" -j ACCEPT/) + end + end + end + end + + describe 'sport' do + context 'single port' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '560 - test': + proto => tcp, + sport => '560', + action => accept, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --sports 560 -m comment --comment "560 - test" -j ACCEPT/) + end + end + end + + context 'multiple ports' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '560 - test': + proto => tcp, + sport => '560-561', + action => accept, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --sports 560:561 -m comment --comment "560 - test" -j ACCEPT/) + end + end + end + + context 'invalid ports' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '560 - test': + proto => tcp, + sport => '9999560-561', + action => accept, + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/invalid port\/service `9999560' specified/) + end + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m multiport --sports 9999560-561 -m comment --comment "560 - test" -j ACCEPT/) + end + end + end + end + + describe 'dport' do + context 'single port' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '561 - test': + proto => tcp, + dport => '561', + action => accept, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --dports 561 -m comment --comment "561 - test" -j ACCEPT/) + end + end + end + + context 'multiple ports' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '561 - test': + proto => tcp, + dport => '561-562', + action => accept, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --dports 561:562 -m comment --comment "561 - test" -j ACCEPT/) + end + end + end + + context 'invalid ports' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '561 - test': + proto => tcp, + dport => '9999561-562', + action => accept, + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/invalid port\/service `9999561' specified/) + end + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m multiport --dports 9999561-562 -m comment --comment "560 - test" -j ACCEPT/) + end + end + end + end + + describe 'port' do + context 'single port' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '562 - test': + proto => tcp, + port => '562', + action => accept, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 562 -m comment --comment "562 - test" -j ACCEPT/) + end + end + end + + context 'multiple ports' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '562 - test': + proto => tcp, + port => '562-563', + action => accept, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 562:563 -m comment --comment "562 - test" -j ACCEPT/) + end + end + end + + context 'invalid ports' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '562 - test': + proto => tcp, + port => '9999562-563', + action => accept, + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/invalid port\/service `9999562' specified/) + end + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m multiport --ports 9999562-563 -m comment --comment "562 - test" -j ACCEPT/) + end + end + end + end + + ['dst_type', 'src_type'].each do |type| + describe "#{type}" do + context 'MULTICAST' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '563 - test': + proto => tcp, + action => accept, + #{type} => 'MULTICAST', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m addrtype\s.*\sMULTICAST -m comment --comment "563 - test" -j ACCEPT/) + end + end + end + + context 'BROKEN' do + it 'fails' do + pp = <<-EOS + class { '::firewall': } + firewall { '563 - test': + proto => tcp, + action => accept, + #{type} => 'BROKEN', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Invalid value "BROKEN"./) + end + end + + it 'should not contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m addrtype\s.*\sBROKEN -m comment --comment "563 - test" -j ACCEPT/) + end + end + end + end + end + + describe 'tcp_flags' do + context 'FIN,SYN ACK' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '564 - test': + proto => tcp, + action => accept, + tcp_flags => 'FIN,SYN ACK', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN ACK -m comment --comment "564 - test" -j ACCEPT/) + end + end + end + end + + describe 'chain' do + context 'INPUT' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '565 - test': + proto => tcp, + action => accept, + chain => 'FORWARD', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A FORWARD -p tcp -m comment --comment "565 - test" -j ACCEPT/) + end + end + end + end + + describe 'table' do + context 'mangle' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '566 - test': + proto => tcp, + action => accept, + table => 'mangle', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save -t mangle') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m comment --comment "566 - test" -j ACCEPT/) + end + end + end + context 'nat' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '566 - test2': + proto => tcp, + action => accept, + table => 'nat', + chain => 'OUTPUT', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should not contain the rule' do + shell('iptables-save -t nat') do |r| + expect(r.stdout).to match(/-A OUTPUT -p tcp -m comment --comment "566 - test2" -j ACCEPT/) + end + end + end + end + + describe 'jump' do + after :all do + iptables_flush_all_tables + expect(shell('iptables -t filter -X TEST').stderr).to eq("") + end + + context 'MARK' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewallchain { 'TEST:filter:IPv4': + ensure => present, + } + firewall { '567 - test': + proto => tcp, + chain => 'INPUT', + jump => 'TEST', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m comment --comment "567 - test" -j TEST/) + end + end + end + + context 'jump and apply' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewallchain { 'TEST:filter:IPv4': + ensure => present, + } + firewall { '568 - test': + proto => tcp, + chain => 'INPUT', + action => 'accept', + jump => 'TEST', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Only one of the parameters 'action' and 'jump' can be set/) + end + end + + it 'should not contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m comment --comment "568 - test" -j TEST/) + end + end + end + end + + describe 'tosource' do + context '192.168.1.1' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '568 - test': + proto => tcp, + table => 'nat', + chain => 'POSTROUTING', + jump => 'SNAT', + tosource => '192.168.1.1', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save -t nat') do |r| + expect(r.stdout).to match(/A POSTROUTING -p tcp -m comment --comment "568 - test" -j SNAT --to-source 192.168.1.1/) + end + end + end + end + + describe 'todest' do + context '192.168.1.1' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '569 - test': + proto => tcp, + table => 'nat', + chain => 'PREROUTING', + jump => 'DNAT', + source => '200.200.200.200', + todest => '192.168.1.1', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save -t nat') do |r| + expect(r.stdout).to match(/-A PREROUTING -s 200.200.200.200(\/32)? -p tcp -m comment --comment "569 - test" -j DNAT --to-destination 192.168.1.1/) + end + end + end + end + + describe 'toports' do + context '192.168.1.1' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '570 - test': + proto => icmp, + table => 'nat', + chain => 'PREROUTING', + jump => 'REDIRECT', + toports => '2222', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save -t nat') do |r| + expect(r.stdout).to match(/-A PREROUTING -p icmp -m comment --comment "570 - test" -j REDIRECT --to-ports 2222/) + end + end + end + end + + # RHEL5 does not support --random + if default['platform'] !~ /el-5/ + describe 'random' do + context '192.168.1.1' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '570 - test 2': + proto => all, + table => 'nat', + chain => 'POSTROUTING', + jump => 'MASQUERADE', + source => '172.30.0.0/16', + random => true + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'should contain the rule' do + shell('iptables-save -t nat') do |r| + expect(r.stdout).to match(/-A POSTROUTING -s 172\.30\.0\.0\/16 -m comment --comment "570 - test 2" -j MASQUERADE --random/) + end + end + end + end + end + + describe 'icmp' do + context 'any' do + it 'fails' do + pp = <<-EOS + class { '::firewall': } + firewall { '571 - test': + proto => icmp, + icmp => 'any', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/This behaviour should be achieved by omitting or undefining the ICMP parameter/) + end + end + + it 'should not contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p icmp -m comment --comment "570 - test" -m icmp --icmp-type 11/) + end + end + end + end + + #iptables version 1.3.5 is not suppored by the ip6tables provider + if default['platform'] !~ /el-5/ + describe 'hop_limit' do + context '5' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '571 - test': + ensure => present, + proto => tcp, + port => '571', + action => accept, + hop_limit => '5', + provider => 'ip6tables', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('ip6tables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 571 -m comment --comment "571 - test" -m hl --hl-eq 5 -j ACCEPT/) + end + end + end + + context 'invalid' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '571 - test': + ensure => present, + proto => tcp, + port => '571', + action => accept, + hop_limit => 'invalid', + provider => 'ip6tables', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Invalid value "invalid"./) + end + end + + it 'should not contain the rule' do + shell('ip6tables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m multiport --ports 571 -m comment --comment "571 - test" -m hl --hl-eq invalid -j ACCEPT/) + end + end + end + end + + describe 'ishasmorefrags' do + context 'true' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '587 - test': + ensure => present, + proto => tcp, + port => '587', + action => accept, + ishasmorefrags => true, + provider => 'ip6tables', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('ip6tables-save') do |r| + expect(r.stdout).to match(/A INPUT -p tcp -m frag --fragid 0 --fragmore -m multiport --ports 587 -m comment --comment "587 - test" -j ACCEPT/) + end + end + end + + context 'false' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '588 - test': + ensure => present, + proto => tcp, + port => '588', + action => accept, + ishasmorefrags => false, + provider => 'ip6tables', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('ip6tables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 588 -m comment --comment "588 - test" -j ACCEPT/) + end + end + end + end + + describe 'islastfrag' do + context 'true' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '589 - test': + ensure => present, + proto => tcp, + port => '589', + action => accept, + islastfrag => true, + provider => 'ip6tables', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('ip6tables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m frag --fragid 0 --fraglast -m multiport --ports 589 -m comment --comment "589 - test" -j ACCEPT/) + end + end + end + + context 'false' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '590 - test': + ensure => present, + proto => tcp, + port => '590', + action => accept, + islastfrag => false, + provider => 'ip6tables', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('ip6tables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 590 -m comment --comment "590 - test" -j ACCEPT/) + end + end + end + end + + describe 'isfirstfrag' do + context 'true' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '591 - test': + ensure => present, + proto => tcp, + port => '591', + action => accept, + isfirstfrag => true, + provider => 'ip6tables', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('ip6tables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m frag --fragid 0 --fragfirst -m multiport --ports 591 -m comment --comment "591 - test" -j ACCEPT/) + end + end + end + + context 'false' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '592 - test': + ensure => present, + proto => tcp, + port => '592', + action => accept, + isfirstfrag => false, + provider => 'ip6tables', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('ip6tables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 592 -m comment --comment "592 - test" -j ACCEPT/) + end + end + end + end + end + + describe 'limit' do + context '500/sec' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '572 - test': + ensure => present, + proto => tcp, + port => '572', + action => accept, + limit => '500/sec', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 572 -m comment --comment "572 - test" -m limit --limit 500\/sec -j ACCEPT/) + end + end + end + end + + describe 'burst' do + context '500' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '573 - test': + ensure => present, + proto => tcp, + port => '573', + action => accept, + limit => '500/sec', + burst => '1500', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 573 -m comment --comment "573 - test" -m limit --limit 500\/sec --limit-burst 1500 -j ACCEPT/) + end + end + end + + context 'invalid' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '571 - test': + ensure => present, + proto => tcp, + port => '571', + action => accept, + limit => '500/sec', + burst => '1500/sec', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Invalid value "1500\/sec"./) + end + end + + it 'should not contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m multiport --ports 573 -m comment --comment "573 - test" -m limit --limit 500\/sec --limit-burst 1500\/sec -j ACCEPT/) + end + end + end + end + + describe 'uid' do + context 'nobody' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '574 - test': + ensure => present, + proto => tcp, + chain => 'OUTPUT', + port => '574', + action => accept, + uid => 'nobody', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A OUTPUT -p tcp -m owner --uid-owner (nobody|\d+) -m multiport --ports 574 -m comment --comment "574 - test" -j ACCEPT/) + end + end + end + end + + describe 'gid' do + context 'root' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '575 - test': + ensure => present, + proto => tcp, + chain => 'OUTPUT', + port => '575', + action => accept, + gid => 'root', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A OUTPUT -p tcp -m owner --gid-owner (root|\d+) -m multiport --ports 575 -m comment --comment "575 - test" -j ACCEPT/) + end + end + end + end + + #iptables version 1.3.5 does not support masks on MARK rules + if default['platform'] !~ /el-5/ + describe 'set_mark' do + context '0x3e8/0xffffffff' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '580 - test': + ensure => present, + chain => 'OUTPUT', + proto => tcp, + port => '580', + jump => 'MARK', + table => 'mangle', + set_mark => '0x3e8/0xffffffff', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save -t mangle') do |r| + expect(r.stdout).to match(/-A OUTPUT -p tcp -m multiport --ports 580 -m comment --comment "580 - test" -j MARK --set-xmark 0x3e8\/0xffffffff/) + end + end + end + end + end + + describe 'pkttype' do + context 'multicast' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '581 - test': + ensure => present, + proto => tcp, + port => '581', + action => accept, + pkttype => 'multicast', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 581 -m pkttype --pkt-type multicast -m comment --comment "581 - test" -j ACCEPT/) + end + end + end + + context 'test' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '582 - test': + ensure => present, + proto => tcp, + port => '582', + action => accept, + pkttype => 'test', + } + EOS + + apply_manifest(pp, :expect_failures => true) do |r| + expect(r.stderr).to match(/Invalid value "test"./) + end + end + + it 'should not contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/-A INPUT -p tcp -m multiport --ports 582 -m pkttype --pkt-type multicast -m comment --comment "582 - test" -j ACCEPT/) + end + end + end + end + + describe 'isfragment' do + context 'true' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '583 - test': + ensure => present, + proto => tcp, + port => '583', + action => accept, + isfragment => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -f -m multiport --ports 583 -m comment --comment "583 - test" -j ACCEPT/) + end + end + end + + context 'false' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '584 - test': + ensure => present, + proto => tcp, + port => '584', + action => accept, + isfragment => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -p tcp -m multiport --ports 584 -m comment --comment "584 - test" -j ACCEPT/) + end + end + end + end + + # RHEL5/SLES does not support -m socket + describe 'socket', :unless => (default['platform'] =~ /el-5/ or fact('operatingsystem') == 'SLES') do + context 'true' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '585 - test': + ensure => present, + proto => tcp, + port => '585', + action => accept, + chain => 'PREROUTING', + table => 'nat', + socket => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save -t nat') do |r| + expect(r.stdout).to match(/-A PREROUTING -p tcp -m multiport --ports 585 -m socket -m comment --comment "585 - test" -j ACCEPT/) + end + end + end + + context 'false' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '586 - test': + ensure => present, + proto => tcp, + port => '586', + action => accept, + chain => 'PREROUTING', + table => 'nat', + socket => false, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save -t nat') do |r| + expect(r.stdout).to match(/-A PREROUTING -p tcp -m multiport --ports 586 -m comment --comment "586 - test" -j ACCEPT/) + end + end + end + end + + describe 'ipsec_policy' do + context 'ipsec' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '593 - test': + ensure => 'present', + action => 'reject', + chain => 'OUTPUT', + destination => '20.0.0.0/8', + ipsec_dir => 'out', + ipsec_policy => 'ipsec', + proto => 'all', + reject => 'icmp-net-unreachable', + table => 'filter', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A OUTPUT -d 20.0.0.0\/(8|255\.0\.0\.0) -m comment --comment "593 - test" -m policy --dir out --pol ipsec -j REJECT --reject-with icmp-net-unreachable/) + end + end + end + + context 'none' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '594 - test': + ensure => 'present', + action => 'reject', + chain => 'OUTPUT', + destination => '20.0.0.0/8', + ipsec_dir => 'out', + ipsec_policy => 'none', + proto => 'all', + reject => 'icmp-net-unreachable', + table => 'filter', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A OUTPUT -d 20.0.0.0\/(8|255\.0\.0\.0) -m comment --comment "594 - test" -m policy --dir out --pol none -j REJECT --reject-with icmp-net-unreachable/) + end + end + end + end + + describe 'ipsec_dir' do + context 'out' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '595 - test': + ensure => 'present', + action => 'reject', + chain => 'OUTPUT', + destination => '20.0.0.0/8', + ipsec_dir => 'out', + ipsec_policy => 'ipsec', + proto => 'all', + reject => 'icmp-net-unreachable', + table => 'filter', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A OUTPUT -d 20.0.0.0\/(8|255\.0\.0\.0) -m comment --comment "595 - test" -m policy --dir out --pol ipsec -j REJECT --reject-with icmp-net-unreachable/) + end + end + end + + context 'in' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '596 - test': + ensure => 'present', + action => 'reject', + chain => 'INPUT', + destination => '20.0.0.0/8', + ipsec_dir => 'in', + ipsec_policy => 'none', + proto => 'all', + reject => 'icmp-net-unreachable', + table => 'filter', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -d 20.0.0.0\/(8|255\.0\.0\.0) -m comment --comment "596 - test" -m policy --dir in --pol none -j REJECT --reject-with icmp-net-unreachable/) + end + end + end + end + + describe 'recent' do + context 'set' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '597 - test': + ensure => 'present', + chain => 'INPUT', + destination => '30.0.0.0/8', + proto => 'all', + table => 'filter', + recent => 'set', + rdest => true, + rname => 'list1', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + # Mask added as of Ubuntu 14.04. + expect(r.stdout).to match(/-A INPUT -d 30.0.0.0\/(8|255\.0\.0\.0) -m comment --comment "597 - test" -m recent --set --name list1 (--mask 255.255.255.255 )?--rdest/) + end + end + end + + context 'rcheck' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '598 - test': + ensure => 'present', + chain => 'INPUT', + destination => '30.0.0.0/8', + proto => 'all', + table => 'filter', + recent => 'rcheck', + rsource => true, + rname => 'list1', + rseconds => 60, + rhitcount => 5, + rttl => true, + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -d 30.0.0.0\/(8|255\.0\.0\.0) -m comment --comment "598 - test" -m recent --rcheck --seconds 60 --hitcount 5 --rttl --name list1 (--mask 255.255.255.255 )?--rsource/) + end + end + end + + context 'update' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '599 - test': + ensure => 'present', + chain => 'INPUT', + destination => '30.0.0.0/8', + proto => 'all', + table => 'filter', + recent => 'update', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -d 30.0.0.0\/(8|255\.0\.0\.0) -m comment --comment "599 - test" -m recent --update/) + end + end + end + + context 'remove' do + it 'applies' do + pp = <<-EOS + class { '::firewall': } + firewall { '600 - test': + ensure => 'present', + chain => 'INPUT', + destination => '30.0.0.0/8', + proto => 'all', + table => 'filter', + recent => 'remove', + } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + it 'should contain the rule' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/-A INPUT -d 30.0.0.0\/(8|255\.0\.0\.0) -m comment --comment "600 - test" -m recent --remove/) + end + end + end + end + + describe 'reset' do + it 'deletes all rules' do + shell('ip6tables --flush') + shell('iptables --flush; iptables -t nat --flush; iptables -t mangle --flush') + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/firewallchain_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/firewallchain_spec.rb new file mode 100644 index 0000000000..757336a75c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/firewallchain_spec.rb @@ -0,0 +1,125 @@ +require 'spec_helper_acceptance' + +describe 'puppet resource firewallchain command:' do + before :all do + iptables_flush_all_tables + end + describe 'ensure' do + context 'present' do + it 'applies cleanly' do + pp = <<-EOS + firewallchain { 'MY_CHAIN:filter:IPv4': + ensure => present, + } + EOS + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'finds the chain' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/MY_CHAIN/) + end + end + end + + context 'absent' do + it 'applies cleanly' do + pp = <<-EOS + firewallchain { 'MY_CHAIN:filter:IPv4': + ensure => absent, + } + EOS + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'fails to find the chain' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/MY_CHAIN/) + end + end + end + end + + # XXX purge => false is not yet implemented + #context 'adding a firewall rule to a chain:' do + # it 'applies cleanly' do + # pp = <<-EOS + # firewallchain { 'MY_CHAIN:filter:IPv4': + # ensure => present, + # } + # firewall { '100 my rule': + # chain => 'MY_CHAIN', + # action => 'accept', + # proto => 'tcp', + # dport => 5000, + # } + # EOS + # # Run it twice and test for idempotency + # apply_manifest(pp, :catch_failures => true) + # apply_manifest(pp, :catch_changes => true) + # end + #end + + #context 'not purge firewallchain chains:' do + # it 'does not purge the rule' do + # pp = <<-EOS + # firewallchain { 'MY_CHAIN:filter:IPv4': + # ensure => present, + # purge => false, + # before => Resources['firewall'], + # } + # resources { 'firewall': + # purge => true, + # } + # EOS + # # Run it twice and test for idempotency + # apply_manifest(pp, :catch_failures => true) do |r| + # expect(r.stdout).to_not match(/removed/) + # expect(r.stderr).to eq('') + # end + # apply_manifest(pp, :catch_changes => true) + # end + + # it 'still has the rule' do + # pp = <<-EOS + # firewall { '100 my rule': + # chain => 'MY_CHAIN', + # action => 'accept', + # proto => 'tcp', + # dport => 5000, + # } + # EOS + # # Run it twice and test for idempotency + # apply_manifest(pp, :catch_changes => true) + # end + #end + + describe 'policy' do + after :all do + shell('iptables -t filter -P FORWARD ACCEPT') + end + + context 'DROP' do + it 'applies cleanly' do + pp = <<-EOS + firewallchain { 'FORWARD:filter:IPv4': + policy => 'drop', + } + EOS + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'finds the chain' do + shell('iptables-save') do |r| + expect(r.stdout).to match(/FORWARD DROP/) + end + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/ip6_fragment_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/ip6_fragment_spec.rb new file mode 100644 index 0000000000..bfce0e607f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/ip6_fragment_spec.rb @@ -0,0 +1,114 @@ +require 'spec_helper_acceptance' + +if default['platform'] =~ /el-5/ + describe "firewall ip6tables doesn't work on 1.3.5 because --comment is missing" do + before :all do + ip6tables_flush_all_tables + end + + it "can't use ip6tables" do + pp = <<-EOS + class { '::firewall': } + firewall { '599 - test': + ensure => present, + proto => 'tcp', + provider => 'ip6tables', + } + EOS + expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/ip6tables provider is not supported/) + end + end +else + describe 'firewall ishasmorefrags/islastfrag/isfirstfrag properties' do + before :all do + ip6tables_flush_all_tables + end + + shared_examples "is idempotent" do |values, line_match| + it "changes the values to #{values}" do + pp = <<-EOS + class { '::firewall': } + firewall { '599 - test': + ensure => present, + proto => 'tcp', + provider => 'ip6tables', + #{values} + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + + shell('ip6tables-save') do |r| + expect(r.stdout).to match(/#{line_match}/) + end + end + end + shared_examples "doesn't change" do |values, line_match| + it "doesn't change the values to #{values}" do + pp = <<-EOS + class { '::firewall': } + firewall { '599 - test': + ensure => present, + proto => 'tcp', + provider => 'ip6tables', + #{values} + } + EOS + + apply_manifest(pp, :catch_changes => true) + + shell('ip6tables-save') do |r| + expect(r.stdout).to match(/#{line_match}/) + end + end + end + + describe 'adding a rule' do + context 'when unset' do + before :all do + ip6tables_flush_all_tables + end + it_behaves_like 'is idempotent', '', /-A INPUT -p tcp -m comment --comment "599 - test"/ + end + context 'when set to true' do + before :all do + ip6tables_flush_all_tables + end + it_behaves_like "is idempotent", 'ishasmorefrags => true, islastfrag => true, isfirstfrag => true', /-A INPUT -p tcp -m frag --fragid 0 --fragmore -m frag --fragid 0 --fraglast -m frag --fragid 0 --fragfirst -m comment --comment "599 - test"/ + end + context 'when set to false' do + before :all do + ip6tables_flush_all_tables + end + it_behaves_like "is idempotent", 'ishasmorefrags => false, islastfrag => false, isfirstfrag => false', /-A INPUT -p tcp -m comment --comment "599 - test"/ + end + end + describe 'editing a rule' do + context 'when unset or false' do + before :each do + ip6tables_flush_all_tables + shell('ip6tables -A INPUT -p tcp -m comment --comment "599 - test"') + end + context 'and current value is false' do + it_behaves_like "doesn't change", 'ishasmorefrags => false, islastfrag => false, isfirstfrag => false', /-A INPUT -p tcp -m comment --comment "599 - test"/ + end + context 'and current value is true' do + it_behaves_like "is idempotent", 'ishasmorefrags => true, islastfrag => true, isfirstfrag => true', /-A INPUT -p tcp -m frag --fragid 0 --fragmore -m frag --fragid 0 --fraglast -m frag --fragid 0 --fragfirst -m comment --comment "599 - test"/ + end + end + context 'when set to true' do + before :each do + ip6tables_flush_all_tables + shell('ip6tables -A INPUT -p tcp -m frag --fragid 0 --fragmore -m frag --fragid 0 --fraglast -m frag --fragid 0 --fragfirst -m comment --comment "599 - test"') + end + context 'and current value is false' do + it_behaves_like "is idempotent", 'ishasmorefrags => false, islastfrag => false, isfirstfrag => false', /-A INPUT -p tcp -m comment --comment "599 - test"/ + end + context 'and current value is true' do + it_behaves_like "doesn't change", 'ishasmorefrags => true, islastfrag => true, isfirstfrag => true', /-A INPUT -p tcp -m frag --fragid 0 --fragmore -m frag --fragid 0 --fraglast -m frag --fragid 0 --fragfirst -m comment --comment "599 - test"/ + end + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/isfragment_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/isfragment_spec.rb new file mode 100644 index 0000000000..7fdedc2873 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/isfragment_spec.rb @@ -0,0 +1,92 @@ +require 'spec_helper_acceptance' + +describe 'firewall isfragment property' do + before :all do + iptables_flush_all_tables + end + + shared_examples "is idempotent" do |value, line_match| + it "changes the value to #{value}" do + pp = <<-EOS + class { '::firewall': } + firewall { '597 - test': + ensure => present, + proto => 'tcp', + #{value} + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + + shell('iptables-save') do |r| + expect(r.stdout).to match(/#{line_match}/) + end + end + end + shared_examples "doesn't change" do |value, line_match| + it "doesn't change the value to #{value}" do + pp = <<-EOS + class { '::firewall': } + firewall { '597 - test': + ensure => present, + proto => 'tcp', + #{value} + } + EOS + + apply_manifest(pp, :catch_changes => true) + + shell('iptables-save') do |r| + expect(r.stdout).to match(/#{line_match}/) + end + end + end + + describe 'adding a rule' do + context 'when unset' do + before :all do + iptables_flush_all_tables + end + it_behaves_like 'is idempotent', '', /-A INPUT -p tcp -m comment --comment "597 - test"/ + end + context 'when set to true' do + before :all do + iptables_flush_all_tables + end + it_behaves_like 'is idempotent', 'isfragment => true,', /-A INPUT -p tcp -f -m comment --comment "597 - test"/ + end + context 'when set to false' do + before :all do + iptables_flush_all_tables + end + it_behaves_like "is idempotent", 'isfragment => false,', /-A INPUT -p tcp -m comment --comment "597 - test"/ + end + end + describe 'editing a rule' do + context 'when unset or false' do + before :each do + iptables_flush_all_tables + shell('iptables -A INPUT -p tcp -m comment --comment "597 - test"') + end + context 'and current value is false' do + it_behaves_like "doesn't change", 'isfragment => false,', /-A INPUT -p tcp -m comment --comment "597 - test"/ + end + context 'and current value is true' do + it_behaves_like "is idempotent", 'isfragment => true,', /-A INPUT -p tcp -f -m comment --comment "597 - test"/ + end + end + context 'when set to true' do + before :each do + iptables_flush_all_tables + shell('iptables -A INPUT -p tcp -f -m comment --comment "597 - test"') + end + context 'and current value is false' do + it_behaves_like "is idempotent", 'isfragment => false,', /-A INPUT -p tcp -m comment --comment "597 - test"/ + end + context 'and current value is true' do + it_behaves_like "doesn't change", 'isfragment => true,', /-A INPUT -p tcp -f -m comment --comment "597 - test"/ + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-59-x64-pe.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-59-x64-pe.yml new file mode 100644 index 0000000000..3a6470beae --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-59-x64-pe.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-59-x64: + roles: + - master + - database + - console + platform: el-5-x86_64 + box : centos-59-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: pe diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-59-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-59-x64.yml new file mode 100644 index 0000000000..b41a947169 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-59-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-59-x64: + roles: + - master + platform: el-5-x86_64 + box : centos-59-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-64-x64-fusion.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-64-x64-fusion.yml new file mode 100644 index 0000000000..d5166735ec --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-64-x64-fusion.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-fusion503-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-fusion503-nocm.box + hypervisor : fusion +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-64-x64-pe.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-64-x64-pe.yml new file mode 100644 index 0000000000..7d9242f1b9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-64-x64-pe.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-64-x64: + roles: + - master + - database + - dashboard + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: pe diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-64-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-64-x64.yml new file mode 100644 index 0000000000..05540ed8c5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/centos-64-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/debian-607-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/debian-607-x64.yml new file mode 100644 index 0000000000..4c8be42d03 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/debian-607-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-607-x64: + roles: + - master + platform: debian-6-amd64 + box : debian-607-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/debian-70rc1-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/debian-70rc1-x64.yml new file mode 100644 index 0000000000..19181c123d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/debian-70rc1-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-70rc1-x64: + roles: + - master + platform: debian-7-amd64 + box : debian-70rc1-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/default.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000000..05540ed8c5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/default.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/fedora-18-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/fedora-18-x64.yml new file mode 100644 index 0000000000..624b53716b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/fedora-18-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + fedora-18-x64: + roles: + - master + platform: fedora-18-x86_64 + box : fedora-18-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/sles-11sp1-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/sles-11sp1-x64.yml new file mode 100644 index 0000000000..554c37a505 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/sles-11sp1-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + sles-11sp1-x64: + roles: + - master + platform: sles-11-x86_64 + box : sles-11sp1-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml new file mode 100644 index 0000000000..5047017e62 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-10044-x64: + roles: + - master + platform: ubuntu-10.04-amd64 + box : ubuntu-server-10044-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: git diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 0000000000..d065b304f8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-12.04-amd64 + box : ubuntu-server-12042-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 0000000000..7e789c8d8d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,9 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-14.04-64 + box: puppetlabs/ubuntu-14.04-64-nocm + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/params_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/params_spec.rb new file mode 100644 index 0000000000..c0f93ad21f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/params_spec.rb @@ -0,0 +1,154 @@ +require 'spec_helper_acceptance' + +describe "param based tests:" do + # Takes a hash and converts it into a firewall resource + def pp(params) + name = params.delete('name') || '100 test' + pm = <<-EOS +firewall { '#{name}': + EOS + + params.each do |k,v| + pm += <<-EOS + #{k} => #{v}, + EOS + end + + pm += <<-EOS +} + EOS + pm + end + + it 'test various params', :unless => (default['platform'].match(/el-5/) || fact('operatingsystem') == 'SLES') do + iptables_flush_all_tables + + ppm = pp({ + 'table' => "'raw'", + 'socket' => 'true', + 'chain' => "'PREROUTING'", + 'jump' => 'LOG', + 'log_level' => 'debug', + }) + + expect(apply_manifest(ppm, :catch_failures => true).exit_code).to eq(2) + expect(apply_manifest(ppm, :catch_failures => true).exit_code).to be_zero + end + + it 'test log rule' do + iptables_flush_all_tables + + ppm = pp({ + 'name' => '998 log all', + 'proto' => 'all', + 'jump' => 'LOG', + 'log_level' => 'debug', + }) + expect(apply_manifest(ppm, :catch_failures => true).exit_code).to eq(2) + expect(apply_manifest(ppm, :catch_failures => true).exit_code).to be_zero + end + + it 'test log rule - changing names' do + iptables_flush_all_tables + + ppm1 = pp({ + 'name' => '004 log all INVALID packets', + 'chain' => 'INPUT', + 'proto' => 'all', + 'ctstate' => 'INVALID', + 'jump' => 'LOG', + 'log_level' => '3', + 'log_prefix' => '"IPTABLES dropped invalid: "', + }) + + ppm2 = pp({ + 'name' => '003 log all INVALID packets', + 'chain' => 'INPUT', + 'proto' => 'all', + 'ctstate' => 'INVALID', + 'jump' => 'LOG', + 'log_level' => '3', + 'log_prefix' => '"IPTABLES dropped invalid: "', + }) + + expect(apply_manifest(ppm1, :catch_failures => true).exit_code).to eq(2) + + ppm = <<-EOS + "\n" + ppm2 + resources { 'firewall': + purge => true, + } + EOS + expect(apply_manifest(ppm, :catch_failures => true).exit_code).to eq(2) + end + + it 'test chain - changing names' do + iptables_flush_all_tables + + ppm1 = pp({ + 'name' => '004 with a chain', + 'chain' => 'INPUT', + 'proto' => 'all', + }) + + ppm2 = pp({ + 'name' => '004 with a chain', + 'chain' => 'OUTPUT', + 'proto' => 'all', + }) + + apply_manifest(ppm1, :expect_changes => true) + + ppm = <<-EOS + "\n" + ppm2 + resources { 'firewall': + purge => true, + } + EOS + expect(apply_manifest(ppm2, :expect_failures => true).stderr).to match(/is not supported/) + end + + it 'test log rule - idempotent' do + iptables_flush_all_tables + + ppm1 = pp({ + 'name' => '004 log all INVALID packets', + 'chain' => 'INPUT', + 'proto' => 'all', + 'ctstate' => 'INVALID', + 'jump' => 'LOG', + 'log_level' => '3', + 'log_prefix' => '"IPTABLES dropped invalid: "', + }) + + expect(apply_manifest(ppm1, :catch_failures => true).exit_code).to eq(2) + expect(apply_manifest(ppm1, :catch_failures => true).exit_code).to be_zero + end + + it 'test src_range rule' do + iptables_flush_all_tables + + ppm = pp({ + 'name' => '997 block src ip range', + 'chain' => 'INPUT', + 'proto' => 'all', + 'action' => 'drop', + 'src_range' => '"10.0.0.1-10.0.0.10"', + }) + expect(apply_manifest(ppm, :catch_failures => true).exit_code).to eq(2) + expect(apply_manifest(ppm, :catch_failures => true).exit_code).to be_zero + end + + it 'test dst_range rule' do + iptables_flush_all_tables + + ppm = pp({ + 'name' => '998 block dst ip range', + 'chain' => 'INPUT', + 'proto' => 'all', + 'action' => 'drop', + 'dst_range' => '"10.0.0.2-10.0.0.20"', + }) + expect(apply_manifest(ppm, :catch_failures => true).exit_code).to eq(2) + expect(apply_manifest(ppm, :catch_failures => true).exit_code).to be_zero + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/purge_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/purge_spec.rb new file mode 100644 index 0000000000..f62b14f936 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/purge_spec.rb @@ -0,0 +1,124 @@ +require 'spec_helper_acceptance' + +describe "purge tests:" do + context('resources purge') do + before(:all) do + iptables_flush_all_tables + + shell('iptables -A INPUT -s 1.2.1.2') + shell('iptables -A INPUT -s 1.2.1.2') + end + + it 'make sure duplicate existing rules get purged' do + + pp = <<-EOS + class { 'firewall': } + resources { 'firewall': + purge => true, + } + EOS + + apply_manifest(pp, :expect_changes => true) + end + + it 'saves' do + shell('iptables-save') do |r| + expect(r.stdout).to_not match(/1\.2\.1\.2/) + expect(r.stderr).to eq("") + end + end + end + + context('chain purge') do + before(:each) do + iptables_flush_all_tables + + shell('iptables -A INPUT -p tcp -s 1.2.1.1') + shell('iptables -A INPUT -p udp -s 1.2.1.1') + shell('iptables -A OUTPUT -s 1.2.1.2 -m comment --comment "010 output-1.2.1.2"') + end + + it 'purges only the specified chain' do + pp = <<-EOS + class { 'firewall': } + firewallchain { 'INPUT:filter:IPv4': + purge => true, + } + EOS + + apply_manifest(pp, :expect_changes => true) + + shell('iptables-save') do |r| + expect(r.stdout).to match(/010 output-1\.2\.1\.2/) + expect(r.stdout).to_not match(/1\.2\.1\.1/) + expect(r.stderr).to eq("") + end + end + + it 'ignores managed rules' do + pp = <<-EOS + class { 'firewall': } + firewallchain { 'OUTPUT:filter:IPv4': + purge => true, + } + firewall { '010 output-1.2.1.2': + chain => 'OUTPUT', + proto => 'all', + source => '1.2.1.2', + } + EOS + + apply_manifest(pp, :catch_changes => true) + end + + it 'ignores specified rules' do + pp = <<-EOS + class { 'firewall': } + firewallchain { 'INPUT:filter:IPv4': + purge => true, + ignore => [ + '-s 1\.2\.1\.1', + ], + } + EOS + + apply_manifest(pp, :catch_changes => true) + end + + it 'adds managed rules with ignored rules' do + pp = <<-EOS + class { 'firewall': } + firewallchain { 'INPUT:filter:IPv4': + purge => true, + ignore => [ + '-s 1\.2\.1\.1', + ], + } + firewall { '014 input-1.2.1.6': + chain => 'INPUT', + proto => 'all', + source => '1.2.1.6', + } + -> firewall { '013 input-1.2.1.5': + chain => 'INPUT', + proto => 'all', + source => '1.2.1.5', + } + -> firewall { '012 input-1.2.1.4': + chain => 'INPUT', + proto => 'all', + source => '1.2.1.4', + } + -> firewall { '011 input-1.2.1.3': + chain => 'INPUT', + proto => 'all', + source => '1.2.1.3', + } + EOS + + apply_manifest(pp, :catch_failures => true) + + expect(shell('iptables-save').stdout).to match(/-A INPUT -s 1\.2\.1\.1(\/32)? -p tcp\s?\n-A INPUT -s 1\.2\.1\.1(\/32)? -p udp/) + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/resource_cmd_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/resource_cmd_spec.rb new file mode 100644 index 0000000000..c9a852d826 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/resource_cmd_spec.rb @@ -0,0 +1,93 @@ +require 'spec_helper_acceptance' + +# Here we want to test the the resource commands ability to work with different +# existing ruleset scenarios. This will give the parsing capabilities of the +# code a good work out. +describe 'puppet resource firewall command:' do + context 'make sure it returns no errors when executed on a clean machine' do + it do + shell('puppet resource firewall') do |r| + r.exit_code.should be_zero + # don't check stdout, some boxes come with rules, that is normal + r.stderr.should be_empty + end + end + end + + context 'flush iptables and make sure it returns nothing afterwards' do + before(:all) do + iptables_flush_all_tables + end + + # No rules, means no output thanks. And no errors as well. + it do + shell('puppet resource firewall') do |r| + r.exit_code.should be_zero + r.stderr.should be_empty + r.stdout.should == "\n" + end + end + end + + context 'accepts rules without comments' do + before(:all) do + iptables_flush_all_tables + shell('iptables -A INPUT -j ACCEPT -p tcp --dport 80') + end + + it do + shell('puppet resource firewall') do |r| + r.exit_code.should be_zero + # don't check stdout, testing preexisting rules, output is normal + r.stderr.should be_empty + end + end + end + + context 'accepts rules with invalid comments' do + before(:all) do + iptables_flush_all_tables + shell('iptables -A INPUT -j ACCEPT -p tcp --dport 80 -m comment --comment "http"') + end + + it do + shell('puppet resource firewall') do |r| + r.exit_code.should be_zero + # don't check stdout, testing preexisting rules, output is normal + r.stderr.should be_empty + end + end + end + + context 'accepts rules with negation' do + before :all do + iptables_flush_all_tables + shell('iptables -t nat -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535') + shell('iptables -t nat -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p udp -j MASQUERADE --to-ports 1024-65535') + shell('iptables -t nat -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j MASQUERADE') + end + + it do + shell('puppet resource firewall') do |r| + r.exit_code.should be_zero + # don't check stdout, testing preexisting rules, output is normal + r.stderr.should be_empty + end + end + end + + context 'accepts rules with match extension tcp flag' do + before :all do + iptables_flush_all_tables + shell('iptables -t mangle -A PREROUTING -d 1.2.3.4 -p tcp -m tcp -m multiport --dports 80,443,8140 -j MARK --set-mark 42') + end + + it do + shell('puppet resource firewall') do |r| + r.exit_code.should be_zero + # don't check stdout, testing preexisting rules, output is normal + r.stderr.should be_empty + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/rules_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/rules_spec.rb new file mode 100644 index 0000000000..b0e66ae5bc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/rules_spec.rb @@ -0,0 +1,252 @@ +require 'spec_helper_acceptance' + +describe 'complex ruleset 1' do + before :all do + iptables_flush_all_tables + end + + after :all do + shell('iptables -t filter -P INPUT ACCEPT') + shell('iptables -t filter -P FORWARD ACCEPT') + shell('iptables -t filter -P OUTPUT ACCEPT') + shell('iptables -t filter --flush') + end + + it 'applies cleanly' do + pp = <<-EOS + firewall { '090 forward allow local': + chain => 'FORWARD', + proto => 'all', + source => '10.0.0.0/8', + destination => '10.0.0.0/8', + action => 'accept', + } + firewall { '100 forward standard allow tcp': + chain => 'FORWARD', + source => '10.0.0.0/8', + destination => '!10.0.0.0/8', + proto => 'tcp', + state => 'NEW', + port => [80,443,21,20,22,53,123,43,873,25,465], + action => 'accept', + } + firewall { '100 forward standard allow udp': + chain => 'FORWARD', + source => '10.0.0.0/8', + destination => '!10.0.0.0/8', + proto => 'udp', + port => [53,123], + action => 'accept', + } + firewall { '100 forward standard allow icmp': + chain => 'FORWARD', + source => '10.0.0.0/8', + destination => '!10.0.0.0/8', + proto => 'icmp', + action => 'accept', + } + + firewall { '090 ignore ipsec': + table => 'nat', + chain => 'POSTROUTING', + outiface => 'eth0', + ipsec_policy => 'ipsec', + ipsec_dir => 'out', + action => 'accept', + } + firewall { '093 ignore 10.0.0.0/8': + table => 'nat', + chain => 'POSTROUTING', + outiface => 'eth0', + destination => '10.0.0.0/8', + action => 'accept', + } + firewall { '093 ignore 172.16.0.0/12': + table => 'nat', + chain => 'POSTROUTING', + outiface => 'eth0', + destination => '172.16.0.0/12', + action => 'accept', + } + firewall { '093 ignore 192.168.0.0/16': + table => 'nat', + chain => 'POSTROUTING', + outiface => 'eth0', + destination => '192.168.0.0/16', + action => 'accept', + } + firewall { '100 masq outbound': + table => 'nat', + chain => 'POSTROUTING', + outiface => 'eth0', + jump => 'MASQUERADE', + } + firewall { '101 redirect port 1': + table => 'nat', + chain => 'PREROUTING', + iniface => 'eth0', + proto => 'tcp', + dport => '1', + toports => '22', + jump => 'REDIRECT', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end + + it 'contains appropriate rules' do + shell('iptables-save') do |r| + [ + /INPUT ACCEPT/, + /FORWARD ACCEPT/, + /OUTPUT ACCEPT/, + /-A FORWARD -s 10.0.0.0\/(8|255\.0\.0\.0) -d 10.0.0.0\/(8|255\.0\.0\.0) -m comment --comment \"090 forward allow local\" -j ACCEPT/, + /-A FORWARD -s 10.0.0.0\/(8|255\.0\.0\.0) (! -d|-d !) 10.0.0.0\/(8|255\.0\.0\.0) -p icmp -m comment --comment \"100 forward standard allow icmp\" -j ACCEPT/, + /-A FORWARD -s 10.0.0.0\/(8|255\.0\.0\.0) (! -d|-d !) 10.0.0.0\/(8|255\.0\.0\.0) -p tcp -m multiport --ports 80,443,21,20,22,53,123,43,873,25,465 -m comment --comment \"100 forward standard allow tcp\" -m state --state NEW -j ACCEPT/, + /-A FORWARD -s 10.0.0.0\/(8|255\.0\.0\.0) (! -d|-d !) 10.0.0.0\/(8|255\.0\.0\.0) -p udp -m multiport --ports 53,123 -m comment --comment \"100 forward standard allow udp\" -j ACCEPT/ + ].each do |line| + expect(r.stdout).to match(line) + end + end + end +end + +describe 'complex ruleset 2' do + after :all do + shell('iptables -t filter -P INPUT ACCEPT') + shell('iptables -t filter -P FORWARD ACCEPT') + shell('iptables -t filter -P OUTPUT ACCEPT') + shell('iptables -t filter --flush') + expect(shell('iptables -t filter -X LOCAL_INPUT').stderr).to eq("") + expect(shell('iptables -t filter -X LOCAL_INPUT_PRE').stderr).to eq("") + end + + it 'applies cleanly' do + pp = <<-EOS + class { '::firewall': } + + Firewall { + proto => 'all', + stage => 'pre', + } + Firewallchain { + stage => 'pre', + purge => 'true', + ignore => [ + '--comment "[^"]*(?i:ignore)[^"]*"', + ], + } + + firewall { '010 INPUT allow established and related': + proto => 'all', + state => ['ESTABLISHED', 'RELATED'], + action => 'accept', + before => Firewallchain['INPUT:filter:IPv4'], + } + firewall { '012 accept loopback': + iniface => 'lo', + action => 'accept', + before => Firewallchain['INPUT:filter:IPv4'], + } + firewall { '020 ssh': + proto => 'tcp', + dport => '22', + state => 'NEW', + action => 'accept', + before => Firewallchain['INPUT:filter:IPv4'], + } + + firewall { '013 icmp echo-request': + proto => 'icmp', + icmp => 'echo-request', + action => 'accept', + source => '10.0.0.0/8', + } + firewall { '013 icmp destination-unreachable': + proto => 'icmp', + icmp => 'destination-unreachable', + action => 'accept', + } + firewall { '013 icmp time-exceeded': + proto => 'icmp', + icmp => 'time-exceeded', + action => 'accept', + } + firewall { '999 reject': + action => 'reject', + reject => 'icmp-host-prohibited', + } + + + firewallchain { 'LOCAL_INPUT_PRE:filter:IPv4': } + firewall { '001 LOCAL_INPUT_PRE': + jump => 'LOCAL_INPUT_PRE', + require => Firewallchain['LOCAL_INPUT_PRE:filter:IPv4'], + } + firewallchain { 'LOCAL_INPUT:filter:IPv4': } + firewall { '900 LOCAL_INPUT': + jump => 'LOCAL_INPUT', + require => Firewallchain['LOCAL_INPUT:filter:IPv4'], + } + firewallchain { 'INPUT:filter:IPv4': + policy => 'drop', + ignore => [ + '-j fail2ban-ssh', + '--comment "[^"]*(?i:ignore)[^"]*"', + ], + } + + + firewall { '010 allow established and related': + chain => 'FORWARD', + proto => 'all', + state => ['ESTABLISHED','RELATED'], + action => 'accept', + before => Firewallchain['FORWARD:filter:IPv4'], + } + firewallchain { 'FORWARD:filter:IPv4': + policy => 'drop', + } + + firewallchain { 'OUTPUT:filter:IPv4': } + + + # purge unknown rules from mangle table + firewallchain { ['PREROUTING:mangle:IPv4', 'INPUT:mangle:IPv4', 'FORWARD:mangle:IPv4', 'OUTPUT:mangle:IPv4', 'POSTROUTING:mangle:IPv4']: } + + # and the nat table + firewallchain { ['PREROUTING:nat:IPv4', 'INPUT:nat:IPv4', 'OUTPUT:nat:IPv4', 'POSTROUTING:nat:IPv4']: } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'contains appropriate rules' do + shell('iptables-save') do |r| + [ + /INPUT DROP/, + /FORWARD DROP/, + /OUTPUT ACCEPT/, + /LOCAL_INPUT/, + /LOCAL_INPUT_PRE/, + /-A INPUT -m comment --comment \"001 LOCAL_INPUT_PRE\" -j LOCAL_INPUT_PRE/, + /-A INPUT -m comment --comment \"010 INPUT allow established and related\" -m state --state RELATED,ESTABLISHED -j ACCEPT/, + /-A INPUT -i lo -m comment --comment \"012 accept loopback\" -j ACCEPT/, + /-A INPUT -p icmp -m comment --comment \"013 icmp destination-unreachable\" -m icmp --icmp-type 3 -j ACCEPT/, + /-A INPUT -s 10.0.0.0\/(8|255\.0\.0\.0) -p icmp -m comment --comment \"013 icmp echo-request\" -m icmp --icmp-type 8 -j ACCEPT/, + /-A INPUT -p icmp -m comment --comment \"013 icmp time-exceeded\" -m icmp --icmp-type 11 -j ACCEPT/, + /-A INPUT -p tcp -m multiport --dports 22 -m comment --comment \"020 ssh\" -m state --state NEW -j ACCEPT/, + /-A INPUT -m comment --comment \"900 LOCAL_INPUT\" -j LOCAL_INPUT/, + /-A INPUT -m comment --comment \"999 reject\" -j REJECT --reject-with icmp-host-prohibited/, + /-A FORWARD -m comment --comment \"010 allow established and related\" -m state --state RELATED,ESTABLISHED -j ACCEPT/ + ].each do |line| + expect(r.stdout).to match(line) + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/socket_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/socket_spec.rb new file mode 100644 index 0000000000..c4a05348cf --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/socket_spec.rb @@ -0,0 +1,97 @@ +require 'spec_helper_acceptance' + +# RHEL5 does not support -m socket +describe 'firewall socket property', :unless => (default['platform'] =~ /el-5/ || fact('operatingsystem') == 'SLES') do + before :all do + iptables_flush_all_tables + end + + shared_examples "is idempotent" do |value, line_match| + it "changes the value to #{value}" do + pp = <<-EOS + class { '::firewall': } + firewall { '598 - test': + ensure => present, + proto => 'tcp', + chain => 'PREROUTING', + table => 'raw', + #{value} + } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + + shell('iptables-save -t raw') do |r| + expect(r.stdout).to match(/#{line_match}/) + end + end + end + shared_examples "doesn't change" do |value, line_match| + it "doesn't change the value to #{value}" do + pp = <<-EOS + class { '::firewall': } + firewall { '598 - test': + ensure => present, + proto => 'tcp', + chain => 'PREROUTING', + table => 'raw', + #{value} + } + EOS + + apply_manifest(pp, :catch_changes => true) + + shell('iptables-save -t raw') do |r| + expect(r.stdout).to match(/#{line_match}/) + end + end + end + + describe 'adding a rule' do + context 'when unset' do + before :all do + iptables_flush_all_tables + end + it_behaves_like 'is idempotent', '', /-A PREROUTING -p tcp -m comment --comment "598 - test"/ + end + context 'when set to true' do + before :all do + iptables_flush_all_tables + end + it_behaves_like 'is idempotent', 'socket => true,', /-A PREROUTING -p tcp -m socket -m comment --comment "598 - test"/ + end + context 'when set to false' do + before :all do + iptables_flush_all_tables + end + it_behaves_like "is idempotent", 'socket => false,', /-A PREROUTING -p tcp -m comment --comment "598 - test"/ + end + end + describe 'editing a rule' do + context 'when unset or false' do + before :each do + iptables_flush_all_tables + shell('iptables -t raw -A PREROUTING -p tcp -m comment --comment "598 - test"') + end + context 'and current value is false' do + it_behaves_like "doesn't change", 'socket => false,', /-A PREROUTING -p tcp -m comment --comment "598 - test"/ + end + context 'and current value is true' do + it_behaves_like "is idempotent", 'socket => true,', /-A PREROUTING -p tcp -m socket -m comment --comment "598 - test"/ + end + end + context 'when set to true' do + before :each do + iptables_flush_all_tables + shell('iptables -t raw -A PREROUTING -p tcp -m socket -m comment --comment "598 - test"') + end + context 'and current value is false' do + it_behaves_like "is idempotent", 'socket => false,', /-A PREROUTING -p tcp -m comment --comment "598 - test"/ + end + context 'and current value is true' do + it_behaves_like "doesn't change", 'socket => true,', /-A PREROUTING -p tcp -m socket -m comment --comment "598 - test"/ + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/standard_usage_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/standard_usage_spec.rb new file mode 100644 index 0000000000..f29278b97f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/acceptance/standard_usage_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper_acceptance' + +# Some tests for the standard recommended usage +describe 'standard usage tests:' do + it 'applies twice' do + pp = <<-EOS + class my_fw::pre { + Firewall { + require => undef, + } + + # Default firewall rules + firewall { '000 accept all icmp': + proto => 'icmp', + action => 'accept', + }-> + firewall { '001 accept all to lo interface': + proto => 'all', + iniface => 'lo', + action => 'accept', + }-> + firewall { '002 accept related established rules': + proto => 'all', + ctstate => ['RELATED', 'ESTABLISHED'], + action => 'accept', + } + } + class my_fw::post { + firewall { '999 drop all': + proto => 'all', + action => 'drop', + before => undef, + } + } + resources { "firewall": + purge => true + } + Firewall { + before => Class['my_fw::post'], + require => Class['my_fw::pre'], + } + class { ['my_fw::pre', 'my_fw::post']: } + class { 'firewall': } + firewall { '500 open up port 22': + action => 'accept', + proto => 'tcp', + dport => 22, + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/fixtures/ip6tables/conversion_hash.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/fixtures/ip6tables/conversion_hash.rb new file mode 100644 index 0000000000..7c507d78bd --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/fixtures/ip6tables/conversion_hash.rb @@ -0,0 +1,107 @@ +# These hashes allow us to iterate across a series of test data +# creating rspec examples for each parameter to ensure the input :line +# extrapolates to the desired value for the parameter in question. And +# vice-versa + +# This hash is for testing a line conversion to a hash of parameters +# which will be used to create a resource. +ARGS_TO_HASH6 = { + 'source_destination_ipv6_no_cidr' => { + :line => '-A INPUT -s 2001:db8:85a3::8a2e:370:7334 -d 2001:db8:85a3::8a2e:370:7334 -m comment --comment "000 source destination ipv6 no cidr"', + :table => 'filter', + :provider => 'ip6tables', + :params => { + :source => '2001:db8:85a3::8a2e:370:7334/128', + :destination => '2001:db8:85a3::8a2e:370:7334/128', + }, + }, + 'source_destination_ipv6_netmask' => { + :line => '-A INPUT -s 2001:db8:1234::/ffff:ffff:ffff:0000:0000:0000:0000:0000 -d 2001:db8:4321::/ffff:ffff:ffff:0000:0000:0000:0000:0000 -m comment --comment "000 source destination ipv6 netmask"', + :table => 'filter', + :provider => 'ip6tables', + :params => { + :source => '2001:db8:1234::/48', + :destination => '2001:db8:4321::/48', + }, + }, +} + +# This hash is for testing converting a hash to an argument line. +HASH_TO_ARGS6 = { + 'zero_prefixlen_ipv6' => { + :params => { + :name => '100 zero prefix length ipv6', + :table => 'filter', + :provider => 'ip6tables', + :source => '::/0', + :destination => '::/0', + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '100 zero prefix length ipv6'], + }, + 'source_destination_ipv4_no_cidr' => { + :params => { + :name => '000 source destination ipv4 no cidr', + :table => 'filter', + :provider => 'ip6tables', + :source => '1.1.1.1', + :destination => '2.2.2.2', + }, + :args => ['-t', :filter, '-s', '1.1.1.1/32', '-d', '2.2.2.2/32', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv4 no cidr'], + }, + 'source_destination_ipv6_no_cidr' => { + :params => { + :name => '000 source destination ipv6 no cidr', + :table => 'filter', + :provider => 'ip6tables', + :source => '2001:db8:1234::', + :destination => '2001:db8:4321::', + }, + :args => ['-t', :filter, '-s', '2001:db8:1234::/128', '-d', '2001:db8:4321::/128', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv6 no cidr'], + }, + 'source_destination_ipv6_netmask' => { + :params => { + :name => '000 source destination ipv6 netmask', + :table => 'filter', + :provider => 'ip6tables', + :source => '2001:db8:1234::/ffff:ffff:ffff:0000:0000:0000:0000:0000', + :destination => '2001:db8:4321::/ffff:ffff:ffff:0000:0000:0000:0000:0000', + }, + :args => ['-t', :filter, '-s', '2001:db8:1234::/48', '-d', '2001:db8:4321::/48', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv6 netmask'], + }, + 'frag_ishasmorefrags' => { + :params => { + :name => "100 has more fragments", + :ishasmorefrags => true, + :provider => 'ip6tables', + :table => "filter", + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "frag", "--fragid", "0", "--fragmore", "-m", "comment", "--comment", "100 has more fragments"], + }, + 'frag_islastfrag' => { + :params => { + :name => "100 last fragment", + :islastfrag => true, + :provider => 'ip6tables', + :table => "filter", + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "frag", "--fragid", "0", "--fraglast", "-m", "comment", "--comment", "100 last fragment"], + }, + 'frag_isfirstfrags' => { + :params => { + :name => "100 first fragment", + :isfirstfrag => true, + :provider => 'ip6tables', + :table => "filter", + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "frag", "--fragid", "0", "--fragfirst", "-m", "comment", "--comment", "100 first fragment"], + }, + 'hop_limit' => { + :params => { + :name => "100 hop limit", + :hop_limit => 255, + :provider => 'ip6tables', + :table => "filter", + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "comment", "--comment", "100 hop limit", "-m", "hl", "--hl-eq", 255], + }, +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/fixtures/iptables/conversion_hash.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/fixtures/iptables/conversion_hash.rb new file mode 100644 index 0000000000..105d27fb6b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/fixtures/iptables/conversion_hash.rb @@ -0,0 +1,934 @@ +# These hashes allow us to iterate across a series of test data +# creating rspec examples for each parameter to ensure the input :line +# extrapolates to the desired value for the parameter in question. And +# vice-versa + +# This hash is for testing a line conversion to a hash of parameters +# which will be used to create a resource. +ARGS_TO_HASH = { + 'dport_and_sport' => { + :line => '-A nova-compute-FORWARD -s 0.0.0.0/32 -d 255.255.255.255/32 -p udp -m udp --sport 68 --dport 67 -j ACCEPT', + :table => 'filter', + :params => { + :action => 'accept', + :chain => 'nova-compute-FORWARD', + :source => '0.0.0.0/32', + :destination => '255.255.255.255/32', + :sport => ['68'], + :dport => ['67'], + :proto => 'udp', + }, + }, + 'long_rule_1' => { + :line => '-A INPUT -s 1.1.1.1/32 -d 1.1.1.1/32 -p tcp -m multiport --dports 7061,7062 -m multiport --sports 7061,7062 -m comment --comment "000 allow foo" -j ACCEPT', + :table => 'filter', + :compare_all => true, + :params => { + :action => "accept", + :chain => "INPUT", + :destination => "1.1.1.1/32", + :dport => ["7061","7062"], + :ensure => :present, + :line => '-A INPUT -s 1.1.1.1/32 -d 1.1.1.1/32 -p tcp -m multiport --dports 7061,7062 -m multiport --sports 7061,7062 -m comment --comment "000 allow foo" -j ACCEPT', + :name => "000 allow foo", + :proto => "tcp", + :provider => "iptables", + :source => "1.1.1.1/32", + :sport => ["7061","7062"], + :table => "filter", + }, + }, + 'action_drop_1' => { + :line => '-A INPUT -m comment --comment "000 allow foo" -j DROP', + :table => 'filter', + :params => { + :jump => nil, + :action => "drop", + }, + }, + 'action_reject_1' => { + :line => '-A INPUT -m comment --comment "000 allow foo" -j REJECT', + :table => 'filter', + :params => { + :jump => nil, + :action => "reject", + }, + }, + 'action_nil_1' => { + :line => '-A INPUT -m comment --comment "000 allow foo"', + :table => 'filter', + :params => { + :jump => nil, + :action => nil, + }, + }, + 'jump_custom_chain_1' => { + :line => '-A INPUT -m comment --comment "000 allow foo" -j custom_chain', + :table => 'filter', + :params => { + :jump => "custom_chain", + :action => nil, + }, + }, + 'source_destination_ipv4_no_cidr' => { + :line => '-A INPUT -s 1.1.1.1 -d 2.2.2.2 -m comment --comment "000 source destination ipv4 no cidr"', + :table => 'filter', + :params => { + :source => '1.1.1.1/32', + :destination => '2.2.2.2/32', + }, + }, + 'source_destination_ipv6_no_cidr' => { + :line => '-A INPUT -s 2001:db8:85a3::8a2e:370:7334 -d 2001:db8:85a3::8a2e:370:7334 -m comment --comment "000 source destination ipv6 no cidr"', + :table => 'filter', + :params => { + :source => '2001:db8:85a3::8a2e:370:7334/128', + :destination => '2001:db8:85a3::8a2e:370:7334/128', + }, + }, + 'source_destination_ipv4_netmask' => { + :line => '-A INPUT -s 1.1.1.0/255.255.255.0 -d 2.2.0.0/255.255.0.0 -m comment --comment "000 source destination ipv4 netmask"', + :table => 'filter', + :params => { + :source => '1.1.1.0/24', + :destination => '2.2.0.0/16', + }, + }, + 'source_destination_ipv6_netmask' => { + :line => '-A INPUT -s 2001:db8:1234::/ffff:ffff:ffff:0000:0000:0000:0000:0000 -d 2001:db8:4321::/ffff:ffff:ffff:0000:0000:0000:0000:0000 -m comment --comment "000 source destination ipv6 netmask"', + :table => 'filter', + :params => { + :source => '2001:db8:1234::/48', + :destination => '2001:db8:4321::/48', + }, + }, + 'source_destination_negate_source' => { + :line => '-A INPUT ! -s 1.1.1.1 -d 2.2.2.2 -m comment --comment "000 negated source address"', + :table => 'filter', + :params => { + :source => '! 1.1.1.1/32', + :destination => '2.2.2.2/32', + }, + }, + 'source_destination_negate_destination' => { + :line => '-A INPUT -s 1.1.1.1 ! -d 2.2.2.2 -m comment --comment "000 negated destination address"', + :table => 'filter', + :params => { + :source => '1.1.1.1/32', + :destination => '! 2.2.2.2/32', + }, + }, + 'source_destination_negate_destination_alternative' => { + :line => '-A INPUT -s 1.1.1.1 -d ! 2.2.2.2 -m comment --comment "000 negated destination address alternative"', + :table => 'filter', + :params => { + :source => '1.1.1.1/32', + :destination => '! 2.2.2.2/32', + }, + }, + 'dport_range_1' => { + :line => '-A INPUT -m multiport --dports 1:1024 -m comment --comment "000 allow foo"', + :table => 'filter', + :params => { + :dport => ["1-1024"], + }, + }, + 'dport_range_2' => { + :line => '-A INPUT -m multiport --dports 15,512:1024 -m comment --comment "000 allow foo"', + :table => 'filter', + :params => { + :dport => ["15","512-1024"], + }, + }, + 'sport_range_1' => { + :line => '-A INPUT -m multiport --sports 1:1024 -m comment --comment "000 allow foo"', + :table => 'filter', + :params => { + :sport => ["1-1024"], + }, + }, + 'sport_range_2' => { + :line => '-A INPUT -m multiport --sports 15,512:1024 -m comment --comment "000 allow foo"', + :table => 'filter', + :params => { + :sport => ["15","512-1024"], + }, + }, + 'dst_type_1' => { + :line => '-A INPUT -m addrtype --dst-type LOCAL', + :table => 'filter', + :params => { + :dst_type => 'LOCAL', + }, + }, + 'src_type_1' => { + :line => '-A INPUT -m addrtype --src-type LOCAL', + :table => 'filter', + :params => { + :src_type => 'LOCAL', + }, + }, + 'dst_range_1' => { + :line => '-A INPUT -m iprange --dst-range 10.0.0.2-10.0.0.20', + :table => 'filter', + :params => { + :dst_range => '10.0.0.2-10.0.0.20', + }, + }, + 'src_range_1' => { + :line => '-A INPUT -m iprange --src-range 10.0.0.2-10.0.0.20', + :table => 'filter', + :params => { + :src_range => '10.0.0.2-10.0.0.20', + }, + }, + 'tcp_flags_1' => { + :line => '-A INPUT -p tcp -m tcp --tcp-flags SYN,RST,ACK,FIN SYN -m comment --comment "000 initiation"', + :table => 'filter', + :compare_all => true, + :chain => 'INPUT', + :proto => 'tcp', + :params => { + :chain => "INPUT", + :ensure => :present, + :line => '-A INPUT -p tcp -m tcp --tcp-flags SYN,RST,ACK,FIN SYN -m comment --comment "000 initiation"', + :name => "000 initiation", + :proto => "tcp", + :provider => "iptables", + :table => "filter", + :tcp_flags => "SYN,RST,ACK,FIN SYN", + }, + }, + 'state_returns_sorted_values' => { + :line => '-A INPUT -m state --state INVALID,RELATED,ESTABLISHED', + :table => 'filter', + :params => { + :state => ['ESTABLISHED', 'INVALID', 'RELATED'], + :action => nil, + }, + }, + 'ctstate_returns_sorted_values' => { + :line => '-A INPUT -m conntrack --ctstate INVALID,RELATED,ESTABLISHED', + :table => 'filter', + :params => { + :ctstate => ['ESTABLISHED', 'INVALID', 'RELATED'], + :action => nil, + }, + }, + 'comment_string_character_validation' => { + :line => '-A INPUT -s 192.168.0.1/32 -m comment --comment "000 allow from 192.168.0.1, please"', + :table => 'filter', + :params => { + :source => '192.168.0.1/32', + }, + }, + 'log_level_debug' => { + :line => '-A INPUT -m comment --comment "956 INPUT log-level" -m state --state NEW -j LOG --log-level 7', + :table => 'filter', + :params => { + :state => ['NEW'], + :log_level => '7', + :jump => 'LOG' + }, + }, + 'log_level_warn' => { + :line => '-A INPUT -m comment --comment "956 INPUT log-level" -m state --state NEW -j LOG', + :table => 'filter', + :params => { + :state => ['NEW'], + :log_level => '4', + :jump => 'LOG' + }, + }, + 'load_limit_module_and_implicit_burst' => { + :line => '-A INPUT -m multiport --dports 123 -m comment --comment "057 INPUT limit NTP" -m limit --limit 15/hour', + :table => 'filter', + :params => { + :dport => ['123'], + :limit => '15/hour', + :burst => '5' + }, + }, + 'limit_with_explicit_burst' => { + :line => '-A INPUT -m multiport --dports 123 -m comment --comment "057 INPUT limit NTP" -m limit --limit 30/hour --limit-burst 10', + :table => 'filter', + :params => { + :dport => ['123'], + :limit => '30/hour', + :burst => '10' + }, + }, + 'proto_ipencap' => { + :line => '-A INPUT -p ipencap -m comment --comment "0100 INPUT accept ipencap"', + :table => 'filter', + :params => { + :proto => 'ipencap', + } + }, + 'load_uid_owner_filter_module' => { + :line => '-A OUTPUT -m owner --uid-owner root -m comment --comment "057 OUTPUT uid root only" -j ACCEPT', + :table => 'filter', + :params => { + :action => 'accept', + :uid => 'root', + :chain => 'OUTPUT', + }, + }, + 'load_uid_owner_postrouting_module' => { + :line => '-t mangle -A POSTROUTING -m owner --uid-owner root -m comment --comment "057 POSTROUTING uid root only" -j ACCEPT', + :table => 'mangle', + :params => { + :action => 'accept', + :chain => 'POSTROUTING', + :uid => 'root', + }, + }, + 'load_gid_owner_filter_module' => { + :line => '-A OUTPUT -m owner --gid-owner root -m comment --comment "057 OUTPUT gid root only" -j ACCEPT', + :table => 'filter', + :params => { + :action => 'accept', + :chain => 'OUTPUT', + :gid => 'root', + }, + }, + 'load_gid_owner_postrouting_module' => { + :line => '-t mangle -A POSTROUTING -m owner --gid-owner root -m comment --comment "057 POSTROUTING gid root only" -j ACCEPT', + :table => 'mangle', + :params => { + :action => 'accept', + :chain => 'POSTROUTING', + :gid => 'root', + }, + }, + 'mark_set-mark' => { + :line => '-t mangle -A PREROUTING -j MARK --set-xmark 0x3e8/0xffffffff', + :table => 'mangle', + :params => { + :jump => 'MARK', + :chain => 'PREROUTING', + :set_mark => '0x3e8/0xffffffff', + } + }, + 'iniface_1' => { + :line => '-A INPUT -i eth0 -m comment --comment "060 iniface" -j DROP', + :table => 'filter', + :params => { + :action => 'drop', + :chain => 'INPUT', + :iniface => 'eth0', + }, + }, + 'iniface_with_vlans_1' => { + :line => '-A INPUT -i eth0.234 -m comment --comment "060 iniface" -j DROP', + :table => 'filter', + :params => { + :action => 'drop', + :chain => 'INPUT', + :iniface => 'eth0.234', + }, + }, + 'iniface_with_plus_1' => { + :line => '-A INPUT -i eth+ -m comment --comment "060 iniface" -j DROP', + :table => 'filter', + :params => { + :action => 'drop', + :chain => 'INPUT', + :iniface => 'eth+', + }, + }, + 'outiface_1' => { + :line => '-A OUTPUT -o eth0 -m comment --comment "060 outiface" -j DROP', + :table => 'filter', + :params => { + :action => 'drop', + :chain => 'OUTPUT', + :outiface => 'eth0', + }, + }, + 'outiface_with_vlans_1' => { + :line => '-A OUTPUT -o eth0.234 -m comment --comment "060 outiface" -j DROP', + :table => 'filter', + :params => { + :action => 'drop', + :chain => 'OUTPUT', + :outiface => 'eth0.234', + }, + }, + 'outiface_with_plus_1' => { + :line => '-A OUTPUT -o eth+ -m comment --comment "060 outiface" -j DROP', + :table => 'filter', + :params => { + :action => 'drop', + :chain => 'OUTPUT', + :outiface => 'eth+', + }, + }, + 'pkttype multicast' => { + :line => '-A INPUT -m pkttype --pkt-type multicast -j ACCEPT', + :table => 'filter', + :params => { + :action => 'accept', + :pkttype => 'multicast', + }, + }, + 'socket_option' => { + :line => '-A PREROUTING -m socket -j ACCEPT', + :table => 'mangle', + :params => { + :action => 'accept', + :chain => 'PREROUTING', + :socket => true, + }, + }, + 'isfragment_option' => { + :line => '-A INPUT -f -m comment --comment "010 a-f comment with dashf" -j ACCEPT', + :table => 'filter', + :params => { + :name => '010 a-f comment with dashf', + :action => 'accept', + :isfragment => true, + }, + }, + 'single_tcp_sport' => { + :line => '-A OUTPUT -s 10.94.100.46/32 -p tcp -m tcp --sport 20443 -j ACCEPT', + :table => 'mangle', + :params => { + :action => 'accept', + :chain => 'OUTPUT', + :source => "10.94.100.46/32", + :proto => "tcp", + :sport => ["20443"], + }, + }, + 'single_udp_sport' => { + :line => '-A OUTPUT -s 10.94.100.46/32 -p udp -m udp --sport 20443 -j ACCEPT', + :table => 'mangle', + :params => { + :action => 'accept', + :chain => 'OUTPUT', + :source => "10.94.100.46/32", + :proto => "udp", + :sport => ["20443"], + }, + }, + 'single_tcp_dport' => { + :line => '-A OUTPUT -s 10.94.100.46/32 -p tcp -m tcp --dport 20443 -j ACCEPT', + :table => 'mangle', + :params => { + :action => 'accept', + :chain => 'OUTPUT', + :source => "10.94.100.46/32", + :proto => "tcp", + :dport => ["20443"], + }, + }, + 'single_udp_dport' => { + :line => '-A OUTPUT -s 10.94.100.46/32 -p udp -m udp --dport 20443 -j ACCEPT', + :table => 'mangle', + :params => { + :action => 'accept', + :chain => 'OUTPUT', + :source => "10.94.100.46/32", + :proto => "udp", + :dport => ["20443"], + }, + }, + 'connlimit_above' => { + :line => '-A INPUT -p tcp -m multiport --dports 22 -m comment --comment "061 REJECT connlimit_above 10" -m connlimit --connlimit-above 10 --connlimit-mask 32 -j REJECT --reject-with icmp-port-unreachable', + :table => 'filter', + :params => { + :proto => 'tcp', + :dport => ["22"], + :connlimit_above => '10', + :action => 'reject', + }, + }, + 'connlimit_above_with_connlimit_mask' => { + :line => '-A INPUT -p tcp -m multiport --dports 22 -m comment --comment "061 REJECT connlimit_above 10 with mask 24" -m connlimit --connlimit-above 10 --connlimit-mask 24 -j REJECT --reject-with icmp-port-unreachable', + :table => 'filter', + :params => { + :proto => 'tcp', + :dport => ["22"], + :connlimit_above => '10', + :connlimit_mask => '24', + :action => 'reject', + }, + }, + 'connmark' => { + :line => '-A INPUT -m comment --comment "062 REJECT connmark" -m connmark --mark 0x1 -j REJECT --reject-with icmp-port-unreachable', + :table => 'filter', + :params => { + :proto => 'all', + :connmark => '0x1', + :action => 'reject', + }, + }, +} + +# This hash is for testing converting a hash to an argument line. +HASH_TO_ARGS = { + 'long_rule_1' => { + :params => { + :action => "accept", + :chain => "INPUT", + :destination => "1.1.1.1", + :dport => ["7061","7062"], + :ensure => :present, + :name => "000 allow foo", + :proto => "tcp", + :source => "1.1.1.1", + :sport => ["7061","7062"], + :table => "filter", + }, + :args => ["-t", :filter, "-s", "1.1.1.1/32", "-d", "1.1.1.1/32", "-p", :tcp, "-m", "multiport", "--sports", "7061,7062", "-m", "multiport", "--dports", "7061,7062", "-m", "comment", "--comment", "000 allow foo", "-j", "ACCEPT"], + }, + 'long_rule_2' => { + :params => { + :chain => "INPUT", + :destination => "2.10.13.3/24", + :dport => ["7061"], + :ensure => :present, + :jump => "my_custom_chain", + :name => "700 allow bar", + :proto => "udp", + :source => "1.1.1.1", + :sport => ["7061","7062"], + :table => "filter", + }, + :args => ["-t", :filter, "-s", "1.1.1.1/32", "-d", "2.10.13.0/24", "-p", :udp, "-m", "multiport", "--sports", "7061,7062", "-m", "multiport", "--dports", "7061", "-m", "comment", "--comment", "700 allow bar", "-j", "my_custom_chain"], + }, + 'no_action' => { + :params => { + :name => "100 no action", + :table => "filter", + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "comment", "--comment", + "100 no action"], + }, + 'zero_prefixlen_ipv4' => { + :params => { + :name => '100 zero prefix length ipv4', + :table => 'filter', + :source => '0.0.0.0/0', + :destination => '0.0.0.0/0', + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '100 zero prefix length ipv4'], + }, + 'zero_prefixlen_ipv6' => { + :params => { + :name => '100 zero prefix length ipv6', + :table => 'filter', + :source => '::/0', + :destination => '::/0', + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '100 zero prefix length ipv6'], + }, + 'source_destination_ipv4_no_cidr' => { + :params => { + :name => '000 source destination ipv4 no cidr', + :table => 'filter', + :source => '1.1.1.1', + :destination => '2.2.2.2', + }, + :args => ['-t', :filter, '-s', '1.1.1.1/32', '-d', '2.2.2.2/32', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv4 no cidr'], + }, + 'source_destination_ipv6_no_cidr' => { + :params => { + :name => '000 source destination ipv6 no cidr', + :table => 'filter', + :source => '2001:db8:1234::', + :destination => '2001:db8:4321::', + }, + :args => ['-t', :filter, '-s', '2001:db8:1234::/128', '-d', '2001:db8:4321::/128', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv6 no cidr'], + }, + 'source_destination_ipv4_netmask' => { + :params => { + :name => '000 source destination ipv4 netmask', + :table => 'filter', + :source => '1.1.1.0/255.255.255.0', + :destination => '2.2.0.0/255.255.0.0', + }, + :args => ['-t', :filter, '-s', '1.1.1.0/24', '-d', '2.2.0.0/16', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv4 netmask'], + }, + 'source_destination_ipv6_netmask' => { + :params => { + :name => '000 source destination ipv6 netmask', + :table => 'filter', + :source => '2001:db8:1234::/ffff:ffff:ffff:0000:0000:0000:0000:0000', + :destination => '2001:db8:4321::/ffff:ffff:ffff:0000:0000:0000:0000:0000', + }, + :args => ['-t', :filter, '-s', '2001:db8:1234::/48', '-d', '2001:db8:4321::/48', '-p', :tcp, '-m', 'comment', '--comment', '000 source destination ipv6 netmask'], + }, + 'sport_range_1' => { + :params => { + :name => "100 sport range", + :sport => ["1-1024"], + :table => "filter", + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--sports", "1:1024", "-m", "comment", "--comment", "100 sport range"], + }, + 'sport_range_2' => { + :params => { + :name => "100 sport range", + :sport => ["15","512-1024"], + :table => "filter", + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--sports", "15,512:1024", "-m", "comment", "--comment", "100 sport range"], + }, + 'dport_range_1' => { + :params => { + :name => "100 sport range", + :dport => ["1-1024"], + :table => "filter", + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--dports", "1:1024", "-m", "comment", "--comment", "100 sport range"], + }, + 'dport_range_2' => { + :params => { + :name => "100 sport range", + :dport => ["15","512-1024"], + :table => "filter", + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--dports", "15,512:1024", "-m", "comment", "--comment", "100 sport range"], + }, + 'dst_type_1' => { + :params => { + :name => '000 dst_type', + :table => 'filter', + :dst_type => 'LOCAL', + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'addrtype', '--dst-type', :LOCAL, '-m', 'comment', '--comment', '000 dst_type'], + }, + 'src_type_1' => { + :params => { + :name => '000 src_type', + :table => 'filter', + :src_type => 'LOCAL', + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'addrtype', '--src-type', :LOCAL, '-m', 'comment', '--comment', '000 src_type'], + }, + 'dst_range_1' => { + :params => { + :name => '000 dst_range', + :table => 'filter', + :dst_range => '10.0.0.1-10.0.0.10', + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'iprange', '--dst-range', '10.0.0.1-10.0.0.10', '-m', 'comment', '--comment', '000 dst_range'], + }, + 'src_range_1' => { + :params => { + :name => '000 src_range', + :table => 'filter', + :dst_range => '10.0.0.1-10.0.0.10', + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'iprange', '--dst-range', '10.0.0.1-10.0.0.10', '-m', 'comment', '--comment', '000 src_range'], + }, + 'tcp_flags_1' => { + :params => { + :name => "000 initiation", + :tcp_flags => "SYN,RST,ACK,FIN SYN", + :table => "filter", + }, + + :args => ["-t", :filter, "-p", :tcp, "-m", "tcp", "--tcp-flags", "SYN,RST,ACK,FIN", "SYN", "-m", "comment", "--comment", "000 initiation",] + }, + 'states_set_from_array' => { + :params => { + :name => "100 states_set_from_array", + :table => "filter", + :state => ['ESTABLISHED', 'INVALID'] + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "comment", "--comment", "100 states_set_from_array", + "-m", "state", "--state", "ESTABLISHED,INVALID"], + }, + 'ctstates_set_from_array' => { + :params => { + :name => "100 ctstates_set_from_array", + :table => "filter", + :ctstate => ['ESTABLISHED', 'INVALID'] + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "comment", "--comment", "100 ctstates_set_from_array", + "-m", "conntrack", "--ctstate", "ESTABLISHED,INVALID"], + }, + 'comment_string_character_validation' => { + :params => { + :name => "000 allow from 192.168.0.1, please", + :table => 'filter', + :source => '192.168.0.1' + }, + :args => ['-t', :filter, '-s', '192.168.0.1/32', '-p', :tcp, '-m', 'comment', '--comment', '000 allow from 192.168.0.1, please'], + }, + 'port_property' => { + :params => { + :name => '001 port property', + :table => 'filter', + :port => '80', + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'multiport', '--ports', '80', '-m', 'comment', '--comment', '001 port property'], + }, + 'log_level_debug' => { + :params => { + :name => '956 INPUT log-level', + :table => 'filter', + :state => 'NEW', + :jump => 'LOG', + :log_level => 'debug' + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '956 INPUT log-level', '-m', 'state', '--state', 'NEW', '-j', 'LOG', '--log-level', '7'], + }, + 'log_level_warn' => { + :params => { + :name => '956 INPUT log-level', + :table => 'filter', + :state => 'NEW', + :jump => 'LOG', + :log_level => 'warn' + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'comment', '--comment', '956 INPUT log-level', '-m', 'state', '--state', 'NEW', '-j', 'LOG', '--log-level', '4'], + }, + 'load_limit_module_and_implicit_burst' => { + :params => { + :name => '057 INPUT limit NTP', + :table => 'filter', + :dport => '123', + :limit => '15/hour' + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'multiport', '--dports', '123', '-m', 'comment', '--comment', '057 INPUT limit NTP', '-m', 'limit', '--limit', '15/hour'], + }, + 'limit_with_explicit_burst' => { + :params => { + :name => '057 INPUT limit NTP', + :table => 'filter', + :dport => '123', + :limit => '30/hour', + :burst => '10' + }, + :args => ['-t', :filter, '-p', :tcp, '-m', 'multiport', '--dports', '123', '-m', 'comment', '--comment', '057 INPUT limit NTP', '-m', 'limit', '--limit', '30/hour', '--limit-burst', '10'], + }, + 'proto_ipencap' => { + :params => { + :name => '0100 INPUT accept ipencap', + :table => 'filter', + :proto => 'ipencap', + }, + :args => ['-t', :filter, '-p', :ipencap, '-m', 'comment', '--comment', '0100 INPUT accept ipencap'], + }, + 'load_uid_owner_filter_module' => { + :params => { + :name => '057 OUTPUT uid root only', + :table => 'filter', + :uid => 'root', + :action => 'accept', + :chain => 'OUTPUT', + :proto => 'all', + }, + :args => ['-t', :filter, '-p', :all, '-m', 'owner', '--uid-owner', 'root', '-m', 'comment', '--comment', '057 OUTPUT uid root only', '-j', 'ACCEPT'], + }, + 'load_uid_owner_postrouting_module' => { + :params => { + :name => '057 POSTROUTING uid root only', + :table => 'mangle', + :uid => 'root', + :action => 'accept', + :chain => 'POSTROUTING', + :proto => 'all', + }, + :args => ['-t', :mangle, '-p', :all, '-m', 'owner', '--uid-owner', 'root', '-m', 'comment', '--comment', '057 POSTROUTING uid root only', '-j', 'ACCEPT'], + }, + 'load_gid_owner_filter_module' => { + :params => { + :name => '057 OUTPUT gid root only', + :table => 'filter', + :chain => 'OUTPUT', + :gid => 'root', + :action => 'accept', + :proto => 'all', + }, + :args => ['-t', :filter, '-p', :all, '-m', 'owner', '--gid-owner', 'root', '-m', 'comment', '--comment', '057 OUTPUT gid root only', '-j', 'ACCEPT'], + }, + 'load_gid_owner_postrouting_module' => { + :params => { + :name => '057 POSTROUTING gid root only', + :table => 'mangle', + :gid => 'root', + :action => 'accept', + :chain => 'POSTROUTING', + :proto => 'all', + }, + :args => ['-t', :mangle, '-p', :all, '-m', 'owner', '--gid-owner', 'root', '-m', 'comment', '--comment', '057 POSTROUTING gid root only', '-j', 'ACCEPT'], + }, + 'mark_set-mark_int' => { + :params => { + :name => '058 set-mark 1000', + :table => 'mangle', + :jump => 'MARK', + :chain => 'PREROUTING', + :set_mark => '1000', + }, + :args => ['-t', :mangle, '-p', :tcp, '-m', 'comment', '--comment', '058 set-mark 1000', '-j', 'MARK', '--set-xmark', '0x3e8/0xffffffff'], + }, + 'mark_set-mark_hex' => { + :params => { + :name => '058 set-mark 0x32', + :table => 'mangle', + :jump => 'MARK', + :chain => 'PREROUTING', + :set_mark => '0x32', + }, + :args => ['-t', :mangle, '-p', :tcp, '-m', 'comment', '--comment', '058 set-mark 0x32', '-j', 'MARK', '--set-xmark', '0x32/0xffffffff'], + }, + 'mark_set-mark_hex_with_hex_mask' => { + :params => { + :name => '058 set-mark 0x32/0xffffffff', + :table => 'mangle', + :jump => 'MARK', + :chain => 'PREROUTING', + :set_mark => '0x32/0xffffffff', + }, + :args => ['-t', :mangle, '-p', :tcp, '-m', 'comment', '--comment', '058 set-mark 0x32/0xffffffff', '-j', 'MARK', '--set-xmark', '0x32/0xffffffff'], + }, + 'mark_set-mark_hex_with_mask' => { + :params => { + :name => '058 set-mark 0x32/4', + :table => 'mangle', + :jump => 'MARK', + :chain => 'PREROUTING', + :set_mark => '0x32/4', + }, + :args => ['-t', :mangle, '-p', :tcp, '-m', 'comment', '--comment', '058 set-mark 0x32/4', '-j', 'MARK', '--set-xmark', '0x32/0x4'], + }, + 'iniface_1' => { + :params => { + :name => '060 iniface', + :table => 'filter', + :action => 'drop', + :chain => 'INPUT', + :iniface => 'eth0', + }, + :args => ["-t", :filter, "-i", "eth0", "-p", :tcp, "-m", "comment", "--comment", "060 iniface", "-j", "DROP"], + }, + 'iniface_with_vlans_1' => { + :params => { + :name => '060 iniface', + :table => 'filter', + :action => 'drop', + :chain => 'INPUT', + :iniface => 'eth0.234', + }, + :args => ["-t", :filter, "-i", "eth0.234", "-p", :tcp, "-m", "comment", "--comment", "060 iniface", "-j", "DROP"], + }, + 'iniface_with_plus_1' => { + :params => { + :name => '060 iniface', + :table => 'filter', + :action => 'drop', + :chain => 'INPUT', + :iniface => 'eth+', + }, + :args => ["-t", :filter, "-i", "eth+", "-p", :tcp, "-m", "comment", "--comment", "060 iniface", "-j", "DROP"], + }, + 'outiface_1' => { + :params => { + :name => '060 outiface', + :table => 'filter', + :action => 'drop', + :chain => 'OUTPUT', + :outiface => 'eth0', + }, + :args => ["-t", :filter, "-o", "eth0", "-p", :tcp, "-m", "comment", "--comment", "060 outiface", "-j", "DROP"], + }, + 'outiface_with_vlans_1' => { + :params => { + :name => '060 outiface', + :table => 'filter', + :action => 'drop', + :chain => 'OUTPUT', + :outiface => 'eth0.234', + }, + :args => ["-t", :filter, "-o", "eth0.234", "-p", :tcp, "-m", "comment", "--comment", "060 outiface", "-j", "DROP"], + }, + 'outiface_with_plus_1' => { + :params => { + :name => '060 outiface', + :table => 'filter', + :action => 'drop', + :chain => 'OUTPUT', + :outiface => 'eth+', + }, + :args => ["-t", :filter, "-o", "eth+", "-p", :tcp, "-m", "comment", "--comment", "060 outiface", "-j", "DROP"], + }, + 'pkttype multicast' => { + :params => { + :name => '062 pkttype multicast', + :table => "filter", + :action => 'accept', + :chain => 'INPUT', + :iniface => 'eth0', + :pkttype => 'multicast', + }, + :args => ["-t", :filter, "-i", "eth0", "-p", :tcp, "-m", "pkttype", "--pkt-type", :multicast, "-m", "comment", "--comment", "062 pkttype multicast", "-j", "ACCEPT"], + }, + 'socket_option' => { + :params => { + :name => '050 socket option', + :table => 'mangle', + :action => 'accept', + :chain => 'PREROUTING', + :socket => true, + }, + :args => ['-t', :mangle, '-p', :tcp, '-m', 'socket', '-m', 'comment', '--comment', '050 socket option', '-j', 'ACCEPT'], + }, + 'isfragment_option' => { + :params => { + :name => '050 isfragment option', + :table => 'filter', + :proto => :all, + :action => 'accept', + :isfragment => true, + }, + :args => ['-t', :filter, '-p', :all, '-f', '-m', 'comment', '--comment', '050 isfragment option', '-j', 'ACCEPT'], + }, + 'isfragment_option not changing -f in comment' => { + :params => { + :name => '050 testcomment-with-fdashf', + :table => 'filter', + :proto => :all, + :action => 'accept', + }, + :args => ['-t', :filter, '-p', :all, '-m', 'comment', '--comment', '050 testcomment-with-fdashf', '-j', 'ACCEPT'], + }, + 'connlimit_above' => { + :params => { + :name => '061 REJECT connlimit_above 10', + :table => 'filter', + :proto => 'tcp', + :dport => ["22"], + :connlimit_above => '10', + :action => 'reject', + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--dports", "22", "-m", "comment", "--comment", "061 REJECT connlimit_above 10", "-j", "REJECT", "-m", "connlimit", "--connlimit-above", "10"], + }, + 'connlimit_above_with_connlimit_mask' => { + :params => { + :name => '061 REJECT connlimit_above 10 with mask 24', + :table => 'filter', + :proto => 'tcp', + :dport => ["22"], + :connlimit_above => '10', + :connlimit_mask => '24', + :action => 'reject', + }, + :args => ["-t", :filter, "-p", :tcp, "-m", "multiport", "--dports", "22", "-m", "comment", "--comment", "061 REJECT connlimit_above 10 with mask 24", "-j", "REJECT", "-m", "connlimit", "--connlimit-above", "10", "--connlimit-mask", "24"], + }, + 'connmark' => { + :params => { + :name => '062 REJECT connmark', + :table => 'filter', + :proto => 'all', + :connmark => '0x1', + :action => 'reject', + }, + :args => ["-t", :filter, "-p", :all, "-m", "comment", "--comment", "062 REJECT connmark", "-j", "REJECT", "-m", "connmark", "--mark", "0x1"], + }, +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/spec_helper.rb new file mode 100644 index 0000000000..dc8bc39cb4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/spec_helper.rb @@ -0,0 +1,29 @@ +dir = File.expand_path(File.dirname(__FILE__)) +$LOAD_PATH.unshift File.join(dir, 'lib') + +# Don't want puppet getting the command line arguments for rake or autotest +ARGV.clear + +require 'rubygems' +require 'bundler/setup' +require 'rspec-puppet' + +Bundler.require :default, :test + +require 'pathname' +require 'tmpdir' + +Pathname.glob("#{dir}/shared_behaviours/**/*.rb") do |behaviour| + require behaviour.relative_path_from(Pathname.new(dir)) +end + +fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) + +RSpec.configure do |config| + config.tty = true + config.mock_with :rspec do |c| + c.syntax = :expect + end + config.module_path = File.join(fixture_path, 'modules') + config.manifest_dir = File.join(fixture_path, 'manifests') +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/spec_helper_acceptance.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000000..13d056fa93 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/spec_helper_acceptance.rb @@ -0,0 +1,42 @@ +require 'beaker-rspec' + +def iptables_flush_all_tables + ['filter', 'nat', 'mangle', 'raw'].each do |t| + expect(shell("iptables -t #{t} -F").stderr).to eq("") + end +end + +def ip6tables_flush_all_tables + ['filter'].each do |t| + expect(shell("ip6tables -t #{t} -F").stderr).to eq("") + end +end + +unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' + if hosts.first.is_pe? + install_pe + else + install_puppet + end + hosts.each do |host| + on host, "mkdir -p #{host['distmoduledir']}" + end +end + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + puppet_module_install(:source => proj_root, :module_name => 'firewall') + hosts.each do |host| + shell('/bin/touch /etc/puppet/hiera.yaml') + shell('puppet module install puppetlabs-stdlib --version 3.2.0', { :acceptable_exit_codes => [0,1] }) + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_archlinux_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_archlinux_spec.rb new file mode 100644 index 0000000000..954d9ee10d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_archlinux_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe 'firewall::linux::archlinux', :type => :class do + it { should contain_service('iptables').with( + :ensure => 'running', + :enable => 'true' + )} + it { should contain_service('ip6tables').with( + :ensure => 'running', + :enable => 'true' + )} + + context 'ensure => stopped' do + let(:params) {{ :ensure => 'stopped' }} + it { should contain_service('iptables').with( + :ensure => 'stopped' + )} + it { should contain_service('ip6tables').with( + :ensure => 'stopped' + )} + end + + context 'enable => false' do + let(:params) {{ :enable => 'false' }} + it { should contain_service('iptables').with( + :enable => 'false' + )} + it { should contain_service('ip6tables').with( + :enable => 'false' + )} + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_debian_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_debian_spec.rb new file mode 100644 index 0000000000..98285b642c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_debian_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe 'firewall::linux::debian', :type => :class do + it { should contain_package('iptables-persistent').with( + :ensure => 'present' + )} + it { should contain_service('iptables-persistent').with( + :ensure => nil, + :enable => 'true', + :require => 'Package[iptables-persistent]' + )} + + context 'enable => false' do + let(:params) {{ :enable => 'false' }} + it { should contain_service('iptables-persistent').with( + :enable => 'false' + )} + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_redhat_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_redhat_spec.rb new file mode 100644 index 0000000000..ea49d2b83b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_redhat_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe 'firewall::linux::redhat', :type => :class do + it { should contain_service('iptables').with( + :ensure => 'running', + :enable => 'true' + )} + + context 'ensure => stopped' do + let(:params) {{ :ensure => 'stopped' }} + it { should contain_service('iptables').with( + :ensure => 'stopped' + )} + end + + context 'enable => false' do + let(:params) {{ :enable => 'false' }} + it { should contain_service('iptables').with( + :enable => 'false' + )} + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_spec.rb new file mode 100644 index 0000000000..42056c1b1a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_linux_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe 'firewall::linux', :type => :class do + let(:facts_default) {{ :kernel => 'Linux' }} + it { should contain_package('iptables').with_ensure('present') } + + context 'RedHat like' do + %w{RedHat CentOS Fedora}.each do |os| + context "operatingsystem => #{os}" do + releases = (os == 'Fedora' ? [14,15,'Rawhide'] : [6,7]) + releases.each do |osrel| + context "operatingsystemrelease => #{osrel}" do + let(:facts) { facts_default.merge({ :operatingsystem => os, + :operatingsystemrelease => osrel}) } + it { should contain_class('firewall::linux::redhat').with_require('Package[iptables]') } + end + end + end + end + end + + context 'Debian like' do + %w{Debian Ubuntu}.each do |os| + context "operatingsystem => #{os}" do + let(:facts) { facts_default.merge({ :operatingsystem => os }) } + it { should contain_class('firewall::linux::debian').with_require('Package[iptables]') } + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_spec.rb new file mode 100644 index 0000000000..efc153ab2e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/classes/firewall_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe 'firewall', :type => :class do + context 'kernel => Linux' do + let(:facts) {{ :kernel => 'Linux' }} + it { should contain_class('firewall::linux').with_ensure('running') } + end + + context 'kernel => Windows' do + let(:facts) {{ :kernel => 'Windows' }} + it { expect { should contain_class('firewall::linux') }.to raise_error(Puppet::Error) } + end + + context 'ensure => stopped' do + let(:facts) {{ :kernel => 'Linux' }} + let(:params) {{ :ensure => 'stopped' }} + it { should contain_class('firewall::linux').with_ensure('stopped') } + end + + context 'ensure => test' do + let(:facts) {{ :kernel => 'Linux' }} + let(:params) {{ :ensure => 'test' }} + it { expect { should contain_class('firewall::linux') }.to raise_error(Puppet::Error) } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb new file mode 100644 index 0000000000..13a23a5c29 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/facter/iptables_persistent_version_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe "Facter::Util::Fact iptables_persistent_version" do + before { Facter.clear } + let(:dpkg_cmd) { "dpkg-query -Wf '${Version}' iptables-persistent 2>/dev/null" } + + { + "Debian" => "0.0.20090701", + "Ubuntu" => "0.5.3ubuntu2", + }.each do |os, ver| + describe "#{os} package installed" do + before { + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return(os) + allow(Facter::Util::Resolution).to receive(:exec).with(dpkg_cmd). + and_return(ver) + } + it { Facter.fact(:iptables_persistent_version).value.should == ver } + end + end + + describe 'Ubuntu package not installed' do + before { + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('Ubuntu') + allow(Facter::Util::Resolution).to receive(:exec).with(dpkg_cmd). + and_return(nil) + } + it { Facter.fact(:iptables_persistent_version).value.should be_nil } + end + + describe 'CentOS not supported' do + before { allow(Facter.fact(:operatingsystem)).to receive(:value). + and_return("CentOS") } + it { Facter.fact(:iptables_persistent_version).value.should be_nil } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/facter/iptables_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/facter/iptables_spec.rb new file mode 100644 index 0000000000..5773fdce56 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/facter/iptables_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe "Facter::Util::Fact" do + before { + Facter.clear + allow(Facter.fact(:kernel)).to receive(:value).and_return('Linux') + allow(Facter.fact(:kernelrelease)).to receive(:value).and_return('2.6') + } + + describe 'iptables_version' do + it { + allow(Facter::Util::Resolution).to receive(:exec).with('iptables --version'). + and_return('iptables v1.4.7') + Facter.fact(:iptables_version).value.should == '1.4.7' + } + end + + describe 'ip6tables_version' do + before { allow(Facter::Util::Resolution).to receive(:exec). + with('ip6tables --version').and_return('ip6tables v1.4.7') } + it { Facter.fact(:ip6tables_version).value.should == '1.4.7' } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/provider/iptables_chain_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/provider/iptables_chain_spec.rb new file mode 100755 index 0000000000..f350c2e3c5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/provider/iptables_chain_spec.rb @@ -0,0 +1,227 @@ +#!/usr/bin/env rspec + +require 'spec_helper' +if Puppet.version < '3.4.0' + require 'puppet/provider/confine/exists' +else + require 'puppet/confine/exists' +end + +describe 'iptables chain provider detection' do + if Puppet.version < '3.4.0' + let(:exists) { + Puppet::Provider::Confine::Exists + } + else + let(:exists) { + Puppet::Confine::Exists + } + end + + before :each do + # Reset the default provider + Puppet::Type.type(:firewallchain).defaultprovider = nil + end + + it "should default to iptables provider if /sbin/(eb|ip|ip6)tables[-save] exists" do + # Stub lookup for /sbin/iptables & /sbin/iptables-save + allow(exists).to receive(:which).with("ebtables"). + and_return "/sbin/ebtables" + allow(exists).to receive(:which).with("ebtables-save"). + and_return "/sbin/ebtables-save" + + allow(exists).to receive(:which).with("iptables"). + and_return "/sbin/iptables" + allow(exists).to receive(:which).with("iptables-save"). + and_return "/sbin/iptables-save" + + allow(exists).to receive(:which).with("ip6tables"). + and_return "/sbin/ip6tables" + allow(exists).to receive(:which).with("ip6tables-save"). + and_return "/sbin/ip6tables-save" + + # Every other command should return false so we don't pick up any + # other providers + allow(exists).to receive(:which).with() { |value| + value !~ /(eb|ip|ip6)tables(-save)?$/ + }.and_return false + + # Create a resource instance and make sure the provider is iptables + resource = Puppet::Type.type(:firewallchain).new({ + :name => 'test:filter:IPv4', + }) + expect(resource.provider.class.to_s).to eq("Puppet::Type::Firewallchain::ProviderIptables_chain") + end +end + +describe 'iptables chain provider' do + let(:provider) { Puppet::Type.type(:firewallchain).provider(:iptables_chain) } + let(:resource) { + Puppet::Type.type(:firewallchain).new({ + :name => ':test:', + }) + } + + before :each do + allow(Puppet::Type::Firewallchain).to receive(:defaultprovider).and_return provider + allow(provider).to receive(:command).with(:ebtables_save).and_return "/sbin/ebtables-save" + allow(provider).to receive(:command).with(:iptables_save).and_return "/sbin/iptables-save" + allow(provider).to receive(:command).with(:ip6tables_save).and_return "/sbin/ip6tables-save" + end + + it 'should be able to get a list of existing rules' do + # Pretend to return nil from iptables + allow(provider).to receive(:execute).with(['/sbin/ip6tables-save']).and_return("") + allow(provider).to receive(:execute).with(['/sbin/ebtables-save']).and_return("") + allow(provider).to receive(:execute).with(['/sbin/iptables-save']).and_return("") + + provider.instances.each do |chain| + expect(chain).to be_instance_of(provider) + expect(chain.properties[:provider].to_s).to eq(provider.name.to_s) + end + end + +end + +describe 'iptables chain resource parsing' do + let(:provider) { Puppet::Type.type(:firewallchain).provider(:iptables_chain) } + + before :each do + ebtables = ['BROUTE:BROUTING:ethernet', + 'BROUTE:broute:ethernet', + ':INPUT:ethernet', + ':FORWARD:ethernet', + ':OUTPUT:ethernet', + ':filter:ethernet', + ':filterdrop:ethernet', + ':filterreturn:ethernet', + 'NAT:PREROUTING:ethernet', + 'NAT:OUTPUT:ethernet', + 'NAT:POSTROUTING:ethernet', + ] + allow(provider).to receive(:execute).with(['/sbin/ebtables-save']).and_return(' +*broute +:BROUTING ACCEPT +:broute ACCEPT + +*filter +:INPUT ACCEPT +:FORWARD ACCEPT +:OUTPUT ACCEPT +:filter ACCEPT +:filterdrop DROP +:filterreturn RETURN + +*nat +:PREROUTING ACCEPT +:OUTPUT ACCEPT +:POSTROUTING ACCEPT +') + + iptables = [ + 'raw:PREROUTING:IPv4', + 'raw:OUTPUT:IPv4', + 'raw:raw:IPv4', + 'mangle:PREROUTING:IPv4', + 'mangle:INPUT:IPv4', + 'mangle:FORWARD:IPv4', + 'mangle:OUTPUT:IPv4', + 'mangle:POSTROUTING:IPv4', + 'mangle:mangle:IPv4', + 'NAT:PREROUTING:IPv4', + 'NAT:OUTPUT:IPv4', + 'NAT:POSTROUTING:IPv4', + 'NAT:mangle:IPv4', + 'NAT:mangle:IPv4', + 'NAT:mangle:IPv4', + ':$5()*&%\'"^$): :IPv4', + ] + allow(provider).to receive(:execute).with(['/sbin/iptables-save']).and_return(' +# Generated by iptables-save v1.4.9 on Mon Jan 2 01:20:06 2012 +*raw +:PREROUTING ACCEPT [12:1780] +:OUTPUT ACCEPT [19:1159] +:raw - [0:0] +COMMIT +# Completed on Mon Jan 2 01:20:06 2012 +# Generated by iptables-save v1.4.9 on Mon Jan 2 01:20:06 2012 +*mangle +:PREROUTING ACCEPT [12:1780] +:INPUT ACCEPT [12:1780] +:FORWARD ACCEPT [0:0] +:OUTPUT ACCEPT [19:1159] +:POSTROUTING ACCEPT [19:1159] +:mangle - [0:0] +COMMIT +# Completed on Mon Jan 2 01:20:06 2012 +# Generated by iptables-save v1.4.9 on Mon Jan 2 01:20:06 2012 +*nat +:PREROUTING ACCEPT [2242:639750] +:OUTPUT ACCEPT [5176:326206] +:POSTROUTING ACCEPT [5162:325382] +COMMIT +# Completed on Mon Jan 2 01:20:06 2012 +# Generated by iptables-save v1.4.9 on Mon Jan 2 01:20:06 2012 +*filter +:INPUT ACCEPT [0:0] +:FORWARD DROP [0:0] +:OUTPUT ACCEPT [5673:420879] +:$5()*&%\'"^$): - [0:0] +COMMIT +# Completed on Mon Jan 2 01:20:06 2012 +') + ip6tables = [ + 'raw:PREROUTING:IPv6', + 'raw:OUTPUT:IPv6', + 'raw:ff:IPv6', + 'mangle:PREROUTING:IPv6', + 'mangle:INPUT:IPv6', + 'mangle:FORWARD:IPv6', + 'mangle:OUTPUT:IPv6', + 'mangle:POSTROUTING:IPv6', + 'mangle:ff:IPv6', + ':INPUT:IPv6', + ':FORWARD:IPv6', + ':OUTPUT:IPv6', + ':test:IPv6', + ] + allow(provider).to receive(:execute).with(['/sbin/ip6tables-save']).and_return(' +# Generated by ip6tables-save v1.4.9 on Mon Jan 2 01:31:39 2012 +*raw +:PREROUTING ACCEPT [2173:489241] +:OUTPUT ACCEPT [0:0] +:ff - [0:0] +COMMIT +# Completed on Mon Jan 2 01:31:39 2012 +# Generated by ip6tables-save v1.4.9 on Mon Jan 2 01:31:39 2012 +*mangle +:PREROUTING ACCEPT [2301:518373] +:INPUT ACCEPT [0:0] +:FORWARD ACCEPT [0:0] +:OUTPUT ACCEPT [0:0] +:POSTROUTING ACCEPT [0:0] +:ff - [0:0] +COMMIT +# Completed on Mon Jan 2 01:31:39 2012 +# Generated by ip6tables-save v1.4.9 on Mon Jan 2 01:31:39 2012 +*filter +:INPUT ACCEPT [0:0] +:FORWARD DROP [0:0] +:OUTPUT ACCEPT [20:1292] +:test - [0:0] +COMMIT +# Completed on Mon Jan 2 01:31:39 2012 +') + @all = ebtables + iptables + ip6tables + # IPv4 and IPv6 names also exist as resources {table}:{chain}:IP and {table}:{chain}: + iptables.each { |name| @all += [ name[0..-3], name[0..-5] ] } + ip6tables.each { |name| @all += [ name[0..-3], name[0..-5] ] } + end + + it 'should have all in parsed resources' do + provider.instances.each do |resource| + @all.include?(resource.name) + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/provider/iptables_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/provider/iptables_spec.rb new file mode 100644 index 0000000000..d6f5b64cfe --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/provider/iptables_spec.rb @@ -0,0 +1,410 @@ +#!/usr/bin/env rspec + +require 'spec_helper' +if Puppet.version < '3.4.0' + require 'puppet/provider/confine/exists' +else + require 'puppet/confine/exists' +end + +describe 'iptables provider detection' do + if Puppet.version < '3.4.0' + let(:exists) { + Puppet::Provider::Confine::Exists + } + else + let(:exists) { + Puppet::Confine::Exists + } + end + + before :each do + # Reset the default provider + Puppet::Type.type(:firewall).defaultprovider = nil + end + + it "should default to iptables provider if /sbin/iptables[-save] exists" do + # Stub lookup for /sbin/iptables & /sbin/iptables-save + allow(exists).to receive(:which).with("iptables"). + and_return "/sbin/iptables" + allow(exists).to receive(:which).with("iptables-save"). + and_return "/sbin/iptables-save" + + # Every other command should return false so we don't pick up any + # other providers + allow(exists).to receive(:which).with() { |value| + ! ["iptables","iptables-save"].include?(value) + }.and_return false + + # Create a resource instance and make sure the provider is iptables + resource = Puppet::Type.type(:firewall).new({ + :name => '000 test foo', + }) + expect(resource.provider.class.to_s).to eq("Puppet::Type::Firewall::ProviderIptables") + end +end + +describe 'iptables provider' do + let(:provider) { Puppet::Type.type(:firewall).provider(:iptables) } + let(:resource) { + Puppet::Type.type(:firewall).new({ + :name => '000 test foo', + :action => 'accept', + }) + } + + before :each do + allow(Puppet::Type::Firewall).to receive(:defaultprovider).and_return provider + allow(provider).to receive(:command).with(:iptables_save).and_return "/sbin/iptables-save" + + # Stub iptables version + allow(Facter.fact(:iptables_version)).to receive(:value).and_return("1.4.2") + + allow(Puppet::Util::Execution).to receive(:execute).and_return "" + allow(Puppet::Util).to receive(:which).with("iptables-save"). + and_return "/sbin/iptables-save" + end + + it 'should be able to get a list of existing rules' do + provider.instances.each do |rule| + expect(rule).to be_instance_of(provider) + expect(rule.properties[:provider].to_s).to eq(provider.name.to_s) + end + end + + it 'should ignore lines with fatal errors' do + allow(Puppet::Util::Execution).to receive(:execute).with(['/sbin/iptables-save']). + and_return("FATAL: Could not load /lib/modules/2.6.18-028stab095.1/modules.dep: No such file or directory") + + expect(provider.instances.length).to be_zero + end + + describe '#insert_order' do + let(:iptables_save_output) { [ + '-A INPUT -s 8.0.0.2/32 -p tcp -m multiport --ports 100 -m comment --comment "100 test" -j ACCEPT', + '-A INPUT -s 8.0.0.3/32 -p tcp -m multiport --ports 200 -m comment --comment "200 test" -j ACCEPT', + '-A INPUT -s 8.0.0.4/32 -p tcp -m multiport --ports 300 -m comment --comment "300 test" -j ACCEPT' + ] } + let(:resources) do + iptables_save_output.each_with_index.collect { |l,index| provider.rule_to_hash(l, 'filter', index) } + end + let(:providers) do + resources.collect { |r| provider.new(r) } + end + it 'understands offsets for adding rules to the beginning' do + resource = Puppet::Type.type(:firewall).new({ :name => '001 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(1) # 1-indexed + end + it 'understands offsets for editing rules at the beginning' do + resource = Puppet::Type.type(:firewall).new({ :name => '100 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(1) + end + it 'understands offsets for adding rules to the middle' do + resource = Puppet::Type.type(:firewall).new({ :name => '101 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(2) + end + it 'understands offsets for editing rules at the middle' do + resource = Puppet::Type.type(:firewall).new({ :name => '200 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(2) + end + it 'understands offsets for adding rules to the end' do + resource = Puppet::Type.type(:firewall).new({ :name => '301 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(4) + end + it 'understands offsets for editing rules at the end' do + resource = Puppet::Type.type(:firewall).new({ :name => '300 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(3) + end + + context 'with unname rules between' do + let(:iptables_save_output) { [ + '-A INPUT -s 8.0.0.2/32 -p tcp -m multiport --ports 100 -m comment --comment "100 test" -j ACCEPT', + '-A INPUT -s 8.0.0.2/32 -p tcp -m multiport --ports 150 -m comment --comment "150 test" -j ACCEPT', + '-A INPUT -s 8.0.0.3/32 -p tcp -m multiport --ports 200 -j ACCEPT', + '-A INPUT -s 8.0.0.3/32 -p tcp -m multiport --ports 250 -j ACCEPT', + '-A INPUT -s 8.0.0.4/32 -p tcp -m multiport --ports 300 -m comment --comment "300 test" -j ACCEPT', + '-A INPUT -s 8.0.0.4/32 -p tcp -m multiport --ports 350 -m comment --comment "350 test" -j ACCEPT', + ] } + it 'understands offsets for adding rules before unnamed rules' do + resource = Puppet::Type.type(:firewall).new({ :name => '001 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(1) + end + it 'understands offsets for editing rules before unnamed rules' do + resource = Puppet::Type.type(:firewall).new({ :name => '100 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(1) + end + it 'understands offsets for adding rules between managed rules' do + resource = Puppet::Type.type(:firewall).new({ :name => '120 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(2) + end + it 'understands offsets for adding rules between unnamed rules' do + resource = Puppet::Type.type(:firewall).new({ :name => '151 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(3) + end + it 'understands offsets for adding rules after unnamed rules' do + resource = Puppet::Type.type(:firewall).new({ :name => '351 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(7) + end + end + + context 'with unname rules before and after' do + let(:iptables_save_output) { [ + '-A INPUT -s 8.0.0.3/32 -p tcp -m multiport --ports 050 -j ACCEPT', + '-A INPUT -s 8.0.0.3/32 -p tcp -m multiport --ports 090 -j ACCEPT', + '-A INPUT -s 8.0.0.2/32 -p tcp -m multiport --ports 100 -m comment --comment "100 test" -j ACCEPT', + '-A INPUT -s 8.0.0.2/32 -p tcp -m multiport --ports 150 -m comment --comment "150 test" -j ACCEPT', + '-A INPUT -s 8.0.0.3/32 -p tcp -m multiport --ports 200 -j ACCEPT', + '-A INPUT -s 8.0.0.3/32 -p tcp -m multiport --ports 250 -j ACCEPT', + '-A INPUT -s 8.0.0.4/32 -p tcp -m multiport --ports 300 -m comment --comment "300 test" -j ACCEPT', + '-A INPUT -s 8.0.0.4/32 -p tcp -m multiport --ports 350 -m comment --comment "350 test" -j ACCEPT', + '-A INPUT -s 8.0.0.5/32 -p tcp -m multiport --ports 400 -j ACCEPT', + '-A INPUT -s 8.0.0.5/32 -p tcp -m multiport --ports 450 -j ACCEPT', + ] } + it 'understands offsets for adding rules before unnamed rules' do + resource = Puppet::Type.type(:firewall).new({ :name => '001 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(1) + end + it 'understands offsets for editing rules before unnamed rules' do + resource = Puppet::Type.type(:firewall).new({ :name => '100 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(3) + end + it 'understands offsets for adding rules between managed rules' do + resource = Puppet::Type.type(:firewall).new({ :name => '120 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(4) + end + it 'understands offsets for adding rules between unnamed rules' do + resource = Puppet::Type.type(:firewall).new({ :name => '151 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(5) + end + it 'understands offsets for adding rules after unnamed rules' do + resource = Puppet::Type.type(:firewall).new({ :name => '351 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(9) + end + it 'understands offsets for adding rules at the end' do + resource = Puppet::Type.type(:firewall).new({ :name => '950 test', }) + allow(resource.provider.class).to receive(:instances).and_return(providers) + expect(resource.provider.insert_order).to eq(11) + end + end + end + + # Load in ruby hash for test fixtures. + load 'spec/fixtures/iptables/conversion_hash.rb' + + describe 'when converting rules to resources' do + ARGS_TO_HASH.each do |test_name,data| + describe "for test data '#{test_name}'" do + let(:resource) { provider.rule_to_hash(data[:line], data[:table], 0) } + + # If this option is enabled, make sure the parameters exactly match + if data[:compare_all] then + it "the parameter hash keys should be the same as returned by rules_to_hash" do + expect(resource.keys).to match_array(data[:params].keys) + end + end + + # Iterate across each parameter, creating an example for comparison + data[:params].each do |param_name, param_value| + it "the parameter '#{param_name.to_s}' should match #{param_value.inspect}" do + # booleans get cludged to string "true" + if param_value == true then + expect(resource[param_name]).to be_true + else + expect(resource[param_name]).to eq(data[:params][param_name]) + end + end + end + end + end + end + + describe 'when working out general_args' do + HASH_TO_ARGS.each do |test_name,data| + describe "for test data '#{test_name}'" do + let(:resource) { Puppet::Type.type(:firewall).new(data[:params]) } + let(:provider) { Puppet::Type.type(:firewall).provider(:iptables) } + let(:instance) { provider.new(resource) } + + it 'general_args should be valid' do + expect(instance.general_args.flatten).to eq(data[:args]) + end + end + end + end + + describe 'when converting rules without comments to resources' do + let(:sample_rule) { + '-A INPUT -s 1.1.1.1 -d 1.1.1.1 -p tcp -m multiport --dports 7061,7062 -m multiport --sports 7061,7062 -j ACCEPT' + } + let(:resource) { provider.rule_to_hash(sample_rule, 'filter', 0) } + let(:instance) { provider.new(resource) } + + it 'rule name contains a MD5 sum of the line' do + expect(resource[:name]).to eq("9000 #{Digest::MD5.hexdigest(resource[:line])}") + end + + it 'parsed the rule arguments correctly' do + expect(resource[:chain]).to eq('INPUT') + expect(resource[:source]).to eq('1.1.1.1/32') + expect(resource[:destination]).to eq('1.1.1.1/32') + expect(resource[:proto]).to eq('tcp') + expect(resource[:dport]).to eq(['7061', '7062']) + expect(resource[:sport]).to eq(['7061', '7062']) + expect(resource[:action]).to eq('accept') + end + end + + describe 'when converting existing rules generates by system-config-firewall-tui to resources' do + let(:sample_rule) { + # as generated by iptables-save from rules created with system-config-firewall-tui + '-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT' + } + let(:resource) { provider.rule_to_hash(sample_rule, 'filter', 0) } + let(:instance) { provider.new(resource) } + + it 'rule name contains a MD5 sum of the line' do + expect(resource[:name]).to eq("9000 #{Digest::MD5.hexdigest(resource[:line])}") + end + + it 'parse arguments' do + expect(resource[:chain]).to eq('INPUT') + expect(resource[:proto]).to eq('tcp') + expect(resource[:dport]).to eq(['22']) + expect(resource[:state]).to eq(['NEW']) + expect(resource[:action]).to eq('accept') + end + end + + describe 'when creating resources' do + let(:instance) { provider.new(resource) } + + it 'insert_args should be an array' do + expect(instance.insert_args.class).to eq(Array) + end + end + + describe 'when modifying resources' do + let(:instance) { provider.new(resource) } + + it 'update_args should be an array' do + expect(instance.update_args.class).to eq(Array) + end + + it 'fails when modifying the chain' do + expect { instance.chain = "OUTPUT" }.to raise_error(/is not supported/) + end + end + + describe 'when deleting resources' do + let(:sample_rule) { + '-A INPUT -s 1.1.1.1 -d 1.1.1.1 -p tcp -m multiport --dports 7061,7062 -m multiport --sports 7061,7062 -j ACCEPT' + } + let(:resource) { provider.rule_to_hash(sample_rule, 'filter', 0) } + let(:instance) { provider.new(resource) } + + it 'resource[:line] looks like the original rule' do + resource[:line] == sample_rule + end + + it 'delete_args is an array' do + expect(instance.delete_args.class).to eq(Array) + end + + it 'delete_args is the same as the rule string when joined' do + expect(instance.delete_args.join(' ')).to eq(sample_rule.gsub(/\-A/, + '-t filter -D')) + end + end +end + +describe 'ip6tables provider' do + let(:provider6) { Puppet::Type.type(:firewall).provider(:ip6tables) } + let(:resource) { + Puppet::Type.type(:firewall).new({ + :name => '000 test foo', + :action => 'accept', + :provider => "ip6tables", + }) + } + + before :each do + allow(Puppet::Type::Firewall).to receive(:ip6tables).and_return provider6 + allow(provider6).to receive(:command).with(:ip6tables_save).and_return "/sbin/ip6tables-save" + + # Stub iptables version + allow(Facter.fact(:ip6tables_version)).to receive(:value).and_return '1.4.7' + + allow(Puppet::Util::Execution).to receive(:execute).and_return '' + allow(Puppet::Util).to receive(:which).with("ip6tables-save"). + and_return "/sbin/ip6tables-save" + end + + it 'should be able to get a list of existing rules' do + provider6.instances.each do |rule| + rule.should be_instance_of(provider6) + rule.properties[:provider6].to_s.should == provider6.name.to_s + end + end + + it 'should ignore lines with fatal errors' do + allow(Puppet::Util::Execution).to receive(:execute).with(['/sbin/ip6tables-save']). + and_return("FATAL: Could not load /lib/modules/2.6.18-028stab095.1/modules.dep: No such file or directory") + provider6.instances.length.should == 0 + end + + # Load in ruby hash for test fixtures. + load 'spec/fixtures/ip6tables/conversion_hash.rb' + + describe 'when converting rules to resources' do + ARGS_TO_HASH6.each do |test_name,data| + describe "for test data '#{test_name}'" do + let(:resource) { provider6.rule_to_hash(data[:line], data[:table], 0) } + + # If this option is enabled, make sure the parameters exactly match + if data[:compare_all] then + it "the parameter hash keys should be the same as returned by rules_to_hash" do + resource.keys.should =~ data[:params].keys + end + end + + # Iterate across each parameter, creating an example for comparison + data[:params].each do |param_name, param_value| + it "the parameter '#{param_name.to_s}' should match #{param_value.inspect}" do + resource[param_name].should == data[:params][param_name] + end + end + end + end + end + + describe 'when working out general_args' do + HASH_TO_ARGS6.each do |test_name,data| + describe "for test data '#{test_name}'" do + let(:resource) { Puppet::Type.type(:firewall).new(data[:params]) } + let(:provider6) { Puppet::Type.type(:firewall).provider(:ip6tables) } + let(:instance) { provider6.new(resource) } + + it 'general_args should be valid' do + instance.general_args.flatten.should == data[:args] + end + end + end + end +end + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/type/firewall_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/type/firewall_spec.rb new file mode 100755 index 0000000000..afb61662b6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/type/firewall_spec.rb @@ -0,0 +1,650 @@ +#!/usr/bin/env rspec + +require 'spec_helper' + +firewall = Puppet::Type.type(:firewall) + +describe firewall do + before :each do + @class = firewall + @provider = double 'provider' + allow(@provider).to receive(:name).and_return(:iptables) + allow(Puppet::Type::Firewall).to receive(:defaultprovider).and_return @provider + + @resource = @class.new({:name => '000 test foo'}) + + # Stub iptables version + allow(Facter.fact(:iptables_version)).to receive(:value).and_return('1.4.2') + allow(Facter.fact(:ip6tables_version)).to receive(:value).and_return('1.4.2') + + # Stub confine facts + allow(Facter.fact(:kernel)).to receive(:value).and_return('Linux') + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('Debian') + end + + it 'should have :name be its namevar' do + @class.key_attributes.should == [:name] + end + + describe ':name' do + it 'should accept a name' do + @resource[:name] = '000-test-foo' + @resource[:name].should == '000-test-foo' + end + + it 'should not accept a name with non-ASCII chars' do + lambda { @resource[:name] = '%*#^(#$' }.should raise_error(Puppet::Error) + end + end + + describe ':action' do + it "should have no default" do + res = @class.new(:name => "000 test") + res.parameters[:action].should == nil + end + + [:accept, :drop, :reject].each do |action| + it "should accept value #{action}" do + @resource[:action] = action + @resource[:action].should == action + end + end + + it 'should fail when value is not recognized' do + lambda { @resource[:action] = 'not valid' }.should raise_error(Puppet::Error) + end + end + + describe ':chain' do + [:INPUT, :FORWARD, :OUTPUT, :PREROUTING, :POSTROUTING].each do |chain| + it "should accept chain value #{chain}" do + @resource[:chain] = chain + @resource[:chain].should == chain + end + end + + it 'should fail when the chain value is not recognized' do + lambda { @resource[:chain] = 'not valid' }.should raise_error(Puppet::Error) + end + end + + describe ':table' do + [:nat, :mangle, :filter, :raw].each do |table| + it "should accept table value #{table}" do + @resource[:table] = table + @resource[:table].should == table + end + end + + it "should fail when table value is not recognized" do + lambda { @resource[:table] = 'not valid' }.should raise_error(Puppet::Error) + end + end + + describe ':proto' do + [:tcp, :udp, :icmp, :esp, :ah, :vrrp, :igmp, :ipencap, :ospf, :gre, :all].each do |proto| + it "should accept proto value #{proto}" do + @resource[:proto] = proto + @resource[:proto].should == proto + end + end + + it "should fail when proto value is not recognized" do + lambda { @resource[:proto] = 'foo' }.should raise_error(Puppet::Error) + end + end + + describe ':jump' do + it "should have no default" do + res = @class.new(:name => "000 test") + res.parameters[:jump].should == nil + end + + ['QUEUE', 'RETURN', 'DNAT', 'SNAT', 'LOG', 'MASQUERADE', 'REDIRECT', 'MARK'].each do |jump| + it "should accept jump value #{jump}" do + @resource[:jump] = jump + @resource[:jump].should == jump + end + end + + ['ACCEPT', 'DROP', 'REJECT'].each do |jump| + it "should now fail when value #{jump}" do + lambda { @resource[:jump] = jump }.should raise_error(Puppet::Error) + end + end + + it "should fail when jump value is not recognized" do + lambda { @resource[:jump] = '%^&*' }.should raise_error(Puppet::Error) + end + end + + [:source, :destination].each do |addr| + describe addr do + it "should accept a #{addr} as a string" do + @resource[addr] = '127.0.0.1' + @resource[addr].should == '127.0.0.1/32' + end + ['0.0.0.0/0', '::/0'].each do |prefix| + it "should be nil for zero prefix length address #{prefix}" do + @resource[addr] = prefix + @resource[addr].should == nil + end + end + it "should accept a negated #{addr} as a string" do + @resource[addr] = '! 127.0.0.1' + @resource[addr].should == '! 127.0.0.1/32' + end + end + end + + [:dport, :sport].each do |port| + describe port do + it "should accept a #{port} as string" do + @resource[port] = '22' + @resource[port].should == ['22'] + end + + it "should accept a #{port} as an array" do + @resource[port] = ['22','23'] + @resource[port].should == ['22','23'] + end + + it "should accept a #{port} as a number" do + @resource[port] = 22 + @resource[port].should == ['22'] + end + + it "should accept a #{port} as a hyphen separated range" do + @resource[port] = ['22-1000'] + @resource[port].should == ['22-1000'] + end + + it "should accept a #{port} as a combination of arrays of single and " \ + "hyphen separated ranges" do + + @resource[port] = ['22-1000','33','3000-4000'] + @resource[port].should == ['22-1000','33','3000-4000'] + end + + it "should convert a port name for #{port} to its number" do + @resource[port] = 'ssh' + @resource[port].should == ['22'] + end + + it "should not accept something invalid for #{port}" do + expect { @resource[port] = 'something odd' }.to raise_error(Puppet::Error, /^Parameter .+ failed.+Munging failed for value ".+" in class .+: no such service/) + end + + it "should not accept something invalid in an array for #{port}" do + expect { @resource[port] = ['something odd','something even odder'] }.to raise_error(Puppet::Error, /^Parameter .+ failed.+Munging failed for value ".+" in class .+: no such service/) + end + end + end + + [:dst_type, :src_type].each do |addrtype| + describe addrtype do + it "should have no default" do + res = @class.new(:name => "000 test") + res.parameters[addrtype].should == nil + end + end + + [:UNSPEC, :UNICAST, :LOCAL, :BROADCAST, :ANYCAST, :MULTICAST, :BLACKHOLE, + :UNREACHABLE, :PROHIBIT, :THROW, :NAT, :XRESOLVE].each do |type| + it "should accept #{addrtype} value #{type}" do + @resource[addrtype] = type + @resource[addrtype].should == type + end + end + + it "should fail when #{addrtype} value is not recognized" do + lambda { @resource[addrtype] = 'foo' }.should raise_error(Puppet::Error) + end + end + + [:iniface, :outiface].each do |iface| + describe iface do + it "should accept #{iface} value as a string" do + @resource[iface] = 'eth1' + @resource[iface].should == 'eth1' + end + end + end + + [:tosource, :todest].each do |addr| + describe addr do + it "should accept #{addr} value as a string" do + @resource[addr] = '127.0.0.1' + end + end + end + + describe ':log_level' do + values = { + 'panic' => '0', + 'alert' => '1', + 'crit' => '2', + 'err' => '3', + 'warn' => '4', + 'warning' => '4', + 'not' => '5', + 'notice' => '5', + 'info' => '6', + 'debug' => '7' + } + + values.each do |k,v| + it { + @resource[:log_level] = k + @resource[:log_level].should == v + } + + it { + @resource[:log_level] = 3 + @resource[:log_level].should == 3 + } + + it { lambda { @resource[:log_level] = 'foo' }.should raise_error(Puppet::Error) } + end + end + + describe ':icmp' do + icmp_codes = { + :iptables => { + '0' => 'echo-reply', + '3' => 'destination-unreachable', + '4' => 'source-quench', + '6' => 'redirect', + '8' => 'echo-request', + '9' => 'router-advertisement', + '10' => 'router-solicitation', + '11' => 'time-exceeded', + '12' => 'parameter-problem', + '13' => 'timestamp-request', + '14' => 'timestamp-reply', + '17' => 'address-mask-request', + '18' => 'address-mask-reply' + }, + :ip6tables => { + '1' => 'destination-unreachable', + '3' => 'time-exceeded', + '4' => 'parameter-problem', + '128' => 'echo-request', + '129' => 'echo-reply', + '133' => 'router-solicitation', + '134' => 'router-advertisement', + '137' => 'redirect' + } + } + icmp_codes.each do |provider, values| + describe provider do + values.each do |k,v| + it 'should convert icmp string to number' do + @resource[:provider] = provider + @resource[:provider].should == provider + @resource[:icmp] = v + @resource[:icmp].should == k + end + end + end + end + + it 'should accept values as integers' do + @resource[:icmp] = 9 + @resource[:icmp].should == 9 + end + + it 'should fail if icmp type is "any"' do + lambda { @resource[:icmp] = 'any' }.should raise_error(Puppet::Error) + end + + it 'should fail if icmp type cannot be mapped to a numeric' do + lambda { @resource[:icmp] = 'foo' }.should raise_error(Puppet::Error) + end + end + + describe ':state' do + it 'should accept value as a string' do + @resource[:state] = :INVALID + @resource[:state].should == [:INVALID] + end + + it 'should accept value as an array' do + @resource[:state] = [:INVALID, :NEW] + @resource[:state].should == [:INVALID, :NEW] + end + + it 'should sort values alphabetically' do + @resource[:state] = [:NEW, :ESTABLISHED] + @resource[:state].should == [:ESTABLISHED, :NEW] + end + end + + describe ':ctstate' do + it 'should accept value as a string' do + @resource[:ctstate] = :INVALID + @resource[:ctstate].should == [:INVALID] + end + + it 'should accept value as an array' do + @resource[:ctstate] = [:INVALID, :NEW] + @resource[:ctstate].should == [:INVALID, :NEW] + end + + it 'should sort values alphabetically' do + @resource[:ctstate] = [:NEW, :ESTABLISHED] + @resource[:ctstate].should == [:ESTABLISHED, :NEW] + end + end + + describe ':burst' do + it 'should accept numeric values' do + @resource[:burst] = 12 + @resource[:burst].should == 12 + end + + it 'should fail if value is not numeric' do + lambda { @resource[:burst] = 'foo' }.should raise_error(Puppet::Error) + end + end + + describe ':recent' do + ['set', 'update', 'rcheck', 'remove'].each do |recent| + it "should accept recent value #{recent}" do + @resource[:recent] = recent + @resource[:recent].should == "--#{recent}" + end + end + end + + describe ':action and :jump' do + it 'should allow only 1 to be set at a time' do + expect { + @class.new( + :name => "001-test", + :action => "accept", + :jump => "custom_chain" + ) + }.to raise_error(Puppet::Error, /Only one of the parameters 'action' and 'jump' can be set$/) + end + end + describe ':gid and :uid' do + it 'should allow me to set uid' do + @resource[:uid] = 'root' + @resource[:uid].should == 'root' + end + it 'should allow me to set uid as an array, and silently hide my error' do + @resource[:uid] = ['root', 'bobby'] + @resource[:uid].should == 'root' + end + it 'should allow me to set gid' do + @resource[:gid] = 'root' + @resource[:gid].should == 'root' + end + it 'should allow me to set gid as an array, and silently hide my error' do + @resource[:gid] = ['root', 'bobby'] + @resource[:gid].should == 'root' + end + end + + describe ':set_mark' do + ['1.3.2', '1.4.2'].each do |iptables_version| + describe "with iptables #{iptables_version}" do + before { + Facter.clear + allow(Facter.fact(:iptables_version)).to receive(:value).and_return iptables_version + allow(Facter.fact(:ip6tables_version)).to receive(:value).and_return iptables_version + } + + if iptables_version == '1.3.2' + it 'should allow me to set set-mark without mask' do + @resource[:set_mark] = '0x3e8' + @resource[:set_mark].should == '0x3e8' + end + it 'should convert int to hex without mask' do + @resource[:set_mark] = '1000' + @resource[:set_mark].should == '0x3e8' + end + it 'should fail if mask is present' do + lambda { @resource[:set_mark] = '0x3e8/0xffffffff'}.should raise_error( + Puppet::Error, /iptables version #{iptables_version} does not support masks on MARK rules$/ + ) + end + end + + if iptables_version == '1.4.2' + it 'should allow me to set set-mark with mask' do + @resource[:set_mark] = '0x3e8/0xffffffff' + @resource[:set_mark].should == '0x3e8/0xffffffff' + end + it 'should convert int to hex and add a 32 bit mask' do + @resource[:set_mark] = '1000' + @resource[:set_mark].should == '0x3e8/0xffffffff' + end + it 'should add a 32 bit mask' do + @resource[:set_mark] = '0x32' + @resource[:set_mark].should == '0x32/0xffffffff' + end + it 'should use the mask provided' do + @resource[:set_mark] = '0x32/0x4' + @resource[:set_mark].should == '0x32/0x4' + end + it 'should use the mask provided and convert int to hex' do + @resource[:set_mark] = '1000/0x4' + @resource[:set_mark].should == '0x3e8/0x4' + end + it 'should fail if mask value is more than 32 bits' do + lambda { @resource[:set_mark] = '1/4294967296'}.should raise_error( + Puppet::Error, /MARK mask must be integer or hex between 0 and 0xffffffff$/ + ) + end + it 'should fail if mask is malformed' do + lambda { @resource[:set_mark] = '1000/0xq4'}.should raise_error( + Puppet::Error, /MARK mask must be integer or hex between 0 and 0xffffffff$/ + ) + end + end + + ['/', '1000/', 'pwnie'].each do |bad_mark| + it "should fail with malformed mark '#{bad_mark}'" do + lambda { @resource[:set_mark] = bad_mark}.should raise_error(Puppet::Error) + end + end + it 'should fail if mark value is more than 32 bits' do + lambda { @resource[:set_mark] = '4294967296'}.should raise_error( + Puppet::Error, /MARK value must be integer or hex between 0 and 0xffffffff$/ + ) + end + end + end + end + + [:chain, :jump].each do |param| + describe param do + it 'should autorequire fwchain when table and provider are undefined' do + @resource[param] = 'FOO' + @resource[:table].should == :filter + @resource[:provider].should == :iptables + + chain = Puppet::Type.type(:firewallchain).new(:name => 'FOO:filter:IPv4') + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + catalog.add_resource chain + rel = @resource.autorequire[0] + rel.source.ref.should == chain.ref + rel.target.ref.should == @resource.ref + end + + it 'should autorequire fwchain when table is undefined and provider is ip6tables' do + @resource[param] = 'FOO' + @resource[:table].should == :filter + @resource[:provider] = :ip6tables + + chain = Puppet::Type.type(:firewallchain).new(:name => 'FOO:filter:IPv6') + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + catalog.add_resource chain + rel = @resource.autorequire[0] + rel.source.ref.should == chain.ref + rel.target.ref.should == @resource.ref + end + + it 'should autorequire fwchain when table is raw and provider is undefined' do + @resource[param] = 'FOO' + @resource[:table] = :raw + @resource[:provider].should == :iptables + + chain = Puppet::Type.type(:firewallchain).new(:name => 'FOO:raw:IPv4') + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + catalog.add_resource chain + rel = @resource.autorequire[0] + rel.source.ref.should == chain.ref + rel.target.ref.should == @resource.ref + end + + it 'should autorequire fwchain when table is raw and provider is ip6tables' do + @resource[param] = 'FOO' + @resource[:table] = :raw + @resource[:provider] = :ip6tables + + chain = Puppet::Type.type(:firewallchain).new(:name => 'FOO:raw:IPv6') + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + catalog.add_resource chain + rel = @resource.autorequire[0] + rel.source.ref.should == chain.ref + rel.target.ref.should == @resource.ref + end + + # test where autorequire is still needed (table != filter) + ['INPUT', 'OUTPUT', 'FORWARD'].each do |test_chain| + it "should autorequire fwchain #{test_chain} when table is mangle and provider is undefined" do + @resource[param] = test_chain + @resource[:table] = :mangle + @resource[:provider].should == :iptables + + chain = Puppet::Type.type(:firewallchain).new(:name => "#{test_chain}:mangle:IPv4") + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + catalog.add_resource chain + rel = @resource.autorequire[0] + rel.source.ref.should == chain.ref + rel.target.ref.should == @resource.ref + end + + it "should autorequire fwchain #{test_chain} when table is mangle and provider is ip6tables" do + @resource[param] = test_chain + @resource[:table] = :mangle + @resource[:provider] = :ip6tables + + chain = Puppet::Type.type(:firewallchain).new(:name => "#{test_chain}:mangle:IPv6") + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + catalog.add_resource chain + rel = @resource.autorequire[0] + rel.source.ref.should == chain.ref + rel.target.ref.should == @resource.ref + end + end + + # test of case where autorequire should not happen + ['INPUT', 'OUTPUT', 'FORWARD'].each do |test_chain| + + it "should not autorequire fwchain #{test_chain} when table and provider are undefined" do + @resource[param] = test_chain + @resource[:table].should == :filter + @resource[:provider].should == :iptables + + chain = Puppet::Type.type(:firewallchain).new(:name => "#{test_chain}:filter:IPv4") + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + catalog.add_resource chain + rel = @resource.autorequire[0] + rel.should == nil + end + + it "should not autorequire fwchain #{test_chain} when table is undefined and provider is ip6tables" do + @resource[param] = test_chain + @resource[:table].should == :filter + @resource[:provider] = :ip6tables + + chain = Puppet::Type.type(:firewallchain).new(:name => "#{test_chain}:filter:IPv6") + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + catalog.add_resource chain + rel = @resource.autorequire[0] + rel.should == nil + end + end + end + end + + describe ":chain and :jump" do + it 'should autorequire independent fwchains' do + @resource[:chain] = 'FOO' + @resource[:jump] = 'BAR' + @resource[:table].should == :filter + @resource[:provider].should == :iptables + + chain_foo = Puppet::Type.type(:firewallchain).new(:name => 'FOO:filter:IPv4') + chain_bar = Puppet::Type.type(:firewallchain).new(:name => 'BAR:filter:IPv4') + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + catalog.add_resource chain_foo + catalog.add_resource chain_bar + rel = @resource.autorequire + rel[0].source.ref.should == chain_foo.ref + rel[0].target.ref.should == @resource.ref + rel[1].source.ref.should == chain_bar.ref + rel[1].target.ref.should == @resource.ref + end + end + + describe ':pkttype' do + [:multicast, :broadcast, :unicast].each do |pkttype| + it "should accept pkttype value #{pkttype}" do + @resource[:pkttype] = pkttype + @resource[:pkttype].should == pkttype + end + end + + it 'should fail when the pkttype value is not recognized' do + lambda { @resource[:pkttype] = 'not valid' }.should raise_error(Puppet::Error) + end + end + + describe 'autorequire packages' do + [:iptables, :ip6tables].each do |provider| + it "provider #{provider} should autorequire package iptables" do + @resource[:provider] = provider + @resource[:provider].should == provider + package = Puppet::Type.type(:package).new(:name => 'iptables') + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + catalog.add_resource package + rel = @resource.autorequire[0] + rel.source.ref.should == package.ref + rel.target.ref.should == @resource.ref + end + + it "provider #{provider} should autorequire packages iptables and iptables-persistent" do + @resource[:provider] = provider + @resource[:provider].should == provider + packages = [ + Puppet::Type.type(:package).new(:name => 'iptables'), + Puppet::Type.type(:package).new(:name => 'iptables-persistent') + ] + catalog = Puppet::Resource::Catalog.new + catalog.add_resource @resource + packages.each do |package| + catalog.add_resource package + end + packages.zip(@resource.autorequire) do |package, rel| + rel.source.ref.should == package.ref + rel.target.ref.should == @resource.ref + end + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/type/firewallchain_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/type/firewallchain_spec.rb new file mode 100755 index 0000000000..88ca99dc59 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/type/firewallchain_spec.rb @@ -0,0 +1,185 @@ +#!/usr/bin/env rspec + +require 'spec_helper' + +firewallchain = Puppet::Type.type(:firewallchain) + +describe firewallchain do + before(:each) do + # Stub confine facts + allow(Facter.fact(:kernel)).to receive(:value).and_return('Linux') + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('Debian') + end + let(:klass) { firewallchain } + let(:provider) { + prov = double 'provider' + allow(prov).to receive(:name).and_return(:iptables_chain) + prov + } + let(:resource) { + allow(Puppet::Type::Firewallchain).to receive(:defaultprovider).and_return provider + klass.new({:name => 'INPUT:filter:IPv4', :policy => :accept }) + } + + it 'should have :name be its namevar' do + klass.key_attributes.should == [:name] + end + + describe ':name' do + {'nat' => ['PREROUTING', 'POSTROUTING', 'INPUT', 'OUTPUT'], + 'mangle' => [ 'PREROUTING', 'POSTROUTING', 'INPUT', 'FORWARD', 'OUTPUT' ], + 'filter' => ['INPUT','OUTPUT','FORWARD'], + 'raw' => [ 'PREROUTING', 'OUTPUT'], + 'broute' => ['BROUTING'] + }.each_pair do |table, allowedinternalchains| + ['IPv4', 'IPv6', 'ethernet'].each do |protocol| + [ 'test', '$5()*&%\'"^$09):' ].each do |chainname| + name = "#{chainname}:#{table}:#{protocol}" + if table == 'nat' && protocol == 'IPv6' + it "should fail #{name}" do + expect { resource[:name] = name }.to raise_error(Puppet::Error) + end + elsif protocol != 'ethernet' && table == 'broute' + it "should fail #{name}" do + expect { resource[:name] = name }.to raise_error(Puppet::Error) + end + else + it "should accept name #{name}" do + resource[:name] = name + resource[:name].should == name + end + end + end # chainname + end # protocol + + [ 'PREROUTING', 'POSTROUTING', 'BROUTING', 'INPUT', 'FORWARD', 'OUTPUT' ].each do |internalchain| + name = internalchain + ':' + table + ':' + if internalchain == 'BROUTING' + name += 'ethernet' + elsif table == 'nat' + name += 'IPv4' + else + name += 'IPv4' + end + if allowedinternalchains.include? internalchain + it "should allow #{name}" do + resource[:name] = name + resource[:name].should == name + end + else + it "should fail #{name}" do + expect { resource[:name] = name }.to raise_error(Puppet::Error) + end + end + end # internalchain + + end # table, allowedinternalchainnames + + it 'should fail with invalid table names' do + expect { resource[:name] = 'wrongtablename:test:IPv4' }.to raise_error(Puppet::Error) + end + + it 'should fail with invalid protocols names' do + expect { resource[:name] = 'test:filter:IPv5' }.to raise_error(Puppet::Error) + end + + end + + describe ':policy' do + + [:accept, :drop, :queue, :return].each do |policy| + it "should accept policy #{policy}" do + resource[:policy] = policy + resource[:policy].should == policy + end + end + + it 'should fail when value is not recognized' do + expect { resource[:policy] = 'not valid' }.to raise_error(Puppet::Error) + end + + [:accept, :drop, :queue, :return].each do |policy| + it "non-inbuilt chains should not accept policy #{policy}" do + expect { klass.new({:name => 'testchain:filter:IPv4', :policy => policy }) }.to raise_error(Puppet::Error) + end + it "non-inbuilt chains can accept policies on protocol = ethernet (policy #{policy})" do + klass.new({:name => 'testchain:filter:ethernet', :policy => policy }) + end + end + + end + + describe 'autorequire packages' do + it "provider iptables_chain should autorequire package iptables" do + resource[:provider].should == :iptables_chain + package = Puppet::Type.type(:package).new(:name => 'iptables') + catalog = Puppet::Resource::Catalog.new + catalog.add_resource resource + catalog.add_resource package + rel = resource.autorequire[0] + rel.source.ref.should == package.ref + rel.target.ref.should == resource.ref + end + + it "provider iptables_chain should autorequire packages iptables and iptables-persistent" do + resource[:provider].should == :iptables_chain + packages = [ + Puppet::Type.type(:package).new(:name => 'iptables'), + Puppet::Type.type(:package).new(:name => 'iptables-persistent') + ] + catalog = Puppet::Resource::Catalog.new + catalog.add_resource resource + packages.each do |package| + catalog.add_resource package + end + packages.zip(resource.autorequire) do |package, rel| + rel.source.ref.should == package.ref + rel.target.ref.should == resource.ref + end + end + end + + describe 'purge iptables rules' do + before(:each) do + allow(Puppet::Type.type(:firewall).provider(:iptables)).to receive(:iptables_save).and_return(< 'INPUT:filter:IPv4', :purge => true) + + expect(resource.generate.size).to eq(3) + end + + it 'should not generate ignored iptables rules' do + resource = Puppet::Type::Firewallchain.new(:name => 'INPUT:filter:IPv4', :purge => true, :ignore => ['-j fail2ban-ssh']) + + expect(resource.generate.size).to eq(2) + end + + it 'should not generate iptables resources when not enabled' do + resource = Puppet::Type::Firewallchain.new(:name => 'INPUT:filter:IPv4') + + expect(resource.generate.size).to eq(0) + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/util/firewall_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/util/firewall_spec.rb new file mode 100644 index 0000000000..e5864879c3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/util/firewall_spec.rb @@ -0,0 +1,197 @@ +require 'spec_helper' + +describe 'Puppet::Util::Firewall' do + let(:resource) { + type = Puppet::Type.type(:firewall) + provider = double 'provider' + allow(provider).to receive(:name).and_return(:iptables) + allow(Puppet::Type::Firewall).to receive(:defaultprovider).and_return(provider) + type.new({:name => '000 test foo'}) + } + + before(:each) { resource } + + describe '#host_to_ip' do + subject { resource } + specify { + expect(Resolv).to receive(:getaddress).with('puppetlabs.com').and_return('96.126.112.51') + subject.host_to_ip('puppetlabs.com').should == '96.126.112.51/32' + } + specify { subject.host_to_ip('96.126.112.51').should == '96.126.112.51/32' } + specify { subject.host_to_ip('96.126.112.51/32').should == '96.126.112.51/32' } + specify { subject.host_to_ip('2001:db8:85a3:0:0:8a2e:370:7334').should == '2001:db8:85a3::8a2e:370:7334/128' } + specify { subject.host_to_ip('2001:db8:1234::/48').should == '2001:db8:1234::/48' } + specify { subject.host_to_ip('0.0.0.0/0').should == nil } + specify { subject.host_to_ip('::/0').should == nil } + end + + describe '#host_to_mask' do + subject { resource } + specify { + expect(Resolv).to receive(:getaddress).at_least(:once).with('puppetlabs.com').and_return('96.126.112.51') + subject.host_to_mask('puppetlabs.com').should == '96.126.112.51/32' + subject.host_to_mask('!puppetlabs.com').should == '! 96.126.112.51/32' + } + specify { subject.host_to_mask('96.126.112.51').should == '96.126.112.51/32' } + specify { subject.host_to_mask('!96.126.112.51').should == '! 96.126.112.51/32' } + specify { subject.host_to_mask('96.126.112.51/32').should == '96.126.112.51/32' } + specify { subject.host_to_mask('! 96.126.112.51/32').should == '! 96.126.112.51/32' } + specify { subject.host_to_mask('2001:db8:85a3:0:0:8a2e:370:7334').should == '2001:db8:85a3::8a2e:370:7334/128' } + specify { subject.host_to_mask('!2001:db8:85a3:0:0:8a2e:370:7334').should == '! 2001:db8:85a3::8a2e:370:7334/128' } + specify { subject.host_to_mask('2001:db8:1234::/48').should == '2001:db8:1234::/48' } + specify { subject.host_to_mask('! 2001:db8:1234::/48').should == '! 2001:db8:1234::/48' } + specify { subject.host_to_mask('0.0.0.0/0').should == nil } + specify { subject.host_to_mask('!0.0.0.0/0').should == nil } + specify { subject.host_to_mask('::/0').should == nil } + specify { subject.host_to_mask('! ::/0').should == nil } + end + + describe '#icmp_name_to_number' do + describe 'proto unsupported' do + subject { resource } + + %w{inet5 inet8 foo}.each do |proto| + it "should reject invalid proto #{proto}" do + expect { subject.icmp_name_to_number('echo-reply', proto) }. + to raise_error(ArgumentError, "unsupported protocol family '#{proto}'") + end + end + end + + describe 'proto IPv4' do + proto = 'inet' + subject { resource } + specify { subject.icmp_name_to_number('echo-reply', proto).should == '0' } + specify { subject.icmp_name_to_number('destination-unreachable', proto).should == '3' } + specify { subject.icmp_name_to_number('source-quench', proto).should == '4' } + specify { subject.icmp_name_to_number('redirect', proto).should == '6' } + specify { subject.icmp_name_to_number('echo-request', proto).should == '8' } + specify { subject.icmp_name_to_number('router-advertisement', proto).should == '9' } + specify { subject.icmp_name_to_number('router-solicitation', proto).should == '10' } + specify { subject.icmp_name_to_number('time-exceeded', proto).should == '11' } + specify { subject.icmp_name_to_number('parameter-problem', proto).should == '12' } + specify { subject.icmp_name_to_number('timestamp-request', proto).should == '13' } + specify { subject.icmp_name_to_number('timestamp-reply', proto).should == '14' } + specify { subject.icmp_name_to_number('address-mask-request', proto).should == '17' } + specify { subject.icmp_name_to_number('address-mask-reply', proto).should == '18' } + end + + describe 'proto IPv6' do + proto = 'inet6' + subject { resource } + specify { subject.icmp_name_to_number('destination-unreachable', proto).should == '1' } + specify { subject.icmp_name_to_number('time-exceeded', proto).should == '3' } + specify { subject.icmp_name_to_number('parameter-problem', proto).should == '4' } + specify { subject.icmp_name_to_number('echo-request', proto).should == '128' } + specify { subject.icmp_name_to_number('echo-reply', proto).should == '129' } + specify { subject.icmp_name_to_number('router-solicitation', proto).should == '133' } + specify { subject.icmp_name_to_number('router-advertisement', proto).should == '134' } + specify { subject.icmp_name_to_number('redirect', proto).should == '137' } + end + end + + describe '#string_to_port' do + subject { resource } + specify { subject.string_to_port('80','tcp').should == '80' } + specify { subject.string_to_port(80,'tcp').should == '80' } + specify { subject.string_to_port('http','tcp').should == '80' } + specify { subject.string_to_port('domain','udp').should == '53' } + end + + describe '#to_hex32' do + subject { resource } + specify { subject.to_hex32('0').should == '0x0' } + specify { subject.to_hex32('0x32').should == '0x32' } + specify { subject.to_hex32('42').should == '0x2a' } + specify { subject.to_hex32('4294967295').should == '0xffffffff' } + specify { subject.to_hex32('4294967296').should == nil } + specify { subject.to_hex32('-1').should == nil } + specify { subject.to_hex32('bananas').should == nil } + end + + describe '#persist_iptables' do + before { Facter.clear } + subject { resource } + + describe 'when proto is IPv4' do + let(:proto) { 'IPv4' } + + it 'should exec /sbin/service if running RHEL 6 or earlier' do + allow(Facter.fact(:osfamily)).to receive(:value).and_return('RedHat') + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('RedHat') + allow(Facter.fact(:operatingsystemrelease)).to receive(:value).and_return('6') + + expect(subject).to receive(:execute).with(%w{/sbin/service iptables save}) + subject.persist_iptables(proto) + end + + it 'should exec for systemd if running RHEL 7 or greater' do + allow(Facter.fact(:osfamily)).to receive(:value).and_return('RedHat') + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('RedHat') + allow(Facter.fact(:operatingsystemrelease)).to receive(:value).and_return('7') + + expect(subject).to receive(:execute).with(%w{/usr/libexec/iptables/iptables.init save}) + subject.persist_iptables(proto) + end + + it 'should exec for systemd if running Fedora 15 or greater' do + allow(Facter.fact(:osfamily)).to receive(:value).and_return('RedHat') + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('Fedora') + allow(Facter.fact(:operatingsystemrelease)).to receive(:value).and_return('15') + + expect(subject).to receive(:execute).with(%w{/usr/libexec/iptables/iptables.init save}) + subject.persist_iptables(proto) + end + + it 'should exec for CentOS identified from operatingsystem' do + allow(Facter.fact(:osfamily)).to receive(:value).and_return(nil) + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('CentOS') + expect(subject).to receive(:execute).with(%w{/sbin/service iptables save}) + subject.persist_iptables(proto) + end + + it 'should exec for Archlinux identified from osfamily' do + allow(Facter.fact(:osfamily)).to receive(:value).and_return('Archlinux') + expect(subject).to receive(:execute).with(['/bin/sh', '-c', '/usr/sbin/iptables-save > /etc/iptables/iptables.rules']) + subject.persist_iptables(proto) + end + + it 'should raise a warning when exec fails' do + allow(Facter.fact(:osfamily)).to receive(:value).and_return('RedHat') + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('RedHat') + allow(Facter.fact(:operatingsystemrelease)).to receive(:value).and_return('6') + + expect(subject).to receive(:execute).with(%w{/sbin/service iptables save}). + and_raise(Puppet::ExecutionFailure, 'some error') + expect(subject).to receive(:warning).with('Unable to persist firewall rules: some error') + subject.persist_iptables(proto) + end + end + + describe 'when proto is IPv6' do + let(:proto) { 'IPv6' } + + it 'should exec for newer Ubuntu' do + allow(Facter.fact(:osfamily)).to receive(:value).and_return(nil) + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('Ubuntu') + allow(Facter.fact(:iptables_persistent_version)).to receive(:value).and_return('0.5.3ubuntu2') + expect(subject).to receive(:execute).with(%w{/usr/sbin/service iptables-persistent save}) + subject.persist_iptables(proto) + end + + it 'should not exec for older Ubuntu which does not support IPv6' do + allow(Facter.fact(:osfamily)).to receive(:value).and_return(nil) + allow(Facter.fact(:operatingsystem)).to receive(:value).and_return('Ubuntu') + allow(Facter.fact(:iptables_persistent_version)).to receive(:value).and_return('0.0.20090701') + expect(subject).to receive(:execute).never + subject.persist_iptables(proto) + end + + it 'should not exec for Suse which is not supported' do + allow(Facter.fact(:osfamily)).to receive(:value).and_return('Suse') + expect(subject).to receive(:execute).never + subject.persist_iptables(proto) + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/util/ipcidr_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/util/ipcidr_spec.rb new file mode 100644 index 0000000000..916f74a350 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/firewall/spec/unit/puppet/util/ipcidr_spec.rb @@ -0,0 +1,67 @@ +require 'spec_helper' + +describe 'Puppet::Util::IPCidr' do + describe 'ipv4 address' do + before { @ipaddr = Puppet::Util::IPCidr.new('96.126.112.51') } + subject { @ipaddr } + specify { subject.cidr.should == '96.126.112.51/32' } + specify { subject.prefixlen.should == 32 } + specify { subject.netmask.should == '255.255.255.255' } + end + + describe 'single ipv4 address with cidr' do + before { @ipcidr = Puppet::Util::IPCidr.new('96.126.112.51/32') } + subject { @ipcidr } + specify { subject.cidr.should == '96.126.112.51/32' } + specify { subject.prefixlen.should == 32 } + specify { subject.netmask.should == '255.255.255.255' } + end + + describe 'ipv4 address range with cidr' do + before { @ipcidr = Puppet::Util::IPCidr.new('96.126.112.0/24') } + subject { @ipcidr } + specify { subject.cidr.should == '96.126.112.0/24' } + specify { subject.prefixlen.should == 24 } + specify { subject.netmask.should == '255.255.255.0' } + end + + describe 'ipv4 open range with cidr' do + before { @ipcidr = Puppet::Util::IPCidr.new('0.0.0.0/0') } + subject { @ipcidr } + specify { subject.cidr.should == '0.0.0.0/0' } + specify { subject.prefixlen.should == 0 } + specify { subject.netmask.should == '0.0.0.0' } + end + + describe 'ipv6 address' do + before { @ipaddr = Puppet::Util::IPCidr.new('2001:db8:85a3:0:0:8a2e:370:7334') } + subject { @ipaddr } + specify { subject.cidr.should == '2001:db8:85a3::8a2e:370:7334/128' } + specify { subject.prefixlen.should == 128 } + specify { subject.netmask.should == 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' } + end + + describe 'single ipv6 addr with cidr' do + before { @ipaddr = Puppet::Util::IPCidr.new('2001:db8:85a3:0:0:8a2e:370:7334/128') } + subject { @ipaddr } + specify { subject.cidr.should == '2001:db8:85a3::8a2e:370:7334/128' } + specify { subject.prefixlen.should == 128 } + specify { subject.netmask.should == 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' } + end + + describe 'ipv6 addr range with cidr' do + before { @ipaddr = Puppet::Util::IPCidr.new('2001:db8:1234::/48') } + subject { @ipaddr } + specify { subject.cidr.should == '2001:db8:1234::/48' } + specify { subject.prefixlen.should == 48 } + specify { subject.netmask.should == 'ffff:ffff:ffff:0000:0000:0000:0000:0000' } + end + + describe 'ipv6 open range with cidr' do + before { @ipaddr = Puppet::Util::IPCidr.new('::/0') } + subject { @ipaddr } + specify { subject.cidr.should == '::/0' } + specify { subject.prefixlen.should == 0 } + specify { subject.netmask.should == '0000:0000:0000:0000:0000:0000:0000:0000' } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/.fixtures.yml new file mode 100644 index 0000000000..2aa9e3d77a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/.fixtures.yml @@ -0,0 +1,5 @@ +fixtures: + repositories: + vcsrepo: git://github.com/puppetlabs/puppetlabs-vcsrepo.git + symlinks: + git: "#{source_dir}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/CHANGELOG b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/CHANGELOG new file mode 100644 index 0000000000..670358b689 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/CHANGELOG @@ -0,0 +1,2 @@ +2011-06-03 - Dan Bode - 0.0.1 +* initial commit diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/LICENSE new file mode 100644 index 0000000000..297f85cfa8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2013 Puppet Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/Modulefile new file mode 100644 index 0000000000..9403b43a06 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/Modulefile @@ -0,0 +1,10 @@ +name 'puppetlabs-git' +version '0.0.3' +source 'git://github.com/puppetlabs/puppetlabs-git.git' +author 'puppetlabs' +license 'Apache 2.0' +summary 'module for installing git' +description 'module for installing git' +project_page 'https://github.com/puppetlabs/puppetlabs-git/' +dependency 'puppetlabs/vcsrepo' + diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/README.md new file mode 100644 index 0000000000..49e51f4817 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/README.md @@ -0,0 +1,71 @@ +#git + +####Table of Contents + +1. [Overview - What is the [Modulename] module?](#overview) +2. [Module Description - What does the module do?](#module-description) +3. [Setup - The basics of getting started with [Modulename]](#setup) + * [What [Modulename] affects](#what-registry-affects) +4. [Usage - Configuration options and additional functionality](#usage) +6. [Limitations - OS compatibility, etc.](#limitations) +7. [Development - Guide for contributing to the module](#development) + +##Overview + +Simple module that can install git or gitosis + +##Module Description + +This module installs the git revision control system on a target node. It does not manage a git server or any associated services; it simply ensures a bare minimum set of features (e.g. just a package) to use git. + +##Setup + +###What git affects + +* Package['git'] + +The specifics managed by the module may vary depending on the platform. + +##Usage + +###I just want `git` installed +Simply include the `git` class. + +```puppet +include git +``` + +###I want to use `git subtree` with bash completion + +```puppet +include git::subtree +``` + +##Reference + +###Classes + +* `git`: Installs the git client package. +* `gitosis`: Installs the gitosis package. No configuration +* `subtree`: Installs and configures git-subtree for git 1.7 and up. + +###Facts + +* `git_exec_path`: Path to the directory containing all `git-*` commands. +* `git_version`: Version of git that is installed. Undefined if not installed. + +##Limitations + +This module is known to work with the following operating system families: + + - RedHat 5, 6 + - Debian 6.0.7 or newer + - Ubuntu 12.04 or newer + +##Development + +Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can’t access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things. + +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/Rakefile new file mode 100644 index 0000000000..cd3d379958 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/Rakefile @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/rake_tasks' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/files/subtree/bash_completion.sh b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/files/subtree/bash_completion.sh new file mode 100644 index 0000000000..f2683e4494 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/files/subtree/bash_completion.sh @@ -0,0 +1,25 @@ +#!bash +# +# bash completion support for Git subtree. +# +# To use this routine: +# +# 1) Make sure you have installed and configured the core Git completion script, which is required to make this script work; +# 2) Copy this file to somewhere (e.g. ~/.git-subtree-completion.sh); +# 3) Added the following line to your .bashrc: +# source ~/.git-subtree-completion.sh +# + +_git_subtree () +{ + local cur="${COMP_WORDS[COMP_CWORD]}" + + if [ $COMP_CWORD -eq 2 ]; then + __gitcomp "add merge pull push split" + return + elif [ $COMP_CWORD -eq 3 ]; then + __gitcomp "--prefix=" + return + fi + __gitcomp "$(__git_remotes)" +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/lib/facter/git_exec_path.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/lib/facter/git_exec_path.rb new file mode 100644 index 0000000000..23d06e0b0d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/lib/facter/git_exec_path.rb @@ -0,0 +1,4 @@ +# git_exec_path.rb +Facter.add('git_exec_path') do + setcode 'git --exec-path 2>/dev/null' +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/lib/facter/git_version.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/lib/facter/git_version.rb new file mode 100644 index 0000000000..4cb71d2cce --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/lib/facter/git_version.rb @@ -0,0 +1,4 @@ +# git_version +Facter.add('git_version') do + setcode 'git --version 2>/dev/null'.sub(/git version /, '') +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/manifests/gitosis.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/manifests/gitosis.pp new file mode 100644 index 0000000000..64b7b2df3d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/manifests/gitosis.pp @@ -0,0 +1,13 @@ +# Class: gitosis +# +# This installs and configures gitosis +# +# Requires: +# - Class[git] +# +class git::gitosis { + include ::git + package {'gitosis': + ensure => present + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/manifests/init.pp new file mode 100644 index 0000000000..7e57fa23cb --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/manifests/init.pp @@ -0,0 +1,17 @@ +# Class: git +# +# This class installs git +# +# Actions: +# - Install the git package +# +# Sample Usage: +# class { 'git': } +# +class git { + if ! defined(Package['git']) { + package { 'git': + ensure => present + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/manifests/subtree.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/manifests/subtree.pp new file mode 100644 index 0000000000..6c47ca8b4d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/manifests/subtree.pp @@ -0,0 +1,43 @@ +# == Class: git::subtree +# +# Installs and configure git-subtree +# +class git::subtree { + + include ::git + + Package['git'] -> Class['git::subtree'] + + if (versioncmp('1.7.0', $::git_version) > 0) { + fail 'git-subtree requires git 1.7 or later!' + } + + if (versioncmp('1.7.11', $::git_version) > 0) { + $source_dir = '/usr/src/git-subtree' + vcsrepo { $source_dir: + ensure => present, + source => 'http://github.com/apenwarr/git-subtree.git', + provider => 'git', + revision => '2793ee6ba', + } + } else { + $source_dir = '/usr/share/doc/git-core/contrib/subtree' + } + + exec { "/usr/bin/make prefix=/usr libexecdir=${::git_exec_path}": + creates => "${source_dir}/git-subtree", + cwd => $source_dir, + } + -> + exec { "/usr/bin/make prefix=/usr libexecdir=${::git_exec_path} install": + creates => "${::git_exec_path}/git-subtree", + cwd => $source_dir, + } + + file { '/etc/bash_completion.d/git-subtree': + ensure => file, + source => 'puppet:///modules/git/subtree/bash_completion.sh', + mode => '0644', + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/spec/classes/git_subtree_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/spec/classes/git_subtree_spec.rb new file mode 100644 index 0000000000..e7a6e32539 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/spec/classes/git_subtree_spec.rb @@ -0,0 +1,70 @@ +require 'spec_helper' + +describe 'git::subtree' do + + context 'when git version < 1.7.0' do + let(:facts) { { :git_version => '1.6.0' } } + + it 'should fail' do + expect { should create_class('git::subtree') }.to raise_error(Puppet::Error, /git-subtree requires git 1.7 or later!/) + end + end + + context 'when git version > 1.7.0 and < 1.7.11' do + let(:facts) { { + :git_version => '1.7.0', + :git_exec_path => '/usr/lib/git-core', + } } + + it { should create_class('git') } + + it { should create_vcsrepo('/usr/src/git-subtree').with({ + :ensure => 'present', + :source => 'http://github.com/apenwarr/git-subtree.git', + :provider => 'git', + :revision => '2793ee6ba', + })} + + it { should create_exec('/usr/bin/make prefix=/usr libexecdir=/usr/lib/git-core').with({ + :creates => '/usr/src/git-subtree/git-subtree', + :cwd => '/usr/src/git-subtree', + })} + + it { should create_exec('/usr/bin/make prefix=/usr libexecdir=/usr/lib/git-core install').with({ + :creates => '/usr/lib/git-core/git-subtree', + :cwd => '/usr/src/git-subtree', + })} + + it { should create_file('/etc/bash_completion.d/git-subtree').with({ + :ensure => 'file', + :source => 'puppet:///modules/git/subtree/bash_completion.sh', + :mode => '0644', + })} + end + + context 'when git version >= 1.7.11' do + let(:facts) { { + :git_version => '1.7.11', + :git_exec_path => '/usr/lib/git-core', + } } + + it { should create_class('git') } + + it { should create_exec('/usr/bin/make prefix=/usr libexecdir=/usr/lib/git-core').with({ + :creates => '/usr/share/doc/git-core/contrib/subtree/git-subtree', + :cwd => '/usr/share/doc/git-core/contrib/subtree', + })} + + it { should create_exec('/usr/bin/make prefix=/usr libexecdir=/usr/lib/git-core install').with({ + :creates => '/usr/lib/git-core/git-subtree', + :cwd => '/usr/share/doc/git-core/contrib/subtree', + })} + + it { should create_file('/etc/bash_completion.d/git-subtree').with({ + :ensure => 'file', + :source => 'puppet:///modules/git/subtree/bash_completion.sh', + :mode => '0644', + })} + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/spec/spec_helper.rb new file mode 100644 index 0000000000..2c6f56649a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/tests/gitosis.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/tests/gitosis.pp new file mode 100644 index 0000000000..e6240ae21f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/tests/gitosis.pp @@ -0,0 +1 @@ +class { 'git::gitosis': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/tests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/tests/init.pp new file mode 100644 index 0000000000..c232904713 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/git/tests/init.pp @@ -0,0 +1 @@ +class { 'git': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/.fixtures.yml new file mode 100644 index 0000000000..0d21abb8c4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/.fixtures.yml @@ -0,0 +1,5 @@ +fixtures: + repositories: + stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git" + symlinks: + mailcatcher: "#{source_dir}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/.travis.yml new file mode 100644 index 0000000000..08a65c8187 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/.travis.yml @@ -0,0 +1,31 @@ +--- +branches: + only: + - master +language: ruby +bundler_args: --without development +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" +rvm: +- 1.8.7 +- 1.9.3 +- 2.0.0 +env: + matrix: + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.0.0" + - PUPPET_GEM_VERSION="~> 3.1.0" + - PUPPET_GEM_VERSION="~> 3.2.0" +matrix: + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.0.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 3.1.0" + - rvm: 1.8.7 + env: PUPPET_GEM_VERSION="~> 3.2.0" +notifications: + email: false \ No newline at end of file diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/Gemfile new file mode 100644 index 0000000000..170516d981 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/Gemfile @@ -0,0 +1,12 @@ +source 'https://rubygems.org' +puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7'] + +gem 'puppet', puppetversion + +group :test do + gem 'rake', '>= 0.9.0' + gem 'rspec', '>= 2.8.0' + gem 'rspec-puppet', '>= 0.1.1' + gem 'puppetlabs_spec_helper', '>= 0.4.1' + gem 'puppet-lint' +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/Modulefile new file mode 100644 index 0000000000..54de3a1024 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/Modulefile @@ -0,0 +1,13 @@ +name 'actionjack-mailcatcher' +version '0.1.5' +source 'https://github.com/actionjack/puppet-mailcatcher' +author 'actionjack' +license 'Apache License, Version 2.0' +summary 'Install and configure the mailcatcher application.' +description "This puppet module is used to install and configure the mailcatcher +application. +MailCatcher runs a super simple SMTP server which catches any message sent to it +to display in a web interface." +project_page 'https://github.com/actionjack/puppet-mailcatcher' + +dependency 'puppetlabs/stdlib', '>= 2.2.1' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/README.md new file mode 100644 index 0000000000..12d569a08b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/README.md @@ -0,0 +1,34 @@ +# Mailcatcher + +[](https://travis-ci.org/actionjack/puppet-mailcatcher) + +This puppet module is used to install and configure the mailcatcher application. +MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface. +http://mailcatcher.me/ + +* * * + +## Configuration + + +## Dependencies + +Current dependencies are: + + * 'puppetlabs/stdlib', '>= 2.1.0' + +## Usage + + + +```ruby +class {'mailcatcher': } +``` + +## Documentation + +This module is written in puppetdoc compliant format so details on configuration and usage can be found by executing: + +```bash +$ puppet doc manifest/init.pp +``` diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/Rakefile new file mode 100644 index 0000000000..e0e78cfbb8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/Rakefile @@ -0,0 +1,6 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send("disable_80chars") +PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/config.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/config.pp new file mode 100644 index 0000000000..c4a27921e9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/config.pp @@ -0,0 +1,18 @@ +# class mailcatcher::config +# +class mailcatcher::config { + user { 'mailcatcher': + ensure => present, + comment => 'Mailcatcher Mock Smtp Service User', + home => '/var/spool/mailcatcher', + shell => '/bin/true', + } + + file { $mailcatcher::params::log_path: + ensure => directory, + owner => 'mailcatcher', + group => 'mailcatcher', + mode => 0755, + require => User['mailcatcher'] + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/init.pp new file mode 100644 index 0000000000..31c5d3434e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/init.pp @@ -0,0 +1,64 @@ +# == Class: mailcatcher +# +# Install and configure Mailcatcher. +# MailCatcher runs a super simple SMTP server which catches any message sent to +# it to display in a web interface. +# http://mailcatcher.me/ +# +# === Parameters +# +# Document parameters here. +# +# [*smtp_ip*] +# What IP address the mailcatcher smtp service should listen on. +# The default is 127.0.0.1 +# +# [*smtp_port*] +# What TCP Port the mailcatcher smtp service should listen on. +# The default is 1025 +# +# [*http_ip*] +# What IP address the mailcatcher web mail client service should listen on. +# The default is 0.0.0.0 +# +# [*http_port*] +# What TCP Port the mailcatcher web mail client service should listen on. +# The default is 1080 +# +# [*mailcatcher_path*] +# Path to the mailcatcher program. +# The default is '/usr/local/bin' +# +# === Examples +# +# [*default*] +# +# class { mailcatcher: } +# +# [*listen on all ethernet adapters*] +# +# class { mailcatcher: +# smtp_ip => '0.0.0.0' +# } +# +# === Authors +# +# Martin Jackson +# +# === Copyright +# +# Copyright 2013 Martin Jackson, unless otherwise noted. +# +class mailcatcher ( + $smtp_ip = $mailcatcher::params::smtp_ip, + $smtp_port = $mailcatcher::params::smtp_port, + $http_ip = $mailcatcher::params::http_ip, + $http_port = $mailcatcher::params::http_port, + $mailcatcher_path = $mailcatcher::params::mailcatcher_path, + $log_path = $mailcatcher::params::log_path +) inherits mailcatcher::params { + + class {'mailcatcher::package': } -> + class {'mailcatcher::config': } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/package.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/package.pp new file mode 100644 index 0000000000..6d66fb836b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/package.pp @@ -0,0 +1,17 @@ +# class mailcatcher::package +# +class mailcatcher::package { + each( $mailcatcher::params::packages ) |$package| { + if ! defined(Package[$package]) { + package { $package: + ensure => present + } + } + } + + package { 'mailcatcher': + ensure => present, + provider => 'gem', + require => Package[$mailcatcher::params::packages] + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/params.pp new file mode 100644 index 0000000000..a21d6b07e5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/manifests/params.pp @@ -0,0 +1,22 @@ +# class mailcatcher::params +# +class mailcatcher::params { + $smtp_ip = '0.0.0.0' + $smtp_port = '1025' + $http_ip = '0.0.0.0' + $http_port = '1080' + $mailcatcher_path = '/usr/local/bin' + $log_path = '/var/log/mailcatcher' + + case $::osfamily { + 'Debian': { + $packages = ['ruby-dev', 'sqlite3', 'libsqlite3-dev', 'rubygems'] + } + 'Redhat': { + $packages = ['ruby-devel', 'sqlite', 'sqlite-devel', 'ruby-sqlite3', 'rubygems'] + } + default: { + fail("${::osfamily} is not supported.") + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/spec/classes/mailcatcher_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/spec/classes/mailcatcher_spec.rb new file mode 100644 index 0000000000..4ae17bd3b1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/spec/classes/mailcatcher_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe 'mailcatcher', :type => :class do + context "As a Web Operations Engineer" do + context 'When I install the mailcatcher base class on Ubuntu' do + let :facts do { + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu' + } + end + + describe 'by default it' do + it { should contain_package('ruby-dev') } + it { should contain_package('sqlite3') } + it { should contain_package('libsqlite3-dev') } + it { should contain_package('rubygems') } + it { should contain_package('mailcatcher').with({ 'provider' => 'gem'}) } + it { should contain_user('mailcatcher') } + it 'should contain a properly formatted start up configuration for upstart' do + should contain_file('/etc/init/mailcatcher.conf').with_content(/exec\s+nohup\s+\/usr\/local\/bin\/mailcatcher\s+--http-ip\s+0\.0\.0\.0\s+--http-port\s+1080\s+--smtp-ip\s+0\.0\.0\.0\s+--smtp-port\s+1025\s+-f/) + end + it { should contain_file('/etc/init/mailcatcher.conf').with({ :notify => 'Class[Mailcatcher::Service]'})} + it { should contain_file('/var/log/mailcatcher').with({ + :ensure => 'directory', + :owner => 'mailcatcher', + :group => 'mailcatcher', + :mode => '0755', + :require => 'User[mailcatcher]' + })} + it { should contain_service('mailcatcher').with({ + :ensure => 'running', + :provider => 'upstart', + :hasstatus => true, + :hasrestart => true, + :require => 'Class[Mailcatcher::Config]', + })} + + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/spec/spec_helper.rb new file mode 100644 index 0000000000..3d92005247 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' \ No newline at end of file diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/templates/etc/init/mailcatcher.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/templates/etc/init/mailcatcher.conf.erb new file mode 100644 index 0000000000..4cd663ffe5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/templates/etc/init/mailcatcher.conf.erb @@ -0,0 +1,16 @@ +# mailcatcher - mock smtp server +# +# mailCatcher runs a super simple SMTP server which catches any +# message sent to it to display in a web interface. + +description "mock smtp server" + +start on startup +stop on shutdown + +setuid mailcatcher +setgid mailcatcher + +script + exec nohup <%= @mailcatcher_path %>/mailcatcher<%= @options.join(' ') %> -f >> /var/log/mailcatcher/mailcatcher.log 2>&1 +end script diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/tests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/tests/init.pp new file mode 100644 index 0000000000..adead2832a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mailcatcher/tests/init.pp @@ -0,0 +1,12 @@ +# The baseline for module testing used by Puppet Labs is that each manifest +# should have a corresponding test manifest that declares that class or defined +# type. +# +# Tests are then run by using puppet apply --noop (to check for compilation +# errors and view a log of events) or by fully applying the test in a virtual +# environment (to compare the resulting system state to the desired state). +# +# Learn more about module testing here: +# http://docs.puppetlabs.com/guides/tests_smoke.html +# +include mailcatcher diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/.fixtures.yml new file mode 100644 index 0000000000..e48e20aaee --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/.fixtures.yml @@ -0,0 +1,6 @@ +fixtures: + repositories: + "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" + "apt": "git://github.com/puppetlabs/puppetlabs-apt.git" + symlinks: + "mongodb": "#{source_dir}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/.nodeset.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/.nodeset.yml new file mode 100644 index 0000000000..767f9cd2f6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/.nodeset.yml @@ -0,0 +1,31 @@ +--- +default_set: 'centos-64-x64' +sets: + 'centos-59-x64': + nodes: + "main.foo.vm": + prefab: 'centos-59-x64' + 'centos-64-x64': + nodes: + "main.foo.vm": + prefab: 'centos-64-x64' + 'fedora-18-x64': + nodes: + "main.foo.vm": + prefab: 'fedora-18-x64' + 'debian-607-x64': + nodes: + "main.foo.vm": + prefab: 'debian-607-x64' + 'debian-70rc1-x64': + nodes: + "main.foo.vm": + prefab: 'debian-70rc1-x64' + 'ubuntu-server-10044-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-10044-x64' + 'ubuntu-server-12042-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-12042-x64' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/.travis.yml new file mode 100644 index 0000000000..f6eff1ce96 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/.travis.yml @@ -0,0 +1,33 @@ +branches: + only: + - master +language: ruby +before_install: + - gem update bundler + - bundle --version + - gem update --system 2.1.11 + - gem --version +bundler_args: --without development +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" +after_success: + - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release + - .forge-release/publish +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 +env: + matrix: + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.3.0" + global: + - PUBLISHER_LOGIN=puppetlabs + - secure: "iUYpjvk33JffZB9lVRqjuwRWesvcvmTknh908xnf60rUOA0QbGEPXxQY+LsQJEIimVsMA22fV6vp9BcqMEjO7OfK2MvAWsEWU/lG+kisFqhWDRf96sADE7k/RvPWJeB2xe+lWXK7Eh26jgctNfk4NptX1X1MjGmdzEvH7Aq79/w=" +matrix: + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" +notifications: + email: false diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/CHANGELOG b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/CHANGELOG new file mode 100644 index 0000000000..92a220f481 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/CHANGELOG @@ -0,0 +1,74 @@ +##2014-05-27 - Release 0.8.0 + +This feature features a rewritten mongodb_replset{} provider, includes several +important bugfixes, ruby 1.8 support, and two new features. + +####Features +- Rewritten mongodb_replset{}, featuring puppet resource support, prefetching, +and flushing. +- Add Ruby 1.8 compatibility. +- Adds `syslog`, allowing you to configure mongodb to send all logging to the hosts syslog. +- Add mongodb::replset, a wrapper class for hiera users. +- Improved testing! + +####Bugfixes +- Fixes the package names to work since 10gen renamed them again. +- Fix provider name in the README. +- Disallow `nojournal` and `journal` to be set at the same time. +- Changed - to = for versioned install on Ubuntu. + +####Known Bugs +* No known bugs + +2014-1-29 - Version 0.7.0 + +Summary: + +Added Replica Set Type and Provider + +2014-1-17 - Version 0.6.0 + +Summary: + +Added support for installing MongoDB client on +RHEL family systems. + +2014-01-10 Version 0.5.0 + +Summary: + +Added types for providers for Mongo users and databases. + +2013-12 Version 0.4.0 + +Major refactoring of the MongoDB module. Includes a new 'mongodb::globals' +that consolidates many shared parameters into one location. This is an +API-breaking release in anticipation of a 1.0 release. + +2013-10-31 - Version 0.3.0 + +Summary: + +Adds a number of parameters and fixes some platform +specific bugs in module deployment. + +2013-09-25 - Version 0.2.0 + +Summary: + +This release fixes a duplicate parameter. + +Fixes: +- Fix a duplicated parameter. + +2012-07-13 Puppet Labs - 0.1.0 +* Add support for RHEL/CentOS +* Change default mongodb install location to OS repo + +2012-05-29 Puppet Labs - 0.0.2 +* Fix Modulefile typo. +* Remove repo pin. +* Update spec tests and add travis support. + +2012-05-03 Puppet Labs - 0.0.1 +* Initial Release. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/Gemfile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/Gemfile new file mode 100644 index 0000000000..39abe867d4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/Gemfile @@ -0,0 +1,19 @@ +source ENV['GEM_SOURCE'] || 'https://rubygems.org' + +group :test, :development do + gem 'rspec-puppet', :require => false + gem 'rake', :require => false + gem 'puppetlabs_spec_helper', :require => false + gem 'serverspec', :require => false + gem 'puppet-lint', :require => false + gem 'pry', :require => false + gem 'simplecov', :require => false + gem 'beaker', :require => false + gem 'beaker-rspec', :require => false +end + +if puppetversion = ENV['PUPPET_VERSION'] + gem 'puppet', puppetversion, :require => false +else + gem 'puppet', :require => false +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/LICENSE b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/LICENSE new file mode 100644 index 0000000000..8961ce8a6d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/LICENSE @@ -0,0 +1,15 @@ +Copyright (C) 2012 Puppet Labs Inc + +Puppet Labs can be contacted at: info@puppetlabs.com + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/Modulefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/Modulefile new file mode 100644 index 0000000000..e2eb82771a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/Modulefile @@ -0,0 +1,12 @@ +name 'puppetlabs-mongodb' +version '0.8.0' +source 'git@github.com:puppetlabs/puppetlabs-mongodb.git' +author 'puppetlabs' +license 'Apache License Version 2.0' +summary 'mongodb puppet module' +description '10gen mongodb puppet module' +project_page 'https://github.com/puppetlabs/puppetlabs-mongodb' + +## Add dependencies, if any: +dependency 'puppetlabs/apt', '>= 1.0.0' +dependency 'puppetlabs/stdlib', '>= 2.2.0' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/README.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/README.md new file mode 100644 index 0000000000..2bc16bb348 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/README.md @@ -0,0 +1,515 @@ +# mongodb puppet module + +[](https://travis-ci.org/puppetlabs/puppetlabs-mongodb) + +####Table of Contents + +1. [Overview] (#overview) +2. [Module Description - What does the module do?](#module-description) +3. [Setup - The basics of getting started with mongodb](#setup) +4. [Usage - Configuration options and additional functionality](#usage) +5. [Reference - An under-the-hood peek at what the module is doing and how](#reference) +6. [Limitations - OS compatibility, etc.] (#limitations) +7. [Development - Guide for contributing to the module] (#development) + +## Overview + +Installs MongoDB on RHEL/Ubuntu/Debian from OS repo, or alternatively from +10gen repository [installation documentation](http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages). + +### Deprecation Warning ### + +This release is a major refactoring of the module which means that the API may +have changed in backwards incompatible ways. If your project depends on the old API, +please pin your dependencies to 0.3 version to ensure your environments don't break. + +The current module design is undergoing review for potential 1.0 release. We welcome +any feedback with regard to the APIs and patterns used in this release. + +##Module Description + +The MongoDB module manages mongod server installation and configuration of the +mongod daemon. For the time being it supports only a single MongoDB server +instance, without sharding functionality. + +For the 0.5 release, the MongoDB module now supports database and user types. + +For the 0.6 release, the MongoDB module now supports basic replicaset features +(initiating a replicaset and adding members, but without specific options). + +## Setup + +###What MongoDB affects + +* MongoDB package. +* MongoDB configuration files. +* MongoDB service. +* MongoDB client. +* 10gen/mongodb apt/yum repository. + +###Beginning with MongoDB + +If you just want a server installation with the default options you can run +`include '::mongodb::server'`. If you need to customize configuration +options you need to do the following: + +```puppet +class {'::mongodb::server': + port => 27018, + verbose => true, +} +``` + +For Red Hat family systems, the client can be installed in a similar fashion: + +``` +puppet class {'::mongodb::client':} +``` + +Note that for Debian/Ubuntu family systems the client is installed with the +server. Using the client class will by default install the server. + +Although most distros come with a prepacked MongoDB server we recommend to +use the 10gen/MongoDB software repository, because most of the current OS +packages are outdated and not appropriate for a production environment. +To install MongoDB from 10gen repository: + +```puppet +class {'::mongodb::globals': + manage_package_repo => true, +}-> +class {'::mongodb::server': }-> +class {'::mongodb::client': } +``` + +## Usage + +Most of the interaction for the server is done via `mongodb::server`. For +more options please have a look at [mongodb::server](#class-mongodbserver). +Also in this version we introduced `mongodb::globals`, which is meant more +for future implementation, where you can configure the main settings for +this module in a global way, to be used by other classes and defined resources. +On its own it does nothing. + +### Create MongoDB database + +To install MongoDB server, create database "testdb" and user "user1" with password "pass1". + +```puppet +class {'::mongodb::server': + auth => true, +} + +mongodb::db { 'testdb': + user => 'user1', + password_hash => 'a15fbfca5e3a758be80ceaf42458bcd8', +} +``` +Parameter 'password_hash' is hex encoded md5 hash of "user1:mongo:pass1". +Unsafe plain text password could be used with 'password' parameter instead of 'password_hash'. + +## Reference + +### Classes + +####Public classes +* `mongodb::server`: Installs and configure MongoDB +* `mongodb::client`: Installs the MongoDB client shell (for Red Hat family systems) +* `mongodb::globals`: Configure main settings in a global way + +####Private classes +* `mongodb::repo`: Manage 10gen/MongoDB software repository +* `mongodb::repo::apt`: Manage Debian/Ubuntu apt 10gen/MongoDB repository +* `mongodb::repo::yum`: Manage Redhat/CentOS apt 10gen/MongoDB repository +* `mongodb::server::config`: Configures MongoDB configuration files +* `mongodb::server::install`: Install MongoDB software packages +* `mongodb::server::service`: Manages service +* `mongodb::client::install`: Installs the MongoDB client software package + +####Class: mongodb::globals +*Note:* most server specific defaults should be overridden in the `mongodb::server` +class. This class should only be used if you are using a non-standard OS or +if you are changing elements such as `version` or `manage_package_repo` that +can only be changed here. + +This class allows you to configure the main settings for this module in a +global way, to be used by the other classes and defined resources. On its +own it does nothing. + +#####`server_package_name` +This setting can be used to override the default MongoDB server package +name. If not specified, the module will use whatever package name is the +default for your OS distro. + +#####`service_name` +This setting can be used to override the default MongoDB service name. If not +specified, the module will use whatever service name is the default for your OS distro. + +#####`service_provider` +This setting can be used to override the default MongoDB service provider. If +not specified, the module will use whatever service provider is the default for +your OS distro. + +#####`service_status` +This setting can be used to override the default status check command for +your MongoDB service. If not specified, the module will use whatever service +name is the default for your OS distro. + +#####`user` +This setting can be used to override the default MongoDB user and owner of the +service and related files in the file system. If not specified, the module will +use the default for your OS distro. + +#####`group` +This setting can be used to override the default MongoDB user group to be used +for related files in the file system. If not specified, the module will use +the default for your OS distro. + +#####`bind_ip` +This setting can be used to configure MonogDB process to bind to and listen +for connections from applications on this address. If not specified, the +module will use the default for your OS distro. +*Note:* This value should be passed as an array. + +#####`version` +The version of MonogDB to install/manage. This is a simple way of providing +a specific version such as '2.2' or '2.4' for example. If not specified, +the module will use the default for your OS distro. + +####Class: mongodb::server + +Most of the parameters manipulate the mongod.conf file. + +For more details about configuration parameters consult the +[MongoDB Configuration File Options](http://docs.mongodb.org/manual/reference/configuration-options/). + +#####`ensure` +Used to ensure that the package is installed and the service is running, or that the package is absent/purged and the service is stopped. Valid values are true/false/present/absent/purged. + +#####`config` +Path of the config file. If not specified, the module will use the default +for your OS distro. + +#####`dbpath` +Set this value to designate a directory for the mongod instance to store +it's data. If not specified, the module will use the default for your OS distro. + +#####`pidfilepath` +Specify a file location to hold the PID or process ID of the mongod process. +If not specified, the module will use the default for your OS distro. + +#####`logpath` +Specify the path to a file name for the log file that will hold all diagnostic +logging information. Unless specified, mongod will output all log information +to the standard output. + +#####`bind_ip` +Set this option to configure the mongod or mongos process to bind to and listen +for connections from applications on this address. If not specified, the module +will use the default for your OS distro. Example: bind_ip=['127.0.0.1', '192.168.0.3'] +*Note*: bind_ip accepts an array as a value. + +#####`logappend` +Set to true to add new entries to the end of the logfile rather than overwriting +the content of the log when the process restarts. Default: True + +#####`fork` +Set to true to fork server process at launch time. The default setting depends on +the operating system. + +#####`port` +Specifies a TCP port for the server instance to listen for client connections. +Default: 27017 + +#####`journal` +Set to true to enable operation journaling to ensure write durability and +data consistency. Default: on 64-bit systems true and on 32-bit systems false + +#####`nojournal` +Set nojournal = true to disable durability journaling. By default, mongod +enables journaling in 64-bit versions after v2.0. +Default: on 64-bit systems false and on 32-bit systems true + +*Note*: You must use journal to enable journaling on 32-bit systems. + +#####`smallfiles` +Set to true to modify MongoDB to use a smaller default data file size. +Specifically, smallfiles reduces the initial size for data files and +limits them to 512 megabytes. Default: false + +#####`cpu` +Set to true to force mongod to report every four seconds CPU utilization +and the amount of time that the processor waits for I/O operations to +complete (i.e. I/O wait.) Default: false + +#####`auth` +Set to true to enable database authentication for users connecting from +remote hosts. If no users exist, the localhost interface will continue +to have access to the database until you create the first user. +Default: false + +#####`noauth` +Disable authentication. Currently the default. Exists for future compatibility + and clarity. + +#####`verbose` +Increases the amount of internal reporting returned on standard output or in +the log file generated by `logpath`. Default: false + +#####`verbositylevel` +MongoDB has the following levels of verbosity: v, vv, vvv, vvvv and vvvvv. +Default: None + +#####`objcheck` +Forces the mongod to validate all requests from clients upon receipt to ensure +that clients never insert invalid documents into the database. +Default: on v2.4 default to true and on earlier version to false + +#####`quota` +Set to true to enable a maximum limit for the number of data files each database +can have. The default quota is 8 data files, when quota is true. Default: false + +#####`quotafiles` +Modify limit on the number of data files per database. This option requires the +`quota` setting. Default: 8 + +#####`diaglog` +Creates a very verbose diagnostic log for troubleshooting and recording various +errors. Valid values: 0, 1, 2, 3 and 7. +For more information please refer to [MongoDB Configuration File Options](http://docs.mongodb.org/manual/reference/configuration-options/). + +#####`directoryperdb` +Set to true to modify the storage pattern of the data directory to store each +database’s files in a distinct folder. Default: false + +#####`profile` +Modify this value to changes the level of database profiling, which inserts +information about operation performance into output of mongod or the +log file if specified by `logpath`. + +#####`maxconns` +Specifies a value to set the maximum number of simultaneous connections +that MongoDB will accept. Default: depends on system (i.e. ulimit and file descriptor) +limits. Unless set, MongoDB will not limit its own connections. + +#####`oplog_size` +Specifies a maximum size in megabytes for the replication operation log +(e.g. oplog.) mongod creates an oplog based on the maximum amount of space +available. For 64-bit systems, the oplog is typically 5% of available disk space. + +#####`nohints` +Ignore query hints. Default: None + +#####`nohttpinterface` +Set to true to disable the HTTP interface. This command will override the rest +and disable the HTTP interface if you specify both. Default: false + +#####`noscripting` +Set noscripting = true to disable the scripting engine. Default: false + +#####`notablescan` +Set notablescan = true to forbid operations that require a table scan. Default: false + +#####`noprealloc` +Set noprealloc = true to disable the preallocation of data files. This will shorten +the start up time in some cases, but can cause significant performance penalties +during normal operations. Default: false + +#####`nssize` +Use this setting to control the default size for all newly created namespace +files (i.e .ns). Default: 16 + +#####`mms_token` +MMS token for mms monitoring. Default: None + +#####`mms_name` +MMS identifier for mms monitoring. Default: None + +#####`mms_interval` +MMS interval for mms monitoring. Default: None + +#####`replset` +Use this setting to configure replication with replica sets. Specify a replica +set name as an argument to this set. All hosts must have the same set name. + +#####`rest` +Set to true to enable a simple REST interface. Default: false + +#####`slowms` +Sets the threshold for mongod to consider a query “slow” for the database profiler. +Default: 100 ms + +#####`keyfile` +Specify the path to a key file to store authentication information. This option +is only useful for the connection between replica set members. Default: None + +#####`master` +Set to true to configure the current instance to act as master instance in a +replication configuration. Default: False *Note*: deprecated – use replica sets + +#####`set_parameter` +Specify extra configuration file parameters (i.e. +textSearchEnabled=true). Default: None + +#####`syslog` +Sends all logging output to the host’s syslog system rather than to standard +output or a log file. Default: None +*Important*: You cannot use syslog with logpath. + +#####`slave` +Set to true to configure the current instance to act as slave instance in a +replication configuration. Default: false +*Note*: deprecated – use replica sets + +#####`only` +Used with the slave option, only specifies only a single database to +replicate. Default: <> +*Note*: deprecated – use replica sets + +#####`source` +Used with the slave setting to specify the master instance from which +this slave instance will replicate. Default: <> +*Note*: deprecated – use replica sets + +### Definitions + +#### Definition: mongodb:db + +Creates database with user. Resource title used as database name. + +#####`user` +Name of the user for database + +#####`password_hash` +Hex encoded md5 hash of "$username:mongo:$password". +For more information please refer to [MongoDB Authentication Process](http://docs.mongodb.org/meta-driver/latest/legacy/implement-authentication-in-driver/#authentication-process). + +#####`password` +Plain-text user password (will be hashed) + +#####`roles` +Array with user roles. Default: ['dbAdmin'] + +### Providers + +#### Provider: mongodb_database +'mongodb_database' can be used to create and manage databases within MongoDB. + +```puppet +mongodb_database { testdb: + ensure => present, + tries => 10, + require => Class['mongodb::server'], +} +``` +#####`tries` +The maximum amount of two second tries to wait MongoDB startup. Default: 10 + + +#### Provider: mongodb_user +'mongodb_user' can be used to create and manage users within MongoDB database. + +```puppet +mongodb_user { testuser: + ensure => present, + password_hash => mongodb_password('testuser', 'p@ssw0rd'), + database => testdb, + roles => ['readWrite', 'dbAdmin'], + tries => 10, + require => Class['mongodb::server'], +} +``` +#####`password_hash` +Hex encoded md5 hash of "$username:mongo:$password". + +#####`database` +Name of database. It will be created, if not exists. + +#####`roles` +Array with user roles. Default: ['dbAdmin'] + +#####`tries` +The maximum amount of two second tries to wait MongoDB startup. Default: 10 + +#### Provider: mongodb_replset +'mongodb_replset' can be used to create and manage MongoDB replicasets. + +```puppet +mongodb_replset { rsmain: + ensure => present, + members => ['host1:27017', 'host2:27017', 'host3:27017'] +} +``` + +Ideally the ```mongodb_replset``` resource will be declared on the initial +desired primary node (arbitrarily the first of the list) and this node will be +processed once the secondary nodes are up. This will ensure all the nodes are +in the first configuration of the replicaset, else it will require running +puppet again to add them. + +#####`members` +Array of 'host:port' of the replicaset members. + +It currently only adds members without options. + +## Limitation + +This module has been tested on: + +* Debian 7.* (Wheezy) +* Debian 6.* (squeeze) +* Ubuntu 12.04.2 (precise) +* Ubuntu 10.04.4 LTS (lucid) +* RHEL 5/6 +* CentOS 5/6 + +For a full list of tested operating systems please have a look at the [.nodeset.xml](https://github.com/puppetlabs/puppetlabs-mongodb/blob/master/.nodeset.yml) definition. + +This module should support `service_ensure` separate from the `ensure` value on `Class[mongodb::server]` but it does not yet. + +## Development + +Puppet Labs modules on the Puppet Forge are open projects, and community +contributions are essential for keeping them great. We can’t access the +huge number of platforms and myriad of hardware, software, and deployment +configurations that Puppet is intended to serve. + +We want to keep it as easy as possible to contribute changes so that our +modules work in your environment. There are a few guidelines that we need +contributors to follow so that we can have a chance of keeping on top of things. + +You can read the complete module contribution guide [on the Puppet Labs wiki.](http://projects.puppetlabs.com/projects/module-site/wiki/Module_contributing) + +### Testing + +There are two types of tests distributed with this module. Unit tests with +rspec-puppet and system tests using rspec-system. + + +unit tests should be run under Bundler with the gem versions as specified +in the Gemfile. To install the necessary gems: + + bundle install --path=vendor + +Test setup and teardown is handled with rake tasks, so the +supported way of running tests is with + + bundle exec rake spec + + +For system test you will also need to install vagrant > 1.3.x and virtualbox > 4.2.10. +To run the system tests + + bundle exec rake spec:system + +To run the tests on different operating systems, see the sets available in [.nodeset.xml](https://github.com/puppetlabs/puppetlabs-mongodb/blob/master/.nodeset.yml) +and run the specific set with the following syntax: + + RSPEC_SET=ubuntu-server-12042-x64 bundle exec rake spec:system + +### Authors + +We would like to thank everyone who has contributed issues and pull requests to this module. +A complete list of contributors can be found on the +[GitHub Contributor Graph](https://github.com/puppetlabs/puppetlabs-mongodb/graphs/contributors) +for the [puppetlabs-mongodb module](https://github.com/puppetlabs/puppetlabs-mongodb). diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/Rakefile b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/Rakefile new file mode 100644 index 0000000000..cd3d379958 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/Rakefile @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/rake_tasks' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/parser/functions/mongodb_password.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/parser/functions/mongodb_password.rb new file mode 100644 index 0000000000..e61bcb9dae --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/parser/functions/mongodb_password.rb @@ -0,0 +1,14 @@ +require 'digest/md5' + +module Puppet::Parser::Functions + newfunction(:mongodb_password, :type => :rvalue, :doc => <<-EOS + Returns the mongodb password hash from the clear text password. + EOS + ) do |args| + + raise(Puppet::ParseError, 'mongodb_password(): Wrong number of arguments ' + + "given (#{args.size} for 2)") if args.size != 2 + + Digest::MD5.hexdigest("#{args[0]}:mongo:#{args[1]}") + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/provider/mongodb_database/mongodb.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/provider/mongodb_database/mongodb.rb new file mode 100644 index 0000000000..0acc76996c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/provider/mongodb_database/mongodb.rb @@ -0,0 +1,36 @@ +Puppet::Type.type(:mongodb_database).provide(:mongodb) do + + desc "Manages MongoDB database." + + defaultfor :kernel => 'Linux' + + commands :mongo => 'mongo' + + def block_until_mongodb(tries = 10) + begin + mongo('--quiet', '--eval', 'db.getMongo()') + rescue => e + debug('MongoDB server not ready, retrying') + sleep 2 + if (tries -= 1) > 0 + retry + else + raise e + end + end + end + + def create + mongo(@resource[:name], '--quiet', '--eval', "db.dummyData.insert({\"created_by_puppet\": 1})") + end + + def destroy + mongo(@resource[:name], '--quiet', '--eval', 'db.dropDatabase()') + end + + def exists? + block_until_mongodb(@resource[:tries]) + mongo("--quiet", "--eval", 'db.getMongo().getDBNames()').split(",").include?(@resource[:name]) + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/provider/mongodb_replset/mongo.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/provider/mongodb_replset/mongo.rb new file mode 100644 index 0000000000..d77afe3036 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/provider/mongodb_replset/mongo.rb @@ -0,0 +1,232 @@ +# +# Author: François Charlier +# + +Puppet::Type.type(:mongodb_replset).provide(:mongo) do + + desc "Manage hosts members for a replicaset." + + confine :true => + begin + require 'json' + true + rescue LoadError + false + end + + commands :mongo => 'mongo' + + mk_resource_methods + + def initialize(resource={}) + super(resource) + @property_flush = {} + end + + def members=(hosts) + @property_flush[:members] = hosts + end + + def self.instances + instance = get_replset_properties + if instance + # There can only be one replset per node + [new(instance)] + else + [] + end + end + + def self.prefetch(resources) + instances.each do |prov| + if resource = resources[prov.name] + resource.provider = prov + end + end + end + + def exists? + @property_hash[:ensure] == :present + end + + def create + @property_flush[:ensure] = :present + @property_flush[:members] = resource.should(:members) + end + + def destroy + @property_flush[:ensure] = :absent + end + + def flush + set_members + @property_hash = self.class.get_replset_properties + end + + private + + def db_ismaster(host) + mongo_command("db.isMaster()", host) + end + + def rs_initiate(conf, master) + return mongo_command("rs.initiate(#{conf})", master) + end + + def rs_status(host) + mongo_command("rs.status()", host) + end + + def rs_add(host, master) + mongo_command("rs.add(\"#{host}\")", master) + end + + def rs_remove(host, master) + mongo_command("rs.remove(\"#{host}\")", master) + end + + def master_host(hosts) + hosts.each do |host| + status = db_ismaster(host) + if status.has_key?('primary') + return status['primary'] + end + end + false + end + + def self.get_replset_properties + output = mongo_command('rs.conf()') + if output['members'] + members = output['members'].collect do |val| + val['host'] + end + props = { + :name => output['_id'], + :ensure => :present, + :members => members, + :provider => :mongo, + } + else + props = nil + end + Puppet.debug("MongoDB replset properties: #{props.inspect}") + props + end + + def alive_members(hosts) + hosts.select do |host| + begin + Puppet.debug "Checking replicaset member #{host} ..." + status = rs_status(host) + if status.has_key?('errmsg') and status['errmsg'] == 'not running with --replSet' + raise Puppet::Error, "Can't configure replicaset #{self.name}, host #{host} is not supposed to be part of a replicaset." + end + if status.has_key?('set') + if status['set'] != self.name + raise Puppet::Error, "Can't configure replicaset #{self.name}, host #{host} is already part of another replicaset." + end + + # This node is alive and supposed to be a member of our set + Puppet.debug "Host #{self.name} is available for replset #{status['set']}" + true + elsif status.has_key?('info') + Puppet.debug "Host #{self.name} is alive but unconfigured: #{status['info']}" + true + end + rescue Puppet::ExecutionFailure + Puppet.warning "Can't connect to replicaset member #{host}." + + false + end + end + end + + def set_members + if @property_flush[:ensure] == :absent + # TODO: I don't know how to remove a node from a replset; unimplemented + #Puppet.debug "Removing all members from replset #{self.name}" + #@property_hash[:members].collect do |member| + # rs_remove(member, master_host(@property_hash[:members])) + #end + return + end + + if ! @property_flush[:members].empty? + # Find the alive members so we don't try to add dead members to the replset + alive_hosts = alive_members(@property_flush[:members]) + dead_hosts = @property_flush[:members] - alive_hosts + raise Puppet::Error, "Can't connect to any member of replicaset #{self.name}." if alive_hosts.empty? + Puppet.debug "Alive members: #{alive_hosts.inspect}" + Puppet.debug "Dead members: #{dead_hosts.inspect}" unless dead_hosts.empty? + else + alive_hosts = [] + end + + if @property_flush[:ensure] == :present and @property_hash[:ensure] != :present + Puppet.debug "Initializing the replset #{self.name}" + + # Create a replset configuration + hostconf = alive_hosts.each_with_index.map do |host,id| + "{ _id: #{id}, host: \"#{host}\" }" + end.join(',') + conf = "{ _id: \"#{self.name}\", members: [ #{hostconf} ] }" + + # Set replset members with the first host as the master + output = rs_initiate(conf, alive_hosts[0]) + if output['ok'] == 0 + raise Puppet::Error, "rs.initiate() failed for replicaset #{self.name}: #{output['errmsg']}" + end + else + # Add members to an existing replset + if master = master_host(alive_hosts) + current_hosts = db_ismaster(master)['hosts'] + newhosts = alive_hosts - current_hosts + newhosts.each do |host| + output = rs_add(host, master) + if output['ok'] == 0 + raise Puppet::Error, "rs.add() failed to add host to replicaset #{self.name}: #{output['errmsg']}" + end + end + else + raise Puppet::Error, "Can't find master host for replicaset #{self.name}." + end + end + end + + def mongo_command(command, host, retries=4) + self.class.mongo_command(command,host,retries) + end + + def self.mongo_command(command, host=nil, retries=4) + # Allow waiting for mongod to become ready + # Wait for 2 seconds initially and double the delay at each retry + wait = 2 + begin + args = Array.new + args << '--quiet' + args << ['--host',host] if host + args << ['--eval',"printjson(#{command})"] + output = mongo(args.flatten) + rescue Puppet::ExecutionFailure => e + if e =~ /Error: couldn't connect to server/ and wait <= 2**max_wait + info("Waiting #{wait} seconds for mongod to become available") + sleep wait + wait *= 2 + retry + else + raise + end + end + + # Dirty hack to remove JavaScript objects + output.gsub!(/ISODate\((.+?)\)/, '\1 ') + output.gsub!(/Timestamp\((.+?)\)/, '[\1]') + + #Hack to avoid non-json empty sets + output = "{}" if output == "null\n" + + JSON.parse(output) + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/provider/mongodb_user/mongodb.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/provider/mongodb_user/mongodb.rb new file mode 100644 index 0000000000..10e0bf7f07 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/provider/mongodb_user/mongodb.rb @@ -0,0 +1,48 @@ +Puppet::Type.type(:mongodb_user).provide(:mongodb) do + + desc "Manage users for a MongoDB database." + + defaultfor :kernel => 'Linux' + + commands :mongo => 'mongo' + + def block_until_mongodb(tries = 10) + begin + mongo('--quiet', '--eval', 'db.getMongo()') + rescue + debug('MongoDB server not ready, retrying') + sleep 2 + retry unless (tries -= 1) <= 0 + end + end + + def create + mongo(@resource[:database], '--eval', "db.system.users.insert({user:\"#{@resource[:name]}\", pwd:\"#{@resource[:password_hash]}\", roles: #{@resource[:roles].inspect}})") + end + + def destroy + mongo(@resource[:database], '--quiet', '--eval', "db.removeUser(\"#{@resource[:name]}\")") + end + + def exists? + block_until_mongodb(@resource[:tries]) + mongo(@resource[:database], '--quiet', '--eval', "db.system.users.find({user:\"#{@resource[:name]}\"}).count()").strip.eql?('1') + end + + def password_hash + mongo(@resource[:database], '--quiet', '--eval', "db.system.users.findOne({user:\"#{@resource[:name]}\"})[\"pwd\"]").strip + end + + def password_hash=(value) + mongo(@resource[:database], '--quiet', '--eval', "db.system.users.update({user:\"#{@resource[:name]}\"}, { $set: {pwd:\"#{value}\"}})") + end + + def roles + mongo(@resource[:database], '--quiet', '--eval', "db.system.users.findOne({user:\"#{@resource[:name]}\"})[\"roles\"]").strip.split(",").sort + end + + def roles=(value) + mongo(@resource[:database], '--quiet', '--eval', "db.system.users.update({user:\"#{@resource[:name]}\"}, { $set: {roles: #{@resource[:roles].inspect}}})") + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/type/mongodb_database.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/type/mongodb_database.rb new file mode 100644 index 0000000000..45c0f8fa23 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/type/mongodb_database.rb @@ -0,0 +1,27 @@ +Puppet::Type.newtype(:mongodb_database) do + @doc = "Manage MongoDB databases." + + ensurable + + newparam(:name, :namevar=>true) do + desc "The name of the database." + newvalues(/^\w+$/) + end + + newparam(:tries) do + desc "The maximum amount of two second tries to wait MongoDB startup." + defaultto 10 + newvalues(/^\d+$/) + munge do |value| + Integer(value) + end + end + + autorequire(:package) do + 'mongodb' + end + + autorequire(:service) do + 'mongodb' + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/type/mongodb_replset.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/type/mongodb_replset.rb new file mode 100644 index 0000000000..8115ef034e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/type/mongodb_replset.rb @@ -0,0 +1,35 @@ +# +# Author: François Charlier +# + +Puppet::Type.newtype(:mongodb_replset) do + @doc = "Manage a MongoDB replicaSet" + + ensurable do + defaultto :present + + newvalue(:present) do + provider.create + end + end + + newparam(:name) do + desc "The name of the replicaSet" + end + + newproperty(:members, :array_matching => :all) do + desc "The replicaSet members" + + def insync?(is) + is.sort == should.sort + end + end + + autorequire(:package) do + 'mongodb' + end + + autorequire(:service) do + 'mongodb' + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/type/mongodb_user.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/type/mongodb_user.rb new file mode 100644 index 0000000000..7f7e97b843 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/lib/puppet/type/mongodb_user.rb @@ -0,0 +1,63 @@ +Puppet::Type.newtype(:mongodb_user) do + @doc = 'Manage a MongoDB user. This includes management of users password as well as privileges.' + + ensurable + + def initialize(*args) + super + # Sort roles array before comparison. + self[:roles] = Array(self[:roles]).sort! + end + + newparam(:name, :namevar=>true) do + desc "The name of the user." + end + + newparam(:database) do + desc "The user's target database." + defaultto do + fail("Parameter 'database' must be set") + end + newvalues(/^\w+$/) + end + + newparam(:tries) do + desc "The maximum amount of two second tries to wait MongoDB startup." + defaultto 10 + newvalues(/^\d+$/) + munge do |value| + Integer(value) + end + end + + newproperty(:roles, :array_matching => :all) do + desc "The user's roles." + defaultto ['dbAdmin'] + newvalue(/^\w+$/) + + # Pretty output for arrays. + def should_to_s(value) + value.inspect + end + + def is_to_s(value) + value.inspect + end + end + + newproperty(:password_hash) do + desc "The password hash of the user. Use mongodb_password() for creating hash." + defaultto do + fail("Property 'password_hash' must be set. Use mongodb_password() for creating hash.") + end + newvalue(/^\w+$/) + end + + autorequire(:package) do + 'mongodb' + end + + autorequire(:service) do + 'mongodb' + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/client.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/client.pp new file mode 100644 index 0000000000..de1b339c7d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/client.pp @@ -0,0 +1,26 @@ +# Class for installing a MongoDB client shell (CLI). +# +# == Parameters +# +# [ensure] Desired ensure state of the package. Optional. +# Defaults to 'true' +# +# [package_name] Name of the package to install the client from. Default +# is repository dependent. +# +class mongodb::client ( + $ensure = $mongodb::params::ensure_client, + $package_name = $mongodb::params::client_package_name, +) inherits mongodb::params { + case $::osfamily { + 'RedHat', 'Linux': { + class { 'mongodb::client::install': } + } + 'Debian': { + warning ('Debian client is included by default with server. Please use ::mongodb::server to install the mongo client for Debian family systems.') + } + default: { + # no action taken, failure happens in params.pp + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/client/install.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/client/install.pp new file mode 100644 index 0000000000..6da26003ba --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/client/install.pp @@ -0,0 +1,26 @@ +# PRIVATE CLASS: do not call directly +class mongodb::client::install { + $package_ensure = $mongodb::client::ensure + $package_name = $mongodb::client::package_name + + case $package_ensure { + true: { + $my_package_ensure = 'present' + } + false: { + $my_package_ensure = 'purged' + } + 'absent': { + $my_package_ensure = 'purged' + } + default: { + $my_package_ensure = $package_ensure + } + } + + package { 'mongodb_client': + ensure => $my_package_ensure, + name => $package_name, + tag => 'mongodb', + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/db.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/db.pp new file mode 100644 index 0000000000..708f5d75e7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/db.pp @@ -0,0 +1,43 @@ +# == Class: mongodb::db +# +# Class for creating mongodb databases and users. +# +# == Parameters +# +# user - Database username. +# password_hash - Hashed password. Hex encoded md5 hash of "$username:mongo:$password". +# password - Plain text user password. This is UNSAFE, use 'password_hash' unstead. +# roles (default: ['dbAdmin']) - array with user roles. +# tries (default: 10) - The maximum amount of two second tries to wait MongoDB startup. +# +define mongodb::db ( + $user, + $password_hash = false, + $password = false, + $roles = ['dbAdmin'], + $tries = 10, +) { + + mongodb_database { $name: + ensure => present, + tries => $tries, + require => Class['mongodb::server'], + } + + if $password_hash { + $hash = $password_hash + } elsif $password { + $hash = mongodb_password($user, $password) + } else { + fail("Parameter 'password_hash' or 'password' should be provided to mongodb::db.") + } + + mongodb_user { $user: + ensure => present, + password_hash => $hash, + database => $name, + roles => $roles, + require => Mongodb_database[$name], + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/globals.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/globals.pp new file mode 100644 index 0000000000..fb04df694d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/globals.pp @@ -0,0 +1,27 @@ +# Class for setting cross-class global overrides. See README.md for more +# details. + +class mongodb::globals ( + $server_package_name = undef, + $client_package_name = undef, + + $service_name = undef, + $service_provider = undef, + $service_status = undef, + + $user = undef, + $group = undef, + $bind_ip = undef, + + $version = undef, + + $manage_package_repo = undef, +) { + + # Setup of the repo only makes sense globally, so we are doing it here. + if($manage_package_repo) { + class { '::mongodb::repo': + ensure => present, + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/init.pp new file mode 100644 index 0000000000..d489731b0d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/init.pp @@ -0,0 +1,136 @@ +# == Class: mongodb +# +# Direct use of this class is deprecated. Please use mongodb::server +# +# Manage mongodb installations on RHEL, CentOS, Debian and Ubuntu - either +# installing from the 10Gen repo or from EPEL in the case of EL systems. +# +# === Parameters +# +# enable_10gen (default: false) - Whether or not to set up 10gen software repositories +# init (auto discovered) - override init (sysv or upstart) for Debian derivatives +# location - override apt location configuration for Debian derivatives +# packagename (auto discovered) - override the package name +# servicename (auto discovered) - override the service name +# service-enable (default: true) - Enable the service and ensure it is running +# +# === Examples +# +# To install with defaults from the distribution packages on any system: +# include mongodb +# +# To install from 10gen on a EL server +# class { 'mongodb': +# enable_10gen => true, +# } +# +# === Authors +# +# Craig Dunn +# +# === Copyright +# +# Copyright 2013 PuppetLabs +# + +class mongodb ( + # Deprecated parameters + $enable_10gen = undef, + + $init = $mongodb::params::service_provider, + $location = '', + $packagename = undef, + $version = undef, + $servicename = $mongodb::params::service_name, + $service_enable = true, #deprecated + $logpath = $mongodb::params::logpath, + $logappend = true, + $fork = $mongodb::params::fork, + $port = 27017, + $dbpath = $mongodb::params::dbpath, + $journal = undef, + $nojournal = undef, + $smallfiles = undef, + $cpu = undef, + $noauth = undef, + $auth = undef, + $verbose = undef, + $objcheck = undef, + $quota = undef, + $oplog = undef, #deprecated it's on if replica set + $oplog_size = undef, + $nohints = undef, + $nohttpinterface = undef, + $noscripting = undef, + $notablescan = undef, + $noprealloc = undef, + $nssize = undef, + $mms_token = undef, + $mms_name = undef, + $mms_interval = undef, + $slave = undef, + $only = undef, + $master = undef, + $source = undef, + $replset = undef, + $rest = undef, + $slowms = undef, + $keyfile = undef, + $bind_ip = undef, + $pidfilepath = undef +) inherits mongodb::params { + + if $enable_10gen { + fail("Parameter enable_10gen is no longer supported. Please use class { 'mongodb::globals': manage_package_repo => true }") + } + + if $version { + fail("Parameter version is no longer supported. Please use class { 'mongodb::globals': version => VERSION }") + } + + if $oplog { + fail('Parameter is no longer supported. On replica set Oplog is enabled by default.') + } + + notify { 'An attempt has been made below to automatically apply your custom + settings to mongodb::server. Please verify this works in a safe test + environment.': } + + class { 'mongodb::server': + package_name => $packagename, + logpath => $logpath, + logappend => $logappend, + fork => $fork, + port => $port, + dbpath => $dbpath, + journal => $journal, + nojournal => $nojournal, + smallfiles => $smallfiles, + cpu => $cpu, + noauth => $noauth, + verbose => $verbose, + objcheck => $objcheck, + quota => $quota, + oplog_size => $oplog_size, + nohints => $nohints, + nohttpinterface => $nohttpinterface, + noscripting => $noscripting, + notablescan => $notablescan, + noprealloc => $noprealloc, + nssize => $nssize, + mms_token => $mms_token, + mms_name => $mms_name, + mms_interval => $mms_interval, + slave => $slave, + only => $only, + master => $master, + source => $source, + replset => $replset, + rest => $rest, + slowms => $slowms, + keyfile => $keyfile, + bind_ip => $bind_ip, + pidfilepath => $pidfilepath, + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/params.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/params.pp new file mode 100644 index 0000000000..5afc4845e3 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/params.pp @@ -0,0 +1,93 @@ +# PRIVATE CLASS: do not use directly +class mongodb::params inherits mongodb::globals { + $ensure = true + $service_status = $service_status + $ensure_client = true + + # Amazon Linux's OS Family is 'Linux', operating system 'Amazon'. + case $::osfamily { + 'RedHat', 'Linux': { + + if $mongodb::globals::manage_package_repo { + $user = pick($user, 'mongod') + $group = pick($group, 'mongod') + if $::mongodb::globals::version { + $server_package_name = "mongodb-org-server-${::mongodb::globals::version}" + $client_package_name = "mongodb-org-${::mongodb::globals::version}" + } else { + $server_package_name = 'mongodb-org-server' + $client_package_name = 'mongodb-org' + } + $service_name = pick($service_name, 'mongod') + $config = '/etc/mongod.conf' + $dbpath = '/var/lib/mongo' + $logpath = '/var/log/mongodb/mongod.log' + $pidfilepath = '/var/run/mongodb/mongod.pid' + $bind_ip = pick($bind_ip, ['127.0.0.1']) + $fork = true + } else { + # RedHat/CentOS doesn't come with a prepacked mongodb + # so we assume that you are using EPEL repository. + $user = pick($user, 'mongodb') + $group = pick($group, 'mongodb') + $server_package_name = pick($server_package_name, 'mongodb-server') + $client_package_name = pick($client_package_name, 'mongodb') + + $service_name = pick($service_name, 'mongod') + $config = '/etc/mongodb.conf' + $dbpath = '/var/lib/mongodb' + $logpath = '/var/log/mongodb/mongodb.log' + $bind_ip = pick($bind_ip, ['127.0.0.1']) + $pidfilepath = '/var/run/mongodb/mongodb.pid' + $fork = true + $journal = true + } + } + 'Debian': { + if $mongodb::globals::manage_package_repo { + $user = pick($user, 'mongodb') + $group = pick($group, 'mongodb') + if $::mongodb::globals::version { + $server_package_name = "mongodb-10gen=${::mongodb::globals::version}" + } else { + $server_package_name = 'mongodb-10gen' + } + $service_name = 'mongodb' + $config = '/etc/mongodb.conf' + $dbpath = '/var/lib/mongodb' + $logpath = '/var/log/mongodb/mongodb.log' + $bind_ip = ['127.0.0.1'] + } else { + # although we are living in a free world, + # I would not recommend to use the prepacked + # mongodb server on Ubuntu 12.04 or Debian 6/7, + # because its really outdated + $user = pick($user, 'mongodb') + $group = pick($group, 'mongodb') + $server_package_name = pick($server_package_name, 'mongodb-server') + $client_package_name = pick($client_package_name, 'mongodb') + $service_name = pick($service_name, 'mongodb') + $config = '/etc/mongodb.conf' + $dbpath = '/var/lib/mongodb' + $logpath = '/var/log/mongodb/mongodb.log' + $bind_ip = pick($bind_ip, ['127.0.0.1']) + $pidfilepath = undef + } + # avoid using fork because of the init scripts design + $fork = undef + } + default: { + fail("Osfamily ${::osfamily} and ${::operatingsystem} is not supported") + } + } + + case $::operatingsystem { + 'Ubuntu': { + $service_provider = pick($service_provider, 'upstart') + } + default: { + $service_provider = undef + } + } + +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/replset.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/replset.pp new file mode 100644 index 0000000000..ce4a025557 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/replset.pp @@ -0,0 +1,10 @@ +# Wrapper class useful for hiera based deployments + +class mongodb::replset( + $sets = undef +) { + + if $sets { + create_resources(mongodb_replset, $sets) + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/repo.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/repo.pp new file mode 100644 index 0000000000..ecd6de1b71 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/repo.pp @@ -0,0 +1,31 @@ +# PRIVATE CLASS: do not use directly +class mongodb::repo ( + $ensure = $mongodb::params::ensure, +) inherits mongodb::params { + case $::osfamily { + 'RedHat', 'Linux': { + $location = $::architecture ? { + 'x86_64' => 'http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/', + 'i686' => 'http://downloads-distro.mongodb.org/repo/redhat/os/i686/', + 'i386' => 'http://downloads-distro.mongodb.org/repo/redhat/os/i686/', + default => undef + } + class { 'mongodb::repo::yum': } + } + + 'Debian': { + $location = $::operatingsystem ? { + 'Debian' => 'http://downloads-distro.mongodb.org/repo/debian-sysvinit', + 'Ubuntu' => 'http://downloads-distro.mongodb.org/repo/ubuntu-upstart', + default => undef + } + class { 'mongodb::repo::apt': } + } + + default: { + if($ensure == 'present' or $ensure == true) { + fail("Unsupported managed repository for osfamily: ${::osfamily}, operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports managing repos for osfamily RedHat, Debian and Ubuntu") + } + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/repo/apt.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/repo/apt.pp new file mode 100644 index 0000000000..e8f4b812f9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/repo/apt.pp @@ -0,0 +1,25 @@ +# PRIVATE CLASS: do not use directly +class mongodb::repo::apt inherits mongodb::repo { + # we try to follow/reproduce the instruction + # from http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ + + include ::apt + + if($::mongodb::repo::ensure == 'present' or $::mongodb::repo::ensure == true) { + apt::source { 'downloads-distro.mongodb.org': + location => $::mongodb::repo::location, + release => 'dist', + repos => '10gen', + key => '9ECBEC467F0CEB10', + key_server => 'keyserver.ubuntu.com', + include_src => false, + } + + Apt::Source['downloads-distro.mongodb.org']->Package<|tag == 'mongodb'|> + } + else { + apt::source { 'downloads-distro.mongodb.org': + ensure => absent, + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/repo/yum.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/repo/yum.pp new file mode 100644 index 0000000000..3a3f6b5d84 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/repo/yum.pp @@ -0,0 +1,20 @@ +# PRIVATE CLASS: do not use directly +class mongodb::repo::yum inherits mongodb::repo { + # We try to follow/reproduce the instruction + # http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/ + + if($::mongodb::repo::ensure == 'present' or $::mongodb::repo::ensure == true) { + yumrepo { 'mongodb': + descr => 'MongoDB/10gen Repository', + baseurl => $::mongodb::repo::location, + gpgcheck => '0', + enabled => '1', + } + Yumrepo['mongodb'] -> Package<|tag == 'mongodb'|> + } + else { + yumrepo { 'mongodb': + enabled => absent, + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server.pp new file mode 100644 index 0000000000..04c576a139 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server.pp @@ -0,0 +1,77 @@ +# This installs a MongoDB server. See README.md for more details. +class mongodb::server ( + $ensure = $mongodb::params::ensure, + + $user = $mongodb::params::user, + $group = $mongodb::params::group, + + $config = $mongodb::params::config, + $dbpath = $mongodb::params::dbpath, + $pidfilepath = $mongodb::params::pidfilepath, + + $service_provider = $mongodb::params::service_provider, + $service_name = $mongodb::params::service_name, + $service_status = $mongodb::params::service_status, + + $package_ensure = $ensure, + $package_name = $mongodb::params::server_package_name, + + $logpath = $mongodb::params::logpath, + $bind_ip = $mongodb::params::bind_ip, + $logappend = true, + $fork = $mongodb::params::fork, + $port = 27017, + $journal = $mongodb::params::journal, + $nojournal = undef, + $smallfiles = undef, + $cpu = undef, + $auth = false, + $noauth = undef, + $verbose = undef, + $verbositylevel = undef, + $objcheck = undef, + $quota = undef, + $quotafiles = undef, + $diaglog = undef, + $directoryperdb = undef, + $profile = undef, + $maxconns = undef, + $oplog_size = undef, + $nohints = undef, + $nohttpinterface = undef, + $noscripting = undef, + $notablescan = undef, + $noprealloc = undef, + $nssize = undef, + $mms_token = undef, + $mms_name = undef, + $mms_interval = undef, + $replset = undef, + $rest = undef, + $slowms = undef, + $keyfile = undef, + $set_parameter = undef, + $syslog = undef, + + # Deprecated parameters + $master = undef, + $slave = undef, + $only = undef, + $source = undef, +) inherits mongodb::params { + + + if ($ensure == 'present' or $ensure == true) { + anchor { 'mongodb::server::start': }-> + class { 'mongodb::server::install': }-> + class { 'mongodb::server::config': }-> + class { 'mongodb::server::service': }-> + anchor { 'mongodb::server::end': } + } else { + anchor { 'mongodb::server::start': }-> + class { 'mongodb::server::service': }-> + class { 'mongodb::server::config': }-> + class { 'mongodb::server::install': }-> + anchor { 'mongodb::server::end': } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server/config.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server/config.pp new file mode 100644 index 0000000000..2056c14d54 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server/config.pp @@ -0,0 +1,92 @@ +# PRIVATE CLASS: do not call directly +class mongodb::server::config { + $ensure = $mongodb::server::ensure + $user = $mongodb::server::user + $group = $mongodb::server::group + $config = $mongodb::server::config + + $dbpath = $mongodb::server::dbpath + $pidfilepath = $mongodb::server::pidfilepath + $logpath = $mongodb::server::logpath + $logappend = $mongodb::server::logappend + $fork = $mongodb::server::fork + $port = $mongodb::server::port + $journal = $mongodb::server::journal + $nojournal = $mongodb::server::nojournal + $smallfiles = $mongodb::server::smallfiles + $cpu = $mongodb::server::cpu + $auth = $mongodb::server::auth + $noath = $mongodb::server::noauth + $verbose = $mongodb::server::verbose + $verbositylevel = $mongodb::server::verbositylevel + $objcheck = $mongodb::server::objcheck + $quota = $mongodb::server::quota + $quotafiles = $mongodb::server::quotafiles + $diaglog = $mongodb::server::diaglog + $oplog_size = $mongodb::server::oplog_size + $nohints = $mongodb::server::nohints + $nohttpinterface = $mongodb::server::nohttpinterface + $noscripting = $mongodb::server::noscripting + $notablescan = $mongodb::server::notablescan + $noprealloc = $mongodb::server::noprealloc + $nssize = $mongodb::server::nssize + $mms_token = $mongodb::server::mms_token + $mms_name = $mongodb::server::mms_name + $mms_interval = $mongodb::server::mms_interval + $master = $mongodb::server::master + $slave = $mongodb::server::slave + $only = $mongodb::server::only + $source = $mongodb::server::source + $replset = $mongodb::server::replset + $rest = $mongodb::server::rest + $slowms = $mongodb::server::slowms + $keyfile = $mongodb::server::keyfile + $bind_ip = $mongodb::server::bind_ip + $directoryperdb = $mongodb::server::directoryperdb + $profile = $mongodb::server::profile + $set_parameter = $mongodb::server::set_parameter + $syslog = $mongodb::server::syslog + + File { + owner => $user, + group => $group, + } + + if ($logpath and $syslog) { fail('You cannot use syslog with logpath')} + + if ($ensure == 'present' or $ensure == true) { + + # Exists for future compatibility and clarity. + if $auth { + $noauth = false + } + else { + $noauth = true + } + + file { $config: + content => template('mongodb/mongodb.conf.erb'), + owner => 'root', + group => 'root', + mode => '0644', + notify => Class['mongodb::server::service'] + } + + file { $dbpath: + ensure => directory, + mode => '0755', + owner => $user, + group => $group, + require => File[$config] + } + } else { + file { $dbpath: + ensure => absent, + force => true, + backup => false, + } + file { $config: + ensure => absent + } + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server/install.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server/install.pp new file mode 100644 index 0000000000..46b0e749b1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server/install.pp @@ -0,0 +1,34 @@ +# PRIVATE CLASS: do not call directly +class mongodb::server::install { + $package_ensure = $mongodb::server::package_ensure + $package_name = $mongodb::server::package_name + + case $package_ensure { + true: { + $my_package_ensure = 'present' + $file_ensure = 'directory' + } + false: { + $my_package_ensure = 'absent' + $file_ensure = 'absent' + } + 'absent': { + $my_package_ensure = 'absent' + $file_ensure = 'absent' + } + 'purged': { + $my_package_ensure = 'purged' + $file_ensure = 'absent' + } + default: { + $my_package_ensure = $package_ensure + $file_ensure = 'present' + } + } + + package { 'mongodb_server': + ensure => $my_package_ensure, + name => $package_name, + tag => 'mongodb', + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server/service.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server/service.pp new file mode 100644 index 0000000000..8cb4a48ef5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/manifests/server/service.pp @@ -0,0 +1,23 @@ +# PRIVATE CLASS: do not call directly +class mongodb::server::service { + $ensure = $mongodb::server::ensure + $service_name = $mongodb::server::service_name + $service_provider = $mongodb::server::service_provider + $service_status = $mongodb::server::service_status + + $service_ensure = $ensure ? { + present => true, + absent => false, + purged => false, + default => $ensure + } + + service { 'mongodb': + ensure => $service_ensure, + name => $service_name, + enable => $service_ensure, + provider => $service_provider, + hasstatus => true, + status => $service_status, + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/centos-6-vcloud.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/centos-6-vcloud.yml new file mode 100644 index 0000000000..ae19ee77c8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/centos-6-vcloud.yml @@ -0,0 +1,21 @@ +HOSTS: + 'master': + roles: + - master + platform: el-6-x86_64 + hypervisor: vcloud + template: centos-6-x86_64 + 'slave': + roles: + - slave + platform: el-6-x86_64 + hypervisor: vcloud + template: centos-6-x86_64 +CONFIG: + type: foss + ssh: + keys: "~/.ssh/id_rsa-acceptance" + datastore: instance0 + folder: Delivery/Quality Assurance/Enterprise/Dynamic + resourcepool: delivery/Quality Assurance/Enterprise/Dynamic + pooling_api: http://vcloud.delivery.puppetlabs.net/ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/centos-64-x64-pe.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/centos-64-x64-pe.yml new file mode 100644 index 0000000000..7d9242f1b9 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/centos-64-x64-pe.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-64-x64: + roles: + - master + - database + - dashboard + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: pe diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/centos-64-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/centos-64-x64.yml new file mode 100644 index 0000000000..05540ed8c5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/centos-64-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/default.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/default.yml new file mode 100644 index 0000000000..4e2cb809e8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/default.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-65-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-65-x64-vbox436-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/fedora-18-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/fedora-18-x64.yml new file mode 100644 index 0000000000..1361649830 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/fedora-18-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + fedora-18-x64: + roles: + - master + platform: fedora-18-x86_64 + box : fedora-18-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/multi-centos-6-vcloud.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/multi-centos-6-vcloud.yml new file mode 100644 index 0000000000..ae19ee77c8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/multi-centos-6-vcloud.yml @@ -0,0 +1,21 @@ +HOSTS: + 'master': + roles: + - master + platform: el-6-x86_64 + hypervisor: vcloud + template: centos-6-x86_64 + 'slave': + roles: + - slave + platform: el-6-x86_64 + hypervisor: vcloud + template: centos-6-x86_64 +CONFIG: + type: foss + ssh: + keys: "~/.ssh/id_rsa-acceptance" + datastore: instance0 + folder: Delivery/Quality Assurance/Enterprise/Dynamic + resourcepool: delivery/Quality Assurance/Enterprise/Dynamic + pooling_api: http://vcloud.delivery.puppetlabs.net/ diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/multi-centos-64-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/multi-centos-64-x64.yml new file mode 100644 index 0000000000..05540ed8c5 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/multi-centos-64-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + centos-64-x64: + roles: + - master + platform: el-6-x86_64 + box : centos-64-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/sles-11-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/sles-11-x64.yml new file mode 100644 index 0000000000..41abe2135e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/sles-11-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + sles-11-x64.local: + roles: + - master + platform: sles-11-x64 + box : sles-11sp1-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml new file mode 100644 index 0000000000..5ca1514e40 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-10044-x64: + roles: + - master + platform: ubuntu-10.04-amd64 + box : ubuntu-server-10044-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml new file mode 100644 index 0000000000..d065b304f8 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-server-12042-x64: + roles: + - master + platform: ubuntu-12.04-amd64 + box : ubuntu-server-12042-x64-vbox4210-nocm + box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box + hypervisor : vagrant +CONFIG: + type: foss diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/replset_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/replset_spec.rb new file mode 100644 index 0000000000..8be5a0f463 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/replset_spec.rb @@ -0,0 +1,69 @@ +require 'spec_helper_acceptance' + +if hosts.length > 1 + describe 'mongodb_replset resource' do + after :all do + # Have to drop the DB to disable replsets for further testing + on hosts, %{mongo local --verbose --eval 'db.dropDatabase()'} + + pp = <<-EOS + class { 'mongodb::globals': } + -> class { 'mongodb::server': + ensure => purged, + } + if $::osfamily == 'RedHat' { + class { 'mongodb::client': } + } + EOS + + apply_manifest_on(hosts.reverse, pp, :catch_failures => true) + end + + it 'configures mongo on both nodes' do + pp = <<-EOS + class { 'mongodb::globals': } + -> class { 'mongodb::server': + bind_ip => '0.0.0.0', + replset => 'test', + } + if $::osfamily == 'RedHat' { + class { 'mongodb::client': } + } + EOS + + apply_manifest_on(hosts.reverse, pp, :catch_failures => true) + apply_manifest_on(hosts.reverse, pp, :catch_changes => true) + end + + it 'sets up the replset with puppet' do + pp = <<-EOS + mongodb_replset { 'test': + members => [#{hosts.collect{|x|"'#{x}:27017'"}.join(',')}], + } + EOS + apply_manifest_on(hosts_as('master'), pp, :catch_failures => true) + on(hosts_as('master'), 'mongo --quiet --eval "printjson(rs.conf())"') do |r| + expect(r.stdout).to match /#{hosts[0]}:27017/ + expect(r.stdout).to match /#{hosts[1]}:27017/ + end + end + + it 'inserts data on the master' do + sleep(30) + on hosts_as('master'), %{mongo --verbose --eval 'db.test.save({name:"test1",value:"some value"})'} + end + + it 'checks the data on the master' do + on hosts_as('master'), %{mongo --verbose --eval 'printjson(db.test.findOne({name:"test1"}))'} do |r| + expect(r.stdout).to match /some value/ + end + end + + it 'checks the data on the slave' do + sleep(10) + on hosts_as('slave'), %{mongo --verbose --eval 'rs.slaveOk(); printjson(db.test.findOne({name:"test1"}))'} do |r| + expect(r.stdout).to match /some value/ + end + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/server_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/server_spec.rb new file mode 100644 index 0000000000..c1132f594c --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/acceptance/server_spec.rb @@ -0,0 +1,122 @@ +require 'spec_helper_acceptance' + +describe 'mongodb::server class' do + + shared_examples 'normal tests' do |tengen| + if tengen + case fact('osfamily') + when 'RedHat' + package_name = 'mongodb-org-server' + service_name = 'mongod' + config_file = '/etc/mongod.conf' + when 'Debian' + package_name = 'mongodbdb-org-10gen' + service_name = 'mongodb' + config_file = '/etc/mongodb.conf' + end + else + case fact('osfamily') + when 'RedHat' + package_name = 'mongodb-server' + service_name = 'mongod' + config_file = '/etc/mongodb.conf' + when 'Debian' + package_name = 'mongodb-server' + service_name = 'mongodb' + config_file = '/etc/mongodb.conf' + end + end + + client_name = 'mongo --version' + + context "default parameters with 10gen => #{tengen}" do + after :all do + if tengen + puts "XXX uninstalls mongodb because changing the port with tengen doesn't work because they have a crappy init script" + pp = <<-EOS + class {'mongodb::globals': manage_package_repo => #{tengen}, } + -> class { 'mongodb::server': ensure => absent, } + -> class { 'mongodb::client': ensure => absent, } + EOS + apply_manifest(pp, :catch_failures => true) + end + end + + it 'should work with no errors' do + case fact('osfamily') + when 'RedHat' + pp = <<-EOS + class { 'mongodb::globals': manage_package_repo => #{tengen}, } + -> class { 'mongodb::server': } + -> class { 'mongodb::client': } + EOS + when 'Debian' + pp = <<-EOS + class { 'mongodb::globals': manage_package_repo => #{tengen}, } + -> class { 'mongodb::server': } + EOS + end + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe package(package_name) do + it { should be_installed } + end + + describe file(config_file) do + it { should be_file } + end + + describe service(service_name) do + it { should be_enabled } + it { should be_running } + end + + describe port(27017) do + it do + sleep(20) + should be_listening + end + end + + describe command(client_name) do + it do + should return_exit_status 0 + end + end + end + + context "test using custom port and 10gen => #{tengen}" do + it 'change port to 27018' do + pp = <<-EOS + class { 'mongodb::globals': manage_package_repo => #{tengen}, } + -> class { 'mongodb::server': port => 27018, } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + describe port(27018) do + sleep(20) + it { sleep 5 ; should be_listening } + end + end + + describe "uninstalling with 10gen => #{tengen}" do + it 'uninstalls mongodb' do + pp = <<-EOS + class {'mongodb::globals': manage_package_repo => #{tengen}, } + -> class { 'mongodb::server': ensure => absent, } + -> class { 'mongodb::client': ensure => absent, } + EOS + apply_manifest(pp, :catch_failures => true) + end + end + end + + it_behaves_like 'normal tests', false + it_behaves_like 'normal tests', true +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/client_install_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/client_install_spec.rb new file mode 100644 index 0000000000..5fe4bfa7cc --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/client_install_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe 'mongodb::client::install', :type => :class do + describe 'it should create package' do + let(:pre_condition) { ["class mongodb::client { $ensure = true $package_name = 'mongodb' }", "include mongodb::client"]} + it { + should contain_package('mongodb_client').with({ + :ensure => 'present', + :name => 'mongodb', + }) + } + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/repo_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/repo_spec.rb new file mode 100644 index 0000000000..aa051e915f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/repo_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe 'mongodb::repo', :type => :class do + + context 'when deploying on Debian' do + let :facts do + { + :osfamily => 'Debian', + :operatingsystem => 'Debian', + :lsbdistid => 'Debian', + } + end + + it { + should contain_class('mongodb::repo::apt') + } + end + + context 'when deploying on CentOS' do + let :facts do + { + :osfamily => 'RedHat', + :operatingsystem => 'CentOS', + } + end + + it { + should contain_class('mongodb::repo::yum') + } + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/server_config_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/server_config_spec.rb new file mode 100644 index 0000000000..db05b88e31 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/server_config_spec.rb @@ -0,0 +1,116 @@ +require 'spec_helper' + +describe 'mongodb::server::config', :type => :class do + + describe 'with preseted variables' do + let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' }", "include mongodb::server"]} + + it { + should contain_file('/etc/mongod.conf') + } + + end + + describe 'with default values' do + let(:pre_condition) {[ "class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' $ensure = present $user = 'mongod' $group = 'mongod' $port = 29017 $bind_ip = ['0.0.0.0'] $fork = true $logpath ='/var/log/mongo/mongod.log' $logappend = true }", "include mongodb::server" ]} + + it { + should contain_file('/etc/mongod.conf').with({ + :mode => '0644', + :owner => 'root', + :group => 'root' + }) + + should contain_file('/etc/mongod.conf').with_content(/^dbpath=\/var\/lib\/mongo/) + should contain_file('/etc/mongod.conf').with_content(/bind_ip\s=\s0\.0\.0\.0/) + should contain_file('/etc/mongod.conf').with_content(/^port = 29017$/) + should contain_file('/etc/mongod.conf').with_content(/^logappend=true/) + should contain_file('/etc/mongod.conf').with_content(/^logpath=\/var\/log\/mongo\/mongod\.log/) + should contain_file('/etc/mongod.conf').with_content(/^fork=true/) + } + end + + describe 'with absent ensure' do + let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' $ensure = absent }", "include mongodb::server"]} + + it { + should contain_file('/etc/mongod.conf').with({ :ensure => 'absent' }) + } + + end + + describe 'with specific bind_ip values' do + let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' $ensure = present $bind_ip = ['127.0.0.1', '10.1.1.13']}", "include mongodb::server"]} + + it { + should contain_file('/etc/mongod.conf').with_content(/bind_ip\s=\s127\.0\.0\.1\,10\.1\.1\.13/) + } + end + + describe 'when specifying auth to true' do + let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $auth = true $dbpath = '/var/lib/mongo' $ensure = present }", "include mongodb::server"]} + + it { + should contain_file('/etc/mongod.conf').with_content(/^auth=true/) + } + end + + describe 'when specifying set_parameter value' do + let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $set_parameter = 'textSearchEnable=true' $dbpath = '/var/lib/mongo' $ensure = present }", "include mongodb::server"]} + + it { + should contain_file('/etc/mongod.conf').with_content(/^setParameter = textSearchEnable=true/) + } + end + + describe 'with journal:' do + context 'on true with i686 architecture' do + let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' $ensure = present $journal = true }", "include mongodb::server"]} + let (:facts) { { :architecture => 'i686' } } + + it { + should contain_file('/etc/mongod.conf').with_content(/^journal = true/) + } + end + end + + # check nested quota and quotafiles + describe 'with quota to' do + + context 'true and without quotafiles' do + let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' $ensure = present $quota = true }", "include mongodb::server"]} + it { + should contain_file('/etc/mongod.conf').with_content(/^quota = true/) + } + end + + context 'true and with quotafiles' do + let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' $ensure = present $quota = true $quotafiles = 1 }", "include mongodb::server"]} + + it { + should contain_file('/etc/mongod.conf').with_content(/quota = true/) + should contain_file('/etc/mongod.conf').with_content(/quotaFiles = 1/) + } + end + end + + describe 'when specifying syslog value' do + context 'it should be set to true' do + let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' $ensure = present $syslog = true }", "include mongodb::server"]} + + it { + should contain_file('/etc/mongod.conf').with_content(/^syslog = true/) + } + end + + context 'if logpath is also set an error should be raised' do + let(:pre_condition) { ["class mongodb::server { $config = '/etc/mongod.conf' $dbpath = '/var/lib/mongo' $ensure = present $syslog = true $logpath ='/var/log/mongo/mongod.log' }", "include mongodb::server"]} + + it { + expect { should contain_file('/etc/mongod.conf') }.to raise_error(Puppet::Error, /You cannot use syslog with logpath/) + } + end + + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/server_install_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/server_install_spec.rb new file mode 100644 index 0000000000..5ca01a90e4 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/server_install_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'mongodb::server::install', :type => :class do + + describe 'it should create package and dbpath file' do + let(:pre_condition) { ["class mongodb::server { $package_ensure = true $dbpath = '/var/lib/mongo' $user = 'mongodb' $package_name = 'mongodb-server' }", "include mongodb::server"]} + + it { + should contain_package('mongodb_server').with({ + :ensure => 'present', + :name => 'mongodb-server', + }) + } + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/server_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/server_spec.rb new file mode 100644 index 0000000000..c74e7f0c16 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/classes/server_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe 'mongodb::server' do + let :facts do + { + :osfamily => 'Debian', + :operatingsystem => 'Debian', + } + end + + context 'with defaults' do + it { should contain_class('mongodb::server::install') } + it { should contain_class('mongodb::server::config') } + end + + context 'when deploying on Solaris' do + let :facts do + { :osfamily => 'Solaris' } + end + it { expect { should raise_error(Puppet::Error) } } + end + +end \ No newline at end of file diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/defines/db_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/defines/db_spec.rb new file mode 100644 index 0000000000..65a6f10523 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/defines/db_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe 'mongodb::db', :type => :define do + let(:title) { 'testdb' } + + let(:params) { + { 'user' => 'testuser', + 'password' => 'testpass', + } + } + + it 'should contain mongodb_database with mongodb::server requirement' do + should contain_mongodb_database('testdb')\ + .with_require('Class[Mongodb::Server]') + end + + it 'should contain mongodb_user with mongodb_database requirement' do + should contain_mongodb_user('testuser')\ + .with_require('Mongodb_database[testdb]') + end + + it 'should contain mongodb_user with proper database name' do + should contain_mongodb_user('testuser')\ + .with_database('testdb') + end + + it 'should contain mongodb_user with proper roles' do + params.merge!({'roles' => ['testrole1', 'testrole2']}) + should contain_mongodb_user('testuser')\ + .with_roles(["testrole1", "testrole2"]) + end + + it 'should prefer password_hash instead of password' do + params.merge!({'password_hash' => 'securehash'}) + should contain_mongodb_user('testuser')\ + .with_password_hash('securehash') + end + + it 'should contain mongodb_database with proper tries param' do + params.merge!({'tries' => 5}) + should contain_mongodb_database('testdb').with_tries(5) + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/spec_helper.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/spec_helper.rb new file mode 100644 index 0000000000..2c6f56649a --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/spec_helper_acceptance.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/spec_helper_acceptance.rb new file mode 100755 index 0000000000..c1c09a9b74 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/spec_helper_acceptance.rb @@ -0,0 +1,39 @@ +#! /usr/bin/env ruby -S rspec +require 'beaker-rspec' + +UNSUPPORTED_PLATFORMS = [] + +unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' + if hosts.first.is_pe? + install_pe + on hosts, 'mkdir -p /etc/puppetlabs/facter/facts.d' + else + install_puppet + on hosts, 'mkdir -p /etc/facter/facts.d' + on hosts, '/bin/touch /etc/puppet/hiera.yaml' + end + hosts.each do |host| + on host, "mkdir -p #{host['distmoduledir']}" + end +end + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + puppet_module_install(:source => proj_root, :module_name => 'mongodb') + on hosts, 'puppet module install puppetlabs-stdlib' + on hosts, 'puppet module install puppetlabs-apt' + case fact('osfamily') + when 'RedHat' + on hosts, 'puppet module install stahnma-epel' + apply_manifest_on hosts, 'include epel' + end + on hosts, 'service iptables stop' + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/spec_helper_system.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/spec_helper_system.rb new file mode 100644 index 0000000000..7e2c48fb5e --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/spec_helper_system.rb @@ -0,0 +1,34 @@ +require 'rspec-system/spec_helper' +require 'rspec-system-puppet/helpers' +require 'rspec-system-serverspec/helpers' + +include RSpecSystemPuppet::Helpers +include Serverspec::Helper::RSpecSystem +include Serverspec::Helper::DetectOS + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Enable colour + c.tty = true + + c.include RSpecSystemPuppet::Helpers + + # This is where we 'setup' the nodes before running our tests + c.before :suite do + # Install puppet + puppet_install + + # Install modules and dependencies + puppet_module_install(:source => proj_root, :module_name => 'mongodb') + shell('puppet module install puppetlabs-stdlib') + shell('puppet module install puppetlabs-apt') + + case node.facts['osfamily'] + when 'RedHat' + shell('puppet module install stahnma-epel') + puppet_apply('include epel') + end + end +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/mongodb_password_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/mongodb_password_spec.rb new file mode 100644 index 0000000000..5b0b825e56 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/mongodb_password_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe 'the mongodb_password function' do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end + + let(:scope) { PuppetlabsSpec::PuppetInternals.scope } + + it 'should exist' do + Puppet::Parser::Functions.function('mongodb_password').should == 'function_mongodb_password' + end + + it 'should raise a ParseError if there no arguments' do + lambda { scope.function_mongodb_password([]) }.should( raise_error(Puppet::ParseError)) + end + + it 'should raise a ParseError if there is more than 2 arguments' do + lambda { scope.function_mongodb_password(%w(foo bar baz)) }.should( raise_error(Puppet::ParseError)) + end + + it 'should convert password into a hash' do + result = scope.function_mongodb_password(%w(user pass)) + result.should(eq('e0c4a7b97d4db31f5014e9694e567d6b')) + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/provider/mongodb_database/mongodb_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/provider/mongodb_database/mongodb_spec.rb new file mode 100644 index 0000000000..4376ada54b --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/provider/mongodb_database/mongodb_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Puppet::Type.type(:mongodb_database).provider(:mongodb) do + + let(:resource) { Puppet::Type.type(:mongodb_database).new( + { :ensure => :present, + :name => 'new_database', + :provider => described_class.name + } + )} + + let(:provider) { resource.provider } + + describe 'create' do + it 'makes a database' do + provider.expects(:mongo) + provider.create + end + end + + describe 'destroy' do + it 'removes a database' do + provider.expects(:mongo) + provider.destroy + end + end + + describe 'exists?' do + it 'checks if database exists' do + provider.expects(:mongo).at_least(2).returns("db1,new_database,db2") + provider.exists?.should be_true + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/provider/mongodb_replset/mongodb_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/provider/mongodb_replset/mongodb_spec.rb new file mode 100644 index 0000000000..51b3f9effe --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/provider/mongodb_replset/mongodb_spec.rb @@ -0,0 +1,148 @@ +# +# Authors: Emilien Macchi +# Francois Charlier +# + +require 'spec_helper' + +describe Puppet::Type.type(:mongodb_replset).provider(:mongo) do + + valid_members = ['mongo1:27017', 'mongo2:27017', 'mongo3:27017'] + + let(:resource) { Puppet::Type.type(:mongodb_replset).new( + { :ensure => :present, + :name => 'rs_test', + :members => valid_members, + :provider => :mongo + } + )} + + let(:resources) { { 'rs_test' => resource } } + let(:provider) { described_class.new(resource) } + + describe '#create' do + it 'should create a replicaset' do + provider.class.stubs(:get_replset_properties) + provider.stubs(:alive_members).returns(valid_members) + provider.expects('rs_initiate').with("{ _id: \"rs_test\", members: [ { _id: 0, host: \"mongo1:27017\" },{ _id: 1, host: \"mongo2:27017\" },{ _id: 2, host: \"mongo3:27017\" } ] }", "mongo1:27017").returns( + { "info" => "Config now saved locally. Should come online in about a minute.", + "ok" => 1 } ) + provider.create + provider.flush + end + end + + describe '#exists?' do + describe 'when the replicaset does not exist' do + it 'returns false' do + provider.class.stubs(:mongo).returns(< "rs_test" }) + provider.expects('rs_add').times(2).returns({ 'ok' => 1 }) + provider.members=(valid_members) + provider.flush + end + + it 'raises an error when the master host is not available' do + provider.stubs(:rs_status).returns({ "set" => "rs_test" }) + provider.stubs(:db_ismaster).returns({ "primary" => false }) + provider.members=(valid_members) + expect { provider.flush }.to raise_error(Puppet::Error, "Can't find master host for replicaset #{resource[:name]}.") + end + + it 'raises an error when at least one member is not running with --replSet' do + provider.stubs(:rs_status).returns({ "ok" => 0, "errmsg" => "not running with --replSet" }) + provider.members=(valid_members) + expect { provider.flush }.to raise_error(Puppet::Error, /is not supposed to be part of a replicaset\.$/) + end + + it 'raises an error when at least one member is configured with another replicaset name' do + provider.stubs(:rs_status).returns({ "set" => "rs_another" }) + provider.members=(valid_members) + expect { provider.flush }.to raise_error(Puppet::Error, /is already part of another replicaset\.$/) + end + + it 'raises an error when no member is available' do + provider.class.stubs(:mongo_command).raises(Puppet::ExecutionFailure, < :present, + :name => 'new_user', + :database => 'new_database', + :password_hash => 'pass', + :roles => ['role1', 'role2'], + :provider => described_class.name + } + )} + + let(:provider) { resource.provider } + + describe 'create' do + it 'creates a user' do + provider.expects(:mongo) + provider.create + end + end + + describe 'destroy' do + it 'removes a user' do + provider.expects(:mongo) + provider.destroy + end + end + + describe 'exists?' do + it 'checks if user exists' do + provider.expects(:mongo).at_least(2).returns("1") + provider.exists?.should be_true + end + end + + describe 'password_hash' do + it 'returns a password_hash' do + provider.expects(:mongo).returns("pass\n") + provider.password_hash.should == "pass" + end + end + + describe 'password_hash=' do + it 'changes a password_hash' do + provider.expects(:mongo) + provider.password_hash=("newpass") + end + end + + describe 'roles' do + it 'returns a sorted roles' do + provider.expects(:mongo).returns("role2,role1\n") + provider.roles.should == ['role1','role2'] + end + end + + describe 'roles=' do + it 'changes a roles' do + provider.expects(:mongo) + provider.roles=(['role3','role4']) + end + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/type/mongodb_database_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/type/mongodb_database_spec.rb new file mode 100644 index 0000000000..245a1becf1 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/type/mongodb_database_spec.rb @@ -0,0 +1,24 @@ +require 'puppet' +require 'puppet/type/mongodb_database' +describe Puppet::Type.type(:mongodb_database) do + + before :each do + @db = Puppet::Type.type(:mongodb_database).new(:name => 'test') + end + + it 'should accept a database name' do + @db[:name].should == 'test' + end + + it 'should accept a tries parameter' do + @db[:tries] = 5 + @db[:tries].should == 5 + end + + it 'should require a name' do + expect { + Puppet::Type.type(:mongodb_database).new({}) + }.to raise_error(Puppet::Error, 'Title or name must be provided') + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/type/mongodb_replset_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/type/mongodb_replset_spec.rb new file mode 100644 index 0000000000..f9b72d4236 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/type/mongodb_replset_spec.rb @@ -0,0 +1,28 @@ +# +# Author: Emilien Macchi +# + +require 'puppet' +require 'puppet/type/mongodb_replset' +describe Puppet::Type.type(:mongodb_replset) do + + before :each do + @replset = Puppet::Type.type(:mongodb_replset).new(:name => 'test') + end + + it 'should accept a replica set name' do + @replset[:name].should == 'test' + end + + it 'should accept a members array' do + @replset[:members] = ['mongo1:27017', 'mongo2:27017'] + @replset[:members].should == ['mongo1:27017', 'mongo2:27017'] + end + + it 'should require a name' do + expect { + Puppet::Type.type(:mongodb_replset).new({}) + }.to raise_error(Puppet::Error, 'Title or name must be provided') + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/type/mongodb_user_spec.rb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/type/mongodb_user_spec.rb new file mode 100644 index 0000000000..c822265d11 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/spec/unit/puppet/type/mongodb_user_spec.rb @@ -0,0 +1,67 @@ +require 'puppet' +require 'puppet/type/mongodb_user' +describe Puppet::Type.type(:mongodb_user) do + + before :each do + @user = Puppet::Type.type(:mongodb_user).new( + :name => 'test', + :database => 'testdb', + :password_hash => 'pass') + end + + it 'should accept a user name' do + @user[:name].should == 'test' + end + + it 'should accept a database name' do + @user[:database].should == 'testdb' + end + + it 'should accept a tries parameter' do + @user[:tries] = 5 + @user[:tries].should == 5 + end + + it 'should accept a password' do + @user[:password_hash] = 'foo' + @user[:password_hash].should == 'foo' + end + + it 'should use default role' do + @user[:roles].should == ['dbAdmin'] + end + + it 'should accept a roles array' do + @user[:roles] = ['role1', 'role2'] + @user[:roles].should == ['role1', 'role2'] + end + + it 'should require a name' do + expect { + Puppet::Type.type(:mongodb_user).new({}) + }.to raise_error(Puppet::Error, 'Title or name must be provided') + end + + it 'should require a database' do + expect { + Puppet::Type.type(:mongodb_user).new({:name => 'test', :password_hash => 'pass'}) + }.to raise_error(Puppet::Error, 'Parameter \'database\' must be set') + end + + it 'should require a password_hash' do + expect { + Puppet::Type.type(:mongodb_user).new({:name => 'test', :database => 'testdb'}) + }.to raise_error(Puppet::Error, 'Property \'password_hash\' must be set. Use mongodb_password() for creating hash.') + end + + it 'should sort roles' do + # Reinitialize type with explicit unsorted roles. + @user = Puppet::Type.type(:mongodb_user).new( + :name => 'test', + :database => 'testdb', + :password_hash => 'pass', + :roles => ['b', 'a']) + @user[:roles].should == ['a', 'b'] + end + +end diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/templates/mongodb.conf.erb b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/templates/mongodb.conf.erb new file mode 100644 index 0000000000..85d81054bb --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/templates/mongodb.conf.erb @@ -0,0 +1,172 @@ +# mongo.conf - generated from Puppet + + +<% if @logpath -%> +#where to log +logpath=<%= @logpath %> +<% if @logappend -%> +logappend=<%= @logappend %> +<% end -%> +<% end -%> +<% if @bind_ip -%> +# Set this option to configure the mongod or mongos process to bind to and +# listen for connections from applications on this address. +# You may concatenate a list of comma separated values to bind mongod to multiple IP addresses. +bind_ip = <%= Array(@bind_ip).join(',') %> +<% end -%> +<% if @fork -%> +# fork and run in background +fork=<%= @fork %> +<% end -%> +port = <%= @port %> +dbpath=<%= @dbpath %> +<% if @pidfilepath -%> +# location of pidfile +pidfilepath = <%= @pidfilepath %> +<% end -%> +<% if @nojournal and not @journal -%> +# Disables write-ahead journaling +nojournal = <%= @nojournal %> +<% end -%> +<% if @journal and not @nojournal -%> +# Enables journaling +journal = <%= @journal %> +<% end -%> +<% if @cpu -%> +# Enables periodic logging of CPU utilization and I/O wait +cpu = <%= @cpu %> +<% end -%> +# Turn on/off security. Off is currently the default +<% if @noauth and not @auth -%> +noauth=<%= @noauth %> +<% end -%> +<% if @auth and not @noauth -%> +auth=<%= @auth %> +<% end -%> +<% if @verbose -%> +# Verbose logging output. +verbose = <%= @verbose %> +<% end -%> +<% if @verbositylevel -%> +<%= @verbositylevel -%> = true +<% end -%> +<% if @objcheck -%> +# Inspect all client data for validity on receipt (useful for +# developing drivers) +objcheck = <%= @objcheck %> +<% end -%> +<% if @maxconns -%> +maxConns = <%= @maxconns %> +<% end -%> +<% if @quota -%> +# Enable db quota management +quota = <%= @quota %> +<% if @quotafiles -%> +quotaFiles = <%= @quotafiles %> +<% end -%> +<% end -%> +<% if @diaglog -%> +# Set oplogging level where n is +# 0=off (default) +# 1=W +# 2=R +# 3=both +# 7=W+some reads +diaglog = <%= @diaglog %> +<% end -%> +<% if @oplog_size -%> +# Specifies a maximum size in megabytes for the replication operation log +oplogSize = <%= @oplog_size %> +<% end -%> +<% if @nohints -%> +# Ignore query hints +nohints = <%= @nohints %> +<% end -%> +<% if @nohttpinterface -%> +# Disable the HTTP interface (Defaults to localhost:27018). +nohttpinterface = <%= @nohttpinterface %> +<% end -%> +<% if @noscripting -%> +# Turns off server-side scripting. This will result in greatly limited +# functionality +noscripting = <%= @noscripting %> +<% end -%> +<% if @notablescan -%> +# Turns off table scans. Any query that would do a table scan fails. +notablescan = <%= @notablescan %> +<% end -%> +<% if @noprealloc -%> +# Disable data file preallocation. +noprealloc = <%= @noprealloc %> +<% end -%> +<% if @nssize -%> +# Specify .ns file size for new databases in megabytes. +nssize = <%= @nssize %> +<% end -%> +<% if @mms_token -%> +# Accout token for Mongo monitoring server. +mms-token = <%= @mms_token %> +<% end -%> +<% if @mms_name -%> +# Server name for Mongo monitoring server. +mms-name = <%= @mms_name %> +<% end -%> +<% if @mms_interval -%> +# Ping interval for Mongo monitoring server. +mms-interval = <%= @mms_interval %> +<% end -%> +<% if @slave -%> +slave = <%= @slave %> +<% end -%> +<% if @source -%> +source = <%= @source %> +<% end -%> +<% if @only -%> +# Slave only: specify a single database to replicate +only = <%= @only %> +<% end -%> +<% if @master -%> +master = <%= @master %> +<% end -%> +<% if @directoryperdb -%> +# Alters the storage pattern of the data directory to store each database +# files in a distinct folder. +directoryperdb = <%= @directoryperdb %> +<% end -%> +<% if @replset -%> +# Configure ReplicaSet membership +replSet = <%= @replset %> +<% end -%> +<% if @smallfiles -%> +# Use a smaller default data file size. +smallfiles = <%= @smallfiles %> +<% end -%> +<% if @rest -%> +# Enable rest API (disabled by default) +rest = <%= @rest %> +<% end -%> +<% if @profile -%> +# Modify this value to changes the level of database profiling, which inserts +# information about operation performance into output of mongod or the log file. +#0 = Off. No profiling. default +#1 = On. Only includes slow operations. +#2 = On. Includes all operations. +profile = <%= @profile %> +<% end -%> +<% if @slowms -%> +# Sets the threshold in milliseconds for mongod to consider a query slow for the profiler. +slowms = <%= @slowms %> +<% end -%> +<% if @keyfile -%> +# Specify the path to a key file to store authentication information. +keyFile = <%= @keyfile %> +<% end -%> +<% if @directoryperdb -%> +directoryperdb = <%= @directoryperdb %> +<% end -%> +<% if @set_parameter -%> +setParameter = <%= @set_parameter %> +<% end -%> +<% if @syslog -%> +syslog = <%= @syslog %> +<% end -%> diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/globals.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/globals.pp new file mode 100644 index 0000000000..8166214bb7 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/globals.pp @@ -0,0 +1,3 @@ +class { 'mongodb::globals': + manage_package_repo => true +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/init.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/init.pp new file mode 100644 index 0000000000..aac044ee0d --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/init.pp @@ -0,0 +1 @@ +class { '::mongodb': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/replicaset.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/replicaset.pp new file mode 100644 index 0000000000..a758b8dd26 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/replicaset.pp @@ -0,0 +1,16 @@ +node default { + class { '::mongodb::globals': + manage_package_repo => true + } -> + class { '::mongodb::server': + smallfiles => true, + bind_ip => ['0.0.0.0'], + replset => 'rsmain' + } +} + +node /mongo1/ inherits default { + mongodb_replset{'rsmain': + members => ['mongo1:27017', 'mongo2:27017', 'mongo3:27017'] + } +} diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/server.pp b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/server.pp new file mode 100644 index 0000000000..95106ebc98 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mongodb/tests/server.pp @@ -0,0 +1,2 @@ +class { 'mongodb::globals': manage_package_repo => true }-> +class { 'mongodb::server': } diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/.fixtures.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/.fixtures.yml new file mode 100644 index 0000000000..5631e2a231 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/.fixtures.yml @@ -0,0 +1,5 @@ +fixtures: + repositories: + "stdlib": "https://github.com/puppetlabs/puppetlabs-stdlib" + symlinks: + "mysql": "#{source_dir}" diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/.nodeset.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/.nodeset.yml new file mode 100644 index 0000000000..767f9cd2f6 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/.nodeset.yml @@ -0,0 +1,31 @@ +--- +default_set: 'centos-64-x64' +sets: + 'centos-59-x64': + nodes: + "main.foo.vm": + prefab: 'centos-59-x64' + 'centos-64-x64': + nodes: + "main.foo.vm": + prefab: 'centos-64-x64' + 'fedora-18-x64': + nodes: + "main.foo.vm": + prefab: 'fedora-18-x64' + 'debian-607-x64': + nodes: + "main.foo.vm": + prefab: 'debian-607-x64' + 'debian-70rc1-x64': + nodes: + "main.foo.vm": + prefab: 'debian-70rc1-x64' + 'ubuntu-server-10044-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-10044-x64' + 'ubuntu-server-12042-x64': + nodes: + "main.foo.vm": + prefab: 'ubuntu-server-12042-x64' diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/.travis.yml b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/.travis.yml new file mode 100644 index 0000000000..42aea59180 --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/.travis.yml @@ -0,0 +1,34 @@ +--- +branches: + only: + - master +language: ruby +bundler_args: --without development +script: "bundle exec rake spec SPEC_OPTS='--format documentation'" +after_success: + - git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-release + - .forge-release/publish +rvm: + - 1.8.7 + - 1.9.3 + - 2.0.0 +env: + matrix: + - PUPPET_GEM_VERSION="~> 2.7.0" + - PUPPET_GEM_VERSION="~> 3.3.0" + - PUPPET_GEM_VERSION="~> 3.4.0" + global: + - PUBLISHER_LOGIN=puppetlabs + - secure: |- + Hc9OPm/kRTmjXSP3TbLir/y6Yy1LqmZS8zrqxdTbpo3Z04EYv1uKhaFDpECl + 0a6bJRUWpLWIuDco08fHMeCTWoFGzE97EDelhHKSYiTNllzYKWPHy7ki/al6 + wjz0gLtiDfmktHQOHatBy6EKLFjoyjGoE4cUUta4Ixq4tMBNzEA= +matrix: + fast_finish: true + exclude: + - rvm: 1.9.3 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.0.0 + env: PUPPET_GEM_VERSION="~> 2.7.0" +notifications: + email: false diff --git a/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/CHANGELOG.md b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/CHANGELOG.md new file mode 100644 index 0000000000..8349998f3f --- /dev/null +++ b/vagrant/vms/phraseanet-php54-nginx/puphpet/puppet/modules/mysql/CHANGELOG.md @@ -0,0 +1,476 @@ +##2014-03-04 - Supported Release 2.2.3 +###Summary + +This is a supported release. This release removes a testing symlink that can +cause trouble on systems where /var is on a seperate filesystem from the +modulepath. + +####Features +####Bugfixes +####Known Bugs +* No known bugs + +##2014-03-04 - Supported Release 2.2.2 +###Summary +This is a supported release. Mostly comprised of enhanced testing, plus a +bugfix for Suse. + +####Bugfixes +- PHP bindings on Suse +- Test fixes + +####Known Bugs +* No known bugs + +##2014-02-19 - Version 2.2.1 + +###Summary + +Minor release that repairs mysql_database{} so that it sees the correct +collation settings (it was only checking the global mysql ones, not the +actual database and constantly setting it over and over since January 22nd). + +Also fixes a bunch of tests on various platforms. + + +##2014-02-13 - Version 2.2.0 + +###Summary + +####Features +- Add `backupdirmode`, `backupdirowner`, `backupdirgroup` to + mysql::server::backup to allow customizing the mysqlbackupdir. +- Support multiple options of the same name, allowing you to + do 'replicate-do-db' => ['base1', 'base2', 'base3'] in order to get three + lines of replicate-do-db = base1, replicate-do-db = base2 etc. + +####Bugfixes +- Fix `restart` so it actually stops mysql restarting if set to false. +- DRY out the defaults_file functionality in the providers. +- mysql_grant fixed to work with root@localhost/@. +- mysql_grant fixed for WITH MAX_QUERIES_PER_HOUR +- mysql_grant fixed so revoking all privileges accounts for GRANT OPTION +- mysql_grant fixed to remove duplicate privileges. +- mysql_grant fixed to handle PROCEDURES when removing privileges. +- mysql_database won't try to create existing databases, breaking replication. +- bind_address renamed bind-address in 'mysqld' options. +- key_buffer renamed to key_buffer_size. +- log_error renamed to log-error. +- pid_file renamed to pid-file. +- Ensure mysql::server:root_password runs before mysql::server::backup +- Fix options_override -> override_options in the README. +- Extensively rewrite the README to be accurate and awesome. +- Move to requiring stdlib 3.2.0, shipped in PE3.0 +- Add many new tests. + + +##2013-11-13 - Version 2.1.0 + +###Summary + +The most important changes in 2.1.0 are improvements to the my.cnf creation, +as well as providers. Setting options to = true strips them to be just the +key name itself, which is required for some options. + +The provider updates fix a number of bugs, from lowercase privileges to +deprecation warnings. + +Last, the new hiera integration functionality should make it easier to +externalize all your grants, users, and, databases. Another great set of +community submissions helped to make this release. + +####Features +- Some options can not take a argument. Gets rid of the '= true' when an +option is set to true. +- Easier hiera integration: Add hash parameters to mysql::server to allow +specifying grants, users, and databases. + +####Bugfixes +- Fix an issue with lowercase privileges in mysql_grant{} causing them to be reapplied needlessly. +- Changed defaults-file to defaults-extra-file in providers. +- Ensure /root/.my.cnf is 0600 and root owned. +- database_user deprecation warning was incorrect. +- Add anchor pattern for client.pp +- Documentation improvements. +- Various test fixes. + + +##2013-10-21 - Version 2.0.1 + +###Summary + +This is a bugfix release to handle an issue where unsorted mysql_grant{} +privileges could cause Puppet to incorrectly reapply the permissions on +each run. + +####Bugfixes +- Mysql_grant now sorts privileges in the type and provider for comparison. +- Comment and test tweak for PE3.1. + + +##2013-10-14 - Version 2.0.0 + +###Summary + +(Previously detailed in the changelog for 2.0.0-rc1) + +This module has been completely refactored and works significantly different. +The changes are broad and touch almost every piece of the module. + +See the README.md for full details of all changes and syntax. +Please remain on 1.0.0 if you don't have time to fully test this in dev. + +* mysql::server, mysql::client, and mysql::bindings are the primary interface +classes. +* mysql::server takes an `override_options` parameter to set my.cnf options, +with the hash format: { 'section' => { 'thing' => 'value' }} +* mysql attempts backwards compatibility by forwarding all parameters to +mysql::server. + + +##2013-10-09 - Version 2.0.0-rc5 + +###Summary + +Hopefully the final rc! Further fixes to mysql_grant (stripping out the +cleverness so we match a much wider range of input.) + +####Bugfixes +- Make mysql_grant accept '.*'@'.*' in terms of input for user@host. + + +##2013-10-09 - Version 2.0.0-rc4 + +###Summary + +Bugfixes to mysql_grant and mysql_user form the bulk of this rc, as well as +ensuring that values in the override_options hash that contain a value of '' +are created as just "key" in the conf rather than "key =" or "key = false". + +####Bugfixes +- Improve mysql_grant to work with IPv6 addresses (both long and short). +- Ensure @host users work as well as user@host users. +- Updated my.cnf template to support items with no values. + + +##2013-10-07 - Version 2.0.0-rc3 + +###Summary +Fix mysql::server::monitor's use of mysql_user{}. + +####Bugfixes +- Fix myql::server::monitor's use of mysql_user{} to grant the proper +permissions. Add specs as well. (Thanks to treydock!) + + +##2013-10-03 - Version 2.0.0-rc2 + +###Summary +Bugfixes + +####Bugfixes +- Fix a duplicate parameter in mysql::server + + +##2013-10-03 - Version 2.0.0-rc1 + +###Summary + +This module has been completely refactored and works significantly different. +The changes are broad and touch almost every piece of the module. + +See the README.md for full details of all changes and syntax. +Please remain on 1.0.0 if you don't have time to fully test this in dev. + +* mysql::server, mysql::client, and mysql::bindings are the primary interface +classes. +* mysql::server takes an `override_options` parameter to set my.cnf options, +with the hash format: { 'section' => { 'thing' => 'value' }} +* mysql attempts backwards compatibility by forwarding all parameters to +mysql::server. + +--- +##2013-09-23 - Version 1.0.0 + +###Summary + +This release introduces a number of new type/providers, to eventually +replace the database_ ones. The module has been converted to call the +new providers rather than the previous ones as they have a number of +fixes, additional options, and work with puppet resource. + +This 1.0.0 release precedes a large refactoring that will be released +almost immediately after as 2.0.0. + +####Features +- Added mysql_grant, mysql_database, and mysql_user. +- Add `mysql::bindings` class and refactor all other bindings to be contained underneath mysql::bindings:: namespace. +- Added support to back up specified databases only with 'mysqlbackup' parameter. +- Add option to mysql::backup to set the backup script to perform a mysqldump on each database to its own file + +####Bugfixes +- Update my.cnf.pass.erb to allow custom socket support +- Add environment variable for .my.cnf in mysql::db. +- Add HOME environment variable for .my.cnf to mysqladmin command when +(re)setting root password + +--- +##2013-07-15 - Version 0.9.0 +####Features +- Add `mysql::backup::backuprotate` parameter +- Add `mysql::backup::delete_before_dump` parameter +- Add `max_user_connections` attribute to `database_user` type + +####Bugfixes +- Add client package dependency for `mysql::db` +- Remove duplicate `expire_logs_days` and `max_binlog_size` settings +- Make root's `.my.cnf` file path dynamic +- Update pidfile path for Suse variants +- Fixes for lint + +##2013-07-05 - Version 0.8.1 +####Bugfixes + - Fix a typo in the Fedora 19 support. + +##2013-07-01 - Version 0.8.0 +####Features + - mysql::perl class to install perl-DBD-mysql. + - minor improvements to the providers to improve reliability + - Install the MariaDB packages on Fedora 19 instead of MySQL. + - Add new `mysql` class parameters: + - `max_connections`: The maximum number of allowed connections. + - `manage_config_file`: Opt out of puppetized control of my.cnf. + - `ft_min_word_len`: Fine tune the full text search. + - `ft_max_word_len`: Fine tune the full text search. + - Add new `mysql` class performance tuning parameters: + - `key_buffer` + - `thread_stack` + - `thread_cache_size` + - `myisam-recover` + - `query_cache_limit` + - `query_cache_size` + - `max_connections` + - `tmp_table_size` + - `table_open_cache` + - `long_query_time` + - Add new `mysql` class replication parameters: + - `server_id` + - `sql_log_bin` + - `log_bin` + - `max_binlog_size` + - `binlog_do_db` + - `expire_logs_days` + - `log_bin_trust_function_creators` + - `replicate_ignore_table` + - `replicate_wild_do_table` + - `replicate_wild_ignore_table` + - `expire_logs_days` + - `max_binlog_size` + +####Bugfixes + - No longer restart MySQL when /root/.my.cnf changes. + - Ensure mysql::config runs before any mysql::db defines. + +##2013-06-26 - Version 0.7.1 +####Bugfixes +- Single-quote password for special characters +- Update travis testing for puppet 3.2.x and missing Bundler gems + +##2013-06-25 - Version 0.7.0 +This is a maintenance release for community bugfixes and exposing +configuration variables. + +* Add new `mysql` class parameters: + - `basedir`: The base directory mysql uses + - `bind_address`: The IP mysql binds to + - `client_package_name`: The name of the mysql client package + - `config_file`: The location of the server config file + - `config_template`: The template to use to generate my.cnf + - `datadir`: The directory MySQL's datafiles are stored + - `default_engine`: The default engine to use for tables + - `etc_root_password`: Whether or not to add the mysql root password to + /etc/my.cnf + - `java_package_name`: The name of the java package containing the java + connector + - `log_error`: Where to log errors + - `manage_service`: Boolean dictating if mysql::server should manage the + service + - `max_allowed_packet`: Maximum network packet size mysqld will accept + - `old_root_password`: Previous root user password + - `php_package_name`: The name of the phpmysql package to install + - `pidfile`: The location mysql will expect the pidfile to be + - `port`: The port mysql listens on + - `purge_conf_dir`: Value fed to recurse and purge parameters of the + /etc/mysql/conf.d resource + - `python_package_name`: The name of the python mysql package to install + - `restart`: Whether to restart mysqld + - `root_group`: Use specified group for root-owned files + - `root_password`: The root MySQL password to use + - `ruby_package_name`: The name of the ruby mysql package to install + - `ruby_package_provider`: The installation suite to use when installing the + ruby package + - `server_package_name`: The name of the server package to install + - `service_name`: The name of the service to start + - `service_provider`: The name of the service provider + - `socket`: The location of the MySQL server socket file + - `ssl_ca`: The location of the SSL CA Cert + - `ssl_cert`: The location of the SSL Certificate to use + - `ssl_key`: The SSL key to use + - `ssl`: Whether or not to enable ssl + - `tmpdir`: The directory MySQL's tmpfiles are stored +* Deprecate `mysql::package_name` parameter in favor of +`mysql::client_package_name` +* Fix local variable template deprecation +* Fix dependency ordering in `mysql::db` +* Fix ANSI quoting in queries +* Fix travis support (but still messy) +* Fix typos + +##2013-01-11 - Version 0.6.1 +* Fix providers when /root/.my.cnf is absent + +##2013-01-09 - Version 0.6.0 +* Add `mysql::server::config` define for specific config directives +* Add `mysql::php` class for php support +* Add `backupcompress` parameter to `mysql::backup` +* Add `restart` parameter to `mysql::config` +* Add `purge_conf_dir` parameter to `mysql::config` +* Add `manage_service` parameter to `mysql::server` +* Add syslog logging support via the `log_error` parameter +* Add initial SuSE support +* Fix remove non-localhost root user when fqdn != hostname +* Fix dependency in `mysql::server::monitor` +* Fix .my.cnf path for root user and root password +* Fix ipv6 support for users +* Fix / update various spec tests +* Fix typos +* Fix lint warnings + +##2012-08-23 - Version 0.5.0 +* Add puppetlabs/stdlib as requirement +* Add validation for mysql privs in provider +* Add `pidfile` parameter to mysql::config +* Add `ensure` parameter to mysql::db +* Add Amazon linux support +* Change `bind_address` parameter to be optional in my.cnf template +* Fix quoting root passwords + +##2012-07-24 - Version 0.4.0 +* Fix various bugs regarding database names +* FreeBSD support +* Allow specifying the storage engine +* Add a backup class +* Add a security class to purge default accounts + +##2012-05-03 - Version 0.3.0 +* 14218 Query the database for available privileges +* Add mysql::java class for java connector installation +* Use correct error log location on different distros +* Fix set_mysql_rootpw to properly depend on my.cnf + +##2012-04-11 - Version 0.2.0 + +##2012-03-19 - William Van Hevelingen +* (#13203) Add ssl support (f7e0ea5) + +##2012-03-18 - Nan Liu +* Travis ci before script needs success exit code. (0ea463b) + +##2012-03-18 - Nan Liu +* Fix Puppet 2.6 compilation issues. (9ebbbc4) + +##2012-03-16 - Nan Liu +* Add travis.ci for testing multiple puppet versions. (33c72ef) + +##2012-03-15 - William Van Hevelingen +* (#13163) Datadir should be configurable (f353fc6) + +##2012-03-16 - Nan Liu +* Document create_resources dependency. (558a59c) + +##2012-03-16 - Nan Liu +* Fix spec test issues related to error message. (eff79b5) + +##2012-03-16 - Nan Liu +* Fix mysql service on Ubuntu. (72da2c5) + +##2012-03-16 - Dan Bode +* Add more spec test coverage (55e399d) + +##2012-03-16 - Nan Liu +* (#11963) Fix spec test due to path changes. (1700349) + +##2012-03-07 - François Charlier +* Add a test to check path for 'mysqld-restart' (b14c7d1) + +##2012-03-07 - François Charlier +* Fix path for 'mysqld-restart' (1a9ae6b) + +##2012-03-15 - Dan Bode +* Add rspec-puppet tests for mysql::config (907331a) + +##2012-03-15 - Dan Bode +* Moved class dependency between sever and config to server (da62ad6) + +##2012-03-14 - Dan Bode
Hello World!
+Puppet modules on this server: + + -- Apache + -- MySQL +