Puppet Class: r_profile::webapp::php_config

Defined in:
manifests/webapp/php_config.pp

Overview

R_profile::Webapp::Php_config

write PHP configuration file settings

“‘puppet config_filename =>

owner => 'user',  # config file owner
group => 'group', # config file group
mode  => '0640',  # config file permissions
notify => RES,    # resources to notify on change
defines   => {,  # PHP define KVPs to write in key=>value format
vars      => {},  # PHP variable KVPs to write in key=>value format

} “‘

Parameters:

  • configs (Any) (defaults to: hiera('r_profile::webapp::php_config', {}))

    Hash of configuration filenames and values to write:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'manifests/webapp/php_config.pp', line 16

class r_profile::webapp::php_config(
    $configs = hiera('r_profile::webapp::php_config', {}),
) {

  $configs.keys.each | $config | {
    $notify = pick($configs[$config]['notify'], false)
    if $notify {
      $_notify = $notify
    } else {
      $_notify = undef
    }

    $file_mode = pick($configs[$config]['mode'], '0644')
    file { $config:
      ensure => file,
      owner  => pick($configs[$config]['owner'], 'root'),
      group  => pick($configs[$config]['group'], 'root'),
      mode   => $file_mode,
      notify => $_notify,
    }

    # defined values
    if $configs[$config]['defines'] {
      $configs[$config]['defines'].keys.sort.each | $def | {
        file_line { "${config}_${def}":
          ensure => present,
          path   => $config,
          line   => "define( '${def}', '${configs[$config]['defines'][$def]}' );",
          match  => "^define( '${def}'",
          notify => $_notify,
        }
      }
    }

    # variables
    if $configs[$config]['vars'] {
      $configs[$config]['vars'].keys.sort.each | $v | {

        file_line { "${config}_${v}":
          ensure => present,
          path   => $config,
          line   => "\$${v} = '${configs[$config]['vars'][$v]}';",
          match  => "^\\\$${v}\s*=",
          notify => $_notify,
        }
      }
    }
  }
}