Puppet Class: wordpress::external_fact

Defined in:
manifests/external_fact.pp

Summary

Deploy files to forge an external fact named 'wordpress'

Overview

Note:

This class should be considered as private.

Parameters:

  • settings (Wordpress::Settings) (defaults to: {})

    Describes all availables settings in this module for all WordPress instances on this node. Defaults to empty hash.

  • hour_fact_update (Integer[1,23])

    Gives the approximate hour (between 1 and 23) when external fact is update (some random is added).



10
11
12
13
14
15
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
# File 'manifests/external_fact.pp', line 10

class wordpress::external_fact (
  Integer[1,23] $hour_fact_update,
  Wordpress::Settings $settings = {},
) {

  $_minute = fqdn_rand(59)
  $_fact_script_path = '/usr/local/sbin/external_fact_wordpress.rb'
  $_fact_output_yaml = '/opt/puppetlabs/facter/facts.d/wordpress.yaml'

  #used by template('/wordpress/external_fact_wordpress.rb.erb')
  $_wproot = $settings.reduce( {} ) |$memo, $value| {
    if $value[1]['ensure'] != 'absent' {
      $mykey = $value[0]
      $mypath = $value[1]['wproot']
      merge($memo,{ $mykey => $mypath })
    } else {
      $memo
    }
  }

  file { $_fact_script_path :
    ensure  => 'file',
    content => template('wordpress/external_fact_wordpress.rb.erb'),
    owner   => 0,
    group   => 0,
    mode    => '0755',
    notify  => Exec['update external fact wordpress'],
  }
  ->
  exec { 'update external fact wordpress':
    command     => "${_fact_script_path} > ${_fact_output_yaml}",
    user        => 'root',
    refreshonly => true,
  }

  cron { 'external_fact workpress update':
    command     => "${_fact_script_path} > ${_fact_output_yaml} &> /dev/null",
    environment => 'PATH=/usr/local/sbin:/usr/local/bin:/opt/puppetlabs/bin:/usr/sbin:/usr/bin:/sbin:/bin',
    user        => 'root',
    hour        => $hour_fact_update,
    minute      => $_minute,
  }

}