Puppet Class: psick::php::tp

Defined in:
manifests/php/tp.pp

Summary

This class manages php with Tiny Puppet (tp)

Overview

psick::php::tp

When you include this class the relevant tp::install define is declared which is expected to install php package and manage its service. Via the resources_hash parameter is possible to pass hashes of tp::conf and tp::dir defines which can manage php configuration files and whole dirs. All the parameters ending with the _hash suffix expect and Hash and are looked up on Hiera via the deep merge lookup option.

Examples:

Just include it to install php

include psick::php::tp

Include via psick module classification (yaml)

psick::profiles::linux_classes:
  php: psick::php::tp

To use upstream repos instead of OS defaults (if tinydata available) as packages source:

psick::php::tp::upstream_repo: true

Manage extra configs via hiera (yaml) with templates based on custom options

psick::php::tp::ensure: present
psick::php::tp::resources:
  tp::conf:
    php:
      epp: profile/php/php.conf.epp
    php::dot.conf:
      epp: profile/php/dot.conf.epp
      base_dir: conf
  exec:
    php::setup:
      command: '/usr/local/bin/php_setup'
      creates: '/opt/php'
psick::php::tp::options:
  key: value

Enable default auto configuration, if configurations are available

for the underlying system and the given auto_conf value, they are
automatically added.
psick::php::tp::auto_conf: true

Parameters:

  • manage (Boolean) (defaults to: true)

    If to actually manage any resource in this profile or not.

  • ensure (Psick::Ensure) (defaults to: 'present')

    If to install or remove php. Valid values are present, absent, latest or any version string, matching the expected php package version.

  • upstream_repo (Optional[Boolean]) (defaults to: undef)

    If to use php upstream repos as source for packages or rely on default packages from the underlying OS.

  • install_hash (Hash) (defaults to: {})

    An hash of valid params to pass to tp::install defines. Useful to manage specific params that are not automatically defined.

  • options

    An open hash of options to use in the templates referenced in the tp::conf entries of the $resources_hash.

  • settings_hash (Hash) (defaults to: {})

    An hash of tp settings to override default php file paths, package names, repo info and whatever tinydata that matches Tp::Settings data type: github.com/example42/puppet-tp/blob/master/types/settings.pp.

  • auto_conf (Boolean) (defaults to: false)

    If to enable automatic configuration of php based on the resources_auto_conf_hash and options_auto_conf_hash parameters, if present in data/common/php.yaml. You can both override them in your Hiera files and merge them with your resources and options.

  • resources_auto_conf_hash (Hash) (defaults to: {})

    The default resources hash if auto_conf is true. The final resources managed are the ones specified here and in $resources. Check psick::php::tp::resources_auto_conf_hash in data/common/php.yaml for the auto_conf defaults.

  • options_auto_conf_hash (Hash) (defaults to: {})

    The default options hash if auto_conf is set. Check psick::php::tp::options_auto_conf_hash in data/common/php.yaml for the auto_conf defaults.

  • resources

    An hash of any resource, like tp::conf, tp::dir, exec or whatever to declare for php confiuration. Can also come from a third-party component modules with dedicated php resources. tp::conf params: github.com/example42/puppet-tp/blob/master/manifests/conf.pp tp::dir params: github.com/example42/puppet-tp/blob/master/manifests/dir.pp any other Puppet resource type, with relevant params can be actually used The Hiera lookup method used for this parameter is defined with the $resource_lookup_method parameter.

  • resource_lookup_method

    What lookup method to use for psick::php::tp::resources

  • resources_defaults (Hash) (defaults to: {})

    An Hash of resources with their default params, to be merged with $resources.

  • auto_prereq (Boolean) (defaults to: true)

    If to automatically install eventual dependencies for php. Set to false if you have problems with duplicated resources, being sure that you manage the prerequistes to install php (other packages, repos or tp installs).

  • noop_manage (Boolean) (defaults to: false)

    If to manage noop mode via the noop() function for the resources of this class. This must be true for noop_value to have effect.

  • noop_value.

    The parameter passed to the noop() function (from trlinkin-noop module) When true, noop in enforced on all the class’ resources. When false, no-noop in enforced on all the class’ resources and overrides any other noop setting (also from clients’ puppet.conf

  • resources_lookup_method (Enum['first','deep','hash']) (defaults to: 'deep')
  • options_lookup_method (Enum['first','deep','hash']) (defaults to: 'deep')
  • noop_value (Boolean) (defaults to: false)


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'manifests/php/tp.pp', line 93

class psick::php::tp (
  Psick::Ensure $ensure                   = 'present',
  Boolean            $manage                   = true,
  Optional[Boolean]  $upstream_repo            = undef,

  Hash               $install_hash             = {},
  Hash               $settings_hash            = {},

# This param is looked up in code according to $resources_lookup_method
#  Hash               $resources                = {},
  Hash               $resources_defaults       = {},
  Enum['first','deep','hash'] $resources_lookup_method = 'deep',

# This param is looked up in code according to $options_lookup_method
#  Hash               $options                 = {},
  Enum['first','deep','hash'] $options_lookup_method = 'deep',

  Boolean            $auto_conf                = false,
  Hash               $resources_auto_conf_hash = {},
  Hash               $options_auto_conf_hash   = {},

  Boolean            $auto_prereq              = true,

  Boolean            $noop_manage              = false,
  Boolean            $noop_value               = false,
) {
  $options=lookup('psick::php::tp::options', Hash, $options_lookup_method, {})

  if $manage {
    if $noop_manage {
      noop($noop_value)
    }
    $options_all = $auto_conf ? {
      true  => $options_auto_conf_hash + $options,
      false => $options,
    }

    $install_defaults = {
      ensure        => $ensure,
      options_hash  => $options_all,
      settings_hash => $settings_hash,
      auto_repo     => $auto_prereq,
      auto_prereq   => $auto_prereq,
      upstream_repo => $upstream_repo,
    }
    tp::install { 'php':
      * => $install_defaults + $install_hash,
    }

    $file_ensure = $ensure ? {
      'absent' => 'absent',
      default  => 'present',
    }
    $dir_ensure = $ensure ? {
      'absent' => 'absent',
      default  => 'directory',
    }

    # Declaration of psick::php::tp::resources
    $resources=lookup('psick::php::tp::resources', Hash, $resources_lookup_method, {})
    $resources.each |String $resource_type, Hash $content| {
      $resources_all = $auto_conf ? {
        true  => pick($resources_auto_conf_hash[$resource_type], {}) + pick($resources[$resource_type], {}),
        false => pick($resources[$resource_type], {}),
      }
      $resources_all.each |String $resource_name, Hash $resource_params| {
        $resources_params_default = $resource_type ? {
          'tp::conf' => {
            ensure        => $file_ensure,
            options_hash  => $options_all,
            settings_hash => $settings_hash,
          },
          'tp::dir' => {
            ensure        => $dir_ensure,
            settings_hash => $settings_hash,
          },
          'exec' => {
            path => $facts['path'],
          },
          'file' => {
            ensure        => $file_ensure,
          },
          'package' => {
            ensure        => $file_ensure,
          },
          default => {},
        }
        $resource_params_all = deep_merge($resources_defaults[$resource_type], $resources_params_default, $resource_params)
        ensure_resource($resource_type,$resource_name,$resource_params_all)
      }
    }
  }
}