From 1e76112f11c009b7e77f4dde189f9984e3f2604f Mon Sep 17 00:00:00 2001 From: Troy Siedsma Date: Thu, 8 May 2014 18:59:45 -0500 Subject: [PATCH 1/3] Fixed tweaksettings Added cpanel.aug and the resource requirement as well as tweaked the tweaksettings function. --- README.md | 1 + cpanel/files/cpanel.aug | 39 ++++++++++++++++++++++++++++++++++++++ cpanel/manifests/cpanel.pp | 13 ++++++++++--- 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 cpanel/files/cpanel.aug diff --git a/README.md b/README.md index 29d16a4..d76fcf9 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ 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::baseconfig Allows you to pass a set options to update the /etc/wwacct.conf file 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..f7d2237 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,11 @@ } 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 baseconfig( From b0b91fc3a262f72da0efd04a5f974b71fe4e71e3 Mon Sep 17 00:00:00 2001 From: Troy Siedsma Date: Thu, 8 May 2014 22:48:16 -0500 Subject: [PATCH 2/3] enabled php.ini handling Added support for modifying php.ini via puppet and augeas. It works in a similar fashion to the tweak settings. --- README.md | 10 ++++++++++ cpanel/manifests/cpanel.pp | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/README.md b/README.md index d76fcf9..e20778c 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,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/manifests/cpanel.pp b/cpanel/manifests/cpanel.pp index f7d2237..07d111f 100644 --- a/cpanel/manifests/cpanel.pp +++ b/cpanel/manifests/cpanel.pp @@ -43,6 +43,24 @@ 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( $ns, $ns2, From 20838ebfdd5c1180c3188473d955d791a3586494 Mon Sep 17 00:00:00 2001 From: Troy Siedsma Date: Thu, 8 May 2014 22:49:53 -0500 Subject: [PATCH 3/3] Updated readme to reflect cpanel::updatephpini --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index e20778c..654f976 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ 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