apache - moduli
Apache - Asentaa Apache2:n ja PHP:n. Lisää myös 'webadmin'-käyttäjän, jonka 'home' kansioon luo varsiaisen www-kansion, joka on linkitetty '/var/www/' kansioon. Ylläpitää Apache2:sta php-tuella.
Ladattavissa täältä.
Käyttöjärjestelmät:
Testattu seuraavilla käyttöjärjestelmillä:
Xubuntu 12.10 32-bit
Ubuntu 12.04 LTS 64-bit
Debian 6.0 64-bit
Rakenne:
apache ├── manifests │ ├── init.pp │ ├── install.pp │ ├── params.pp │ ├── service.pp │ ├── vhost.pp │ └── webadmin.pp ├── README └── templates └── vhost.conf.erb
README
######################### # Puppet module: apache # ######################### This module installs and manages apache2 and php. It also adds virtual host and user to control websites. ###################### # TODO before using # ###################### Check apache::params for wanted specifications. Change atleast '$webadmin_pass'. ################ # Sample usage # ################ 1. include apache 2. apache::vhost { 'website.com': port => '80', docroot => '/var/www/website.com', priority => '000', } ########## # Author # ########## Made by Sampo Tyllilä <sampo.tyllila@gmail.com> ########### # License # ########### This software is distributed under the GNU General Public License version 2 or any later version. http://www.gnu.org/licenses/
Manifests kansion sisältö:
init.pp
# == Class: apache # # This module manages apache2 and php. # # === Parameters # # There are no default parameters for this class. All module parameters are managed # via the apache::params class. # # === Examples # # See README for details. # # === Author # # Sampo Tyllilä# class apache { include apache::params, apache::install, apache::service, apache::webadmin }
install.pp
# == Class: apache::install # # This class installs apache2 and php. # # === Parameters # # [*package_apache*] - The name of apache2 package to install. # [*package_php*] - The name of php package to install. # # === Author # # Sampo Tyllilä# class apache::install { package { $apache::params::package_apache: ensure => latest, } package { $apache::params::package_php: ensure => latest, } }
service.pp
# == Class: apache::service # # This class manages APACHE2 service. # # === Parameters # # [*service*] - The name of the managed service. # # === Author # # Sampo Tyllilä# class apache::service { service { $apache::params::service: ensure => running, enable => true, require => Class['apache::install'], } }
webadmin.pp
# == Class: apache::webadmin # # This class manages user that is used to control websites. # # === Parameters # # [*webadmin*] - The user that is used to control wesites. # [*webadmin_pass*] - The password for the user that is used to control websites. # # === Author # # Sampo Tyllilä# class apache::webadmin { user { $apache::params::webadmin: ensure => present, shell => '/bin/bash', password => $apache::params::webadminpass, managehome => true, } }
params.pp
# == Class: apache::params # # This class manages apache modules parameters. # # === Parameters # # [*package_apache*] - The name of apache2 package to install. # [*service*] - The name of apache2 service. # [*package_php*] - The name of php package to install. # [*webadmin*] - The name of the user that is used to control wesites. # [*webadmin_pass*] - The password for the user that is used to control websites. # # === Author # # Sampo Tyllilä# class apache::params { $package_apache = ['apache2', 'apache2.2-common'] $service = 'apache2' $package_php = ['php5', 'libapache2-mod-php5', 'php5-mysql'] $webadmin = 'webadmin' $webadminpass = '$6$PassHash' }
vhost.pp
# == Define: apahce::vhost # # This class installs Apache Virtual Hosts # # === Parameters # # [*port*] - The port to configure the host on. # [*docroot*] - The docroot for the virtual host. # [*priority*] - The priority of the virtual host. # [*template*] - The tempate to use to create vhost. # [*name*] - The virtual hosts name. # [*webadmin*] - The name of the user that is used to control wesites. # # === Author # # Sampo Tyllilä# define apache::vhost ( $port, $docroot, $priority, $virtualhost = '*', $template = 'apache/vhost.conf.erb' ) { include apache file { '/etc/apache2/sites-enabled/000-default': ensure => absent, } file { "/etc/apache2/sites-available/${name}": ensure => file, content => template($template), owner => 'root', group => 'root', mode => '0644', require => Class['apache::install'], notify => Class['apache::service'], } file { "/etc/apache2/sites-enabled/${priority}-${name}": ensure => link, target => "/etc/apache2/sites-available/${name}", require => File["/etc/apache2/sites-available/${name}"], } file { "/home/${apache::params::webadmin}/${name}": ensure => directory, replace => false, owner => $apache::params::webadmin, group => $apache::params::webadmin, mode => '0644', require => Class['apache::webadmin'], } file { $docroot: ensure => link, target => "/home/${apache::params::webadmin}/${name}", require => File["/home/${apache::params::webadmin}/${name}"], } }
Templates kansion sisältö:
vhost.conf.erb
# MANAGED BY PUPPET! # <VirtualHost <%= virtualhost %>:<%= port %>> ServerAdmin webmaster@localhost DocumentRoot <%= docroot %> <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory <%= docroot %>> Options FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ServerSignature Off </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/<%= name %>_error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/<%= name %>_access.log combined </VirtualHost>