Add apache puppet resource

Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
This commit is contained in:
Bogdan Dobrelya 2015-07-23 13:48:02 +02:00
parent 46d519a4fb
commit dc400bf9d9
5 changed files with 326 additions and 0 deletions

View File

@ -0,0 +1,4 @@
# Apache puppet resource
This class installs Apache and manages apache service.
Defaults provided for Debian OS family.

View File

@ -0,0 +1,5 @@
class {'apache':
service_enable => false,
service_ensure => 'stopped',
package_ensure => 'absent',
}

View File

@ -0,0 +1,120 @@
$resource = hiera($::resource_name)
$apache_name = $resource['input']['apache_name']['value']
$service_name = $resource['input']['service_name']['value']
$default_mods = $resource['input']['default_mods']['value']
$default_vhost = $resource['input']['default_vhost']['value']
$default_charset = $resource['input']['default_charset']['value']
$default_confd_files = $resource['input']['default_confd_files']['value']
$default_ssl_vhost = $resource['input']['default_ssl_vhost']['value']
$default_ssl_cert = $resource['input']['default_ssl_cert']['value']
$default_ssl_key = $resource['input']['default_ssl_key']['value']
$default_ssl_chain = $resource['input']['default_ssl_chain']['value']
$default_ssl_ca = $resource['input']['default_ssl_ca']['value']
$default_ssl_crl_path = $resource['input']['default_ssl_crl_path']['value']
$default_ssl_crl = $resource['input']['default_ssl_crl']['value']
$default_ssl_crl_check = $resource['input']['default_ssl_crl_check']['value']
$default_type = $resource['input']['default_type']['value']
$ip = $resource['input']['ip']['value']
$service_restart = $resource['input']['service_restart']['value']
$purge_configs = $resource['input']['purge_configs']['value']
$purge_vhost_dir = $resource['input']['purge_vhost_dir']['value']
$purge_vdir = $resource['input']['purge_vdir']['value']
$serveradmin = $resource['input']['serveradmin']['value']
$sendfile = $resource['input']['sendfile']['value']
$error_documents = $resource['input']['error_documents']['value']
$timeout = $resource['input']['timeout']['value']
$httpd_dir = $resource['input']['httpd_dir']['value']
$server_root = $resource['input']['server_root']['value']
$conf_dir = $resource['input']['conf_dir']['value']
$confd_dir = $resource['input']['confd_dir']['value']
$vhost_dir = $resource['input']['vhost_dir']['value']
$vhost_enable_dir = $resource['input']['vhost_enable_dir']['value']
$mod_dir = $resource['input']['mod_dir']['value']
$mod_enable_dir = $resource['input']['mod_enable_dir']['value']
$mpm_module = $resource['input']['mpm_module']['value']
$lib_path = $resource['input']['lib_path']['value']
$conf_template = $resource['input']['conf_template']['value']
$servername = $resource['input']['servername']['value']
$manage_user = $resource['input']['manage_user']['value']
$manage_group = $resource['input']['manage_group']['value']
$user = $resource['input']['user']['value']
$group = $resource['input']['group']['value']
$keepalive = $resource['input']['keepalive']['value']
$keepalive_timeout = $resource['input']['keepalive_timeout']['value']
$max_keepalive_requests = $resource['input']['max_keepalive_requests']['value']
$logroot = $resource['input']['logroot']['value']
$logroot_mode = $resource['input']['logroot_mode']['value']
$log_level = $resource['input']['log_level']['value']
$log_formats = $resource['input']['log_formats']['value']
$ports_file = $resource['input']['ports_file']['value']
$docroot = $resource['input']['docroot']['value']
$apache_version = $resource['input']['apache_version']['value']
$server_tokens = $resource['input']['server_tokens']['value']
$server_signature = $resource['input']['server_signature']['value']
$trace_enable = $resource['input']['trace_enable']['value']
$allow_encoded_slashes = $resource['input']['allow_encoded_slashes']['value']
$package_ensure = $resource['input']['package_ensure']['value']
$use_optional_includes = $resource['input']['use_optional_includes']['value']
class {'apache':
apache_name => $apache_name,
service_name => $service_name,
default_mods => $default_mods,
default_vhost => $default_vhost,
default_charset => $default_charset,
default_confd_files => $default_confd_files,
default_ssl_vhost => $default_ssl_vhost,
default_ssl_cert => $default_ssl_cert,
default_ssl_key => $default_ssl_key,
default_ssl_chain => $default_ssl_chain,
default_ssl_ca => $default_ssl_ca,
default_ssl_crl_path => $default_ssl_crl_path,
default_ssl_crl => $default_ssl_crl,
default_ssl_crl_check => $default_ssl_crl_check,
default_type => $default_type,
ip => $ip,
service_enable => true,
service_manage => true,
service_ensure => 'running',
service_restart => $service_restart,
purge_configs => $purge_configs,
purge_vhost_dir => $purge_vhost_dir,
purge_vdir => $purge_vdir,
serveradmin => $serveradmin,
sendfile => $sendfile,
error_documents => $error_documents,
timeout => $timeout,
httpd_dir => $httpd_dir,
server_root => $server_root,
conf_dir => $conf_dir,
confd_dir => $confd_dir,
vhost_dir => $vhost_dir,
vhost_enable_dir => $vhost_enable_dir,
mod_dir => $mod_dir,
mod_enable_dir => $mod_enable_dir,
mpm_module => $mpm_module,
lib_path => $lib_path,
conf_template => $conf_template,
servername => $servername,
manage_user => $manage_user,
manage_group => $manage_group,
user => $user,
group => $group,
keepalive => $keepalive,
keepalive_timeout => $keepalive_timeout,
max_keepalive_requests => $max_keepalive_requests,
logroot => $logroot,
logroot_mode => $logroot_mode,
log_level => $log_level,
log_formats => $log_formats,
ports_file => $ports_file,
docroot => $docroot,
apache_version => $apache_version,
server_tokens => $server_tokens,
server_signature => $server_signature,
trace_enable => $trace_enable,
allow_encoded_slashes => $allow_encoded_slashes,
package_ensure => $package_ensure,
use_optional_includes => $use_optional_includes,
}

View File

@ -0,0 +1,186 @@
id: cinder_scheduler_puppet
handler: puppet
puppet_module: cinder_scheduler
version: 1.0.0
input:
apache_name:
schema: str
value: 'apache2'
service_name:
schema: str
value: 'apache2'
default_mods:
schema: bool
value: true
default_vhost:
schema: bool
value: true
default_charset:
schema: str
value: ''
default_confd_files:
schema: bool
value: true
default_ssl_vhost:
schema: bool
value: false
default_ssl_cert:
schema: str
value: '/etc/ssl/certs/ssl-cert-snakeoil.pem'
default_ssl_key:
schema: str
value: '/etc/ssl/private/ssl-cert-snakeoil.key'
default_ssl_chain:
schema: str
value: ''
default_ssl_ca:
schema: str
value: ''
default_ssl_crl_path:
schema: str
value: ''
default_ssl_crl:
schema: str
value: ''
default_ssl_crl_check:
schema: str
value: ''
default_type:
schema: str
value: 'none'
service_restart:
schema: str
value: 'restart'
purge_configs:
schema: bool
value: true
purge_vhost_dir:
schema: str
value: ''
purge_vdir:
schema: bool
value: false
serveradmin:
schema: str
value: 'root@localhost'
sendfile:
schema: str
value: 'On'
error_documents:
schema: bool
value: false
timeout:
schema: int
value: 120
httpd_dir:
schema: str
value: '/etc/apache2'
server_root:
schema: str
value: '/etc/apache2'
conf_dir:
schema: str
value: '/etc/apache2'
confd_dir:
schema: str
value: '/etc/apache2/conf.d'
vhost_dir:
schema: str
value: '/etc/apache2/sites-available'
vhost_enable_dir:
schema: str
value: '/etc/apache2/sites-enabled'
mod_dir:
schema: str
value: '/etc/apache2/mods-available'
mod_enable_dir:
schema: str
value: '/etc/apache2/mods-enabled'
mpm_module:
schema: str
value: 'worker'
lib_path:
schema: str
value: '/usr/lib/apache2/modules'
conf_template:
schema: str
value: 'apache/httpd.conf.erb'
servername:
schema: str!
value: ''
manage_user:
schema: bool
value: true
manage_group:
schema: bool
value: true
user:
schema: str
value: 'www-data'
group:
schema: str
value: 'www-data'
keepalive:
schema: str
value: 'Off'
keepalive_timeout:
schema: int
value: 15
max_keepalive_requests:
schema: int
value: 100
logroot:
schema: str
value: '/var/log/apache2'
logroot_mode:
schema: str
value: '0640'
log_level:
schema: str
value: 'warn'
log_formats:
schema: {}
value: {}
ports_file:
schema: str
value: '/etc/apache2/ports.conf'
docroot:
schema: str
value: '/srv/www'
apache_version:
schema: str
value: '2.4'
server_tokens:
schema: str
value: 'OS'
server_signature:
schema: str
value: 'On'
trace_enable:
schema: str
value: 'On'
allow_encoded_slashes:
schema: str
value: ''
package_ensure:
schema: str
value: 'installed'
use_optional_includes:
schema: bool
value: false
git:
schema: {repository: str!, branch: str!}
value: {repository: 'https://github.com/puppetlabs/puppetlabs-apache.git', branch: '1.5.0'}
ip:
schema: str!
value:
ssh_key:
schema: str!
value:
ssh_user:
schema: str!
value:
tags: [resource/apache_service, resources/apache]

View File

@ -0,0 +1,11 @@
import requests
from solar.core.log import log
def test(resource):
log.debug('Testing apache_puppet')
requests.get(
'http://%s:%s' % (resource.args['ip'].value, 80)
)