diff --git a/README.md b/README.md index 29d16a4..654f976 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ easyapache recompile if a change is detected with the configuration file. ###cpanel::tweaksettings Allows you to pass key => value pairs for the cpanel.config file and automatically updates your tweak settings if a change is detected. +(note: some keys in the cpanel.config do not have values, this puppet module does not support those options at this time) + +###cpanel::updatephpini +Allows you to pass key => value pairs for php.ini and automatically restarts apache to apply the changes only if the values are changed ###cpanel::baseconfig Allows you to pass a set options to update the /etc/wwacct.conf file @@ -38,6 +42,16 @@ Examples }, email => 'scott@cpanel.net' } + + cpanel::updatephpini { 'puppet': + options => { + 'post_max_size' => '64M', + 'max_execution_time' => '60', + 'memory_limit' => '96M', + 'max_input_time' => '60', + 'upload_max_filesize' => '64M', + }, + } cpanel::baseconfig { 'puppet': ns => 'test-a.cpanel.net', diff --git a/cpanel/files/cpanel.aug b/cpanel/files/cpanel.aug new file mode 100644 index 0000000..1f9eb2b --- /dev/null +++ b/cpanel/files/cpanel.aug @@ -0,0 +1,39 @@ +(* +Module: CPanel + Parses cpanel.config + +Author: Raphael Pinson + +About: Reference + This lens parses cpanel.config files + +About: License + This file is licenced under the LGPL v2+, like the rest of Augeas. + +About: Lens Usage + To be documented + +About: Configuration files + This lens applies to cpanel.config files. See . + +About: Examples + The file contains various examples and tests. +*) +module CPanel = + +autoload xfm + +(* View: kv + A key-value pair, supporting flags and empty values *) +let kv = [ key /[A-Za-z0-9:_.-]+/ + . (Sep.equal . store (Rx.space_in?))? + . Util.eol ] + +(* View: lns + The lens *) +let lns = (Util.comment | Util.empty | kv)* + +(* View: filter *) +let filter = incl "/var/cpanel/cpanel.config" + +let xfm = transform lns filter \ No newline at end of file diff --git a/cpanel/manifests/cpanel.pp b/cpanel/manifests/cpanel.pp index 7b5552f..07d111f 100644 --- a/cpanel/manifests/cpanel.pp +++ b/cpanel/manifests/cpanel.pp @@ -16,6 +16,13 @@ } } define tweaksetting( $options, $email ) { + file { '/usr/share/augeas/lenses/dist/cpanel.aug': + ensure => 'file', + mode => 644, + source => 'puppet:///modules/cpanel/cpanel.aug', + owner => 'root', + group => 'root', + } internalupdatecpanelconfig { [ hash_keys($options) ]: options => $options } @@ -29,11 +36,29 @@ } define internalupdatecpanelconfig( $options ) { augeas { $title: - lens => 'PHP.lns', + lens => 'CPanel.lns', incl => '/var/cpanel/cpanel.config', - context => '/files/var/cpanel/cpanel.config/.anon', changes => "set ${title} ${options[$title]}", - notify => Exec['runtweaksetting'] + notify => Exec['runtweaksetting'], + require => File['/usr/share/augeas/lenses/dist/cpanel.aug'], + } + } + define updatephpini ( $options ) { + internalupdatephpini { [ hash_keys($options) ]: + options => $options + }~> + service { 'cpanel_httpd': + name => 'httpd', + ensure => 'true', + enable => 'true', + } + } + define internalupdatephpini( $options ) { + augeas { $title: + lens => 'PHP.lns', + incl => '/usr/local/lib/php.ini', + context => "/files/usr/local/lib/php.ini/PHP", + changes => "set ${title} ${options[$title]}", } } define baseconfig(