From ef66fa07dc578f601cf9b67cb0ebd24dcaa6ac35 Mon Sep 17 00:00:00 2001 From: Thomas Bellman <bellman@nsc.liu.se> Date: Wed, 5 Feb 2014 19:08:05 +0100 Subject: [PATCH] Add basic installation of Apache web server. This adds the classes 'apache', containing variables for various files and directories that Apache uses, and 'apache::base', doing the basic installation of the Apache package and starting of the service. --- manifests/init.pp | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 manifests/init.pp diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..f6734be --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,60 @@ +# Copyright (C) 2012 Thomas Bellman. +# Licensed under the GNU LGPL v3+; see the README file for more information. + + +import "nsc-puppet-utils" + + +/* + * Various Apache httpd constants. + * Mostly expected to be used internally by the classes and definitions + * below. + */ +class apache +{ + $configfile = '/etc/httpd/conf/httpd.conf' + $configdir = '/etc/httpd/conf.d' +} + + + +/* + * Basic installation of the Apache web server. + * + * This disables the reading of all everything in the conf.d directory, + * which the standard Apache configuration file in RedHat:is OS:es + * does, instead forcing users to explicitly load only those files + * they need. It will also remove all unmanaged files from that + * directory. + */ +class apache::base +{ + include apache + + package { + 'httpd': + ensure => installed; + } + file { + # Keep the conf.d directory clean from all config files except for + # the ones explicitly managed from Puppet. + $apache::configdir: + ensure => directory, + recurse => true, purge => true, force => true, backup => false, + require => Package['httpd'], notify => Service['httpd']; + } + # We do not want to blindly include things in the conf.d directory. + ensure_line { + 'apache::base::no_include_all': + file => $apache::configfile, + line => '##--Include conf.d/*.conf', + pattern => '^\s*Include\s+conf\.d/\*\.conf\s*$', + require => Package['httpd'], + notify => Service['httpd']; + } + service { + 'httpd': + enable => true, ensure => $running, + hasstatus => true, hasrestart => true; + } +} -- GitLab