Skip to content

Commit aeeb5f6

Browse files
committed
Add php augeas lense
References hercules-team/augeas#35
1 parent 7d235e1 commit aeeb5f6

File tree

3 files changed

+114
-2
lines changed

3 files changed

+114
-2
lines changed

files/php.aug

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
(* PHP module for Augeas *)
2+
(* Author: Raphael Pinson <[email protected]> *)
3+
(* *)
4+
5+
module PHP =
6+
autoload xfm
7+
8+
(************************************************************************
9+
* INI File settings
10+
*************************************************************************)
11+
12+
let comment = IniFile.comment IniFile.comment_re IniFile.comment_default
13+
let sep = IniFile.sep IniFile.sep_re IniFile.sep_default
14+
let empty = IniFile.empty
15+
16+
17+
(************************************************************************
18+
* ENTRY
19+
*
20+
* We have to remove the keyword "section" from possible entry keywords
21+
* otherwise it would lead to an ambiguity with the "section" label
22+
* since PHP allows entries outside of sections.
23+
*************************************************************************)
24+
let entry =
25+
let word = IniFile.entry_re
26+
in let entry_re = word . ( "[" . word . "]" )?
27+
in IniFile.indented_entry entry_re sep comment
28+
29+
30+
(************************************************************************
31+
* TITLE
32+
*
33+
* We use IniFile.title_label because there can be entries
34+
* outside of sections whose labels would conflict with section names
35+
*************************************************************************)
36+
let title = IniFile.title ( IniFile.record_re - ".anon" )
37+
let record = IniFile.record title entry
38+
39+
let record_anon = [ label ".anon" . ( entry | empty )+ ]
40+
41+
42+
(************************************************************************
43+
* LENS & FILTER
44+
* There can be entries before any section
45+
* IniFile.entry includes comment management, so we just pass entry to lns
46+
*************************************************************************)
47+
let lns = record_anon? . record*
48+
49+
let filter = (incl "/etc/php*/*/*.ini")
50+
. (incl "/etc/php.ini")
51+
. (incl "/etc/php.d/*.ini")
52+
(* PHPFPM Support *)
53+
. (incl "/etc/php*/fpm/pool.d/*.conf")
54+
(* Zend Community edition *)
55+
. (incl "/usr/local/zend/etc/php.ini")
56+
. (incl "/usr/local/zend/etc/conf.d/*.ini")
57+
. Util.stdexcl
58+
59+
let xfm = transform lns filter

manifests/augeas.pp

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# == Class: php::augeas
2+
#
3+
# php augeas class
4+
#
5+
# Ensure that the php augeas lense is loaded
6+
#
7+
# This lense supports php fpm format
8+
#
9+
# === Parameters
10+
#
11+
# No parameters
12+
#
13+
# === Variables
14+
#
15+
# No variables
16+
#
17+
# === Examples
18+
#
19+
# include php::augeas
20+
#
21+
# === Authors
22+
#
23+
# Christian "Jippi" Winther <[email protected]>
24+
#
25+
# === Copyright
26+
#
27+
# Copyright 2012-2013 Christian "Jippi" Winther, unless otherwise noted.
28+
#
29+
class php::augeas {
30+
31+
if !defined(File['/usr/share/augeas/lenses/contrib']) {
32+
file { "/usr/share/augeas/lenses/contrib":
33+
ensure => directory,
34+
recurse => true,
35+
purge => true,
36+
force => true,
37+
mode => '0644',
38+
owner => "root",
39+
group => "root"
40+
}
41+
}
42+
43+
file { '/usr/share/augeas/lenses/contrib/php.aug':
44+
ensure => present,
45+
source => 'puppet:///modules/php/php.aug',
46+
require => File['/usr/share/augeas/lenses/contrib']
47+
}
48+
49+
}

manifests/config.pp

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@
3434
$settings
3535
) {
3636

37+
include php::augeas
38+
3739
augeas { "php-${name}-config":
38-
context => "/files${inifile}",
39-
changes => template('php/augeas_commands.erb')
40+
context => "/files${inifile}",
41+
load_path => '/usr/share/augeas/lenses/contrib/',
42+
changes => template('php/augeas_commands.erb'),
43+
require => Class['php::augeas']
4044
}
4145

4246
}

0 commit comments

Comments
 (0)