Puppet Class: mcollective::server::config::factsource::yaml

Defined in:
manifests/server/config/factsource/yaml.pp

Overview

private class

Parameters:

  • path (Any) (defaults to: $::path)


2
3
4
5
6
7
8
9
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
54
55
56
57
58
59
60
61
62
63
64
65
# File 'manifests/server/config/factsource/yaml.pp', line 2

class mcollective::server::config::factsource::yaml (
  $path = $::path,
) {
  assert_private()

  $yaml_fact_path_real = $::mcollective::yaml_fact_path_real
  if defined('$is_pe') and str2bool($::is_pe) {
    $ruby_shebang_path = '/opt/puppet/bin/ruby'
  } else {
    $ruby_shebang_path = '/usr/bin/env ruby'
  }
  $yaml_fact_cron      = $::mcollective::yaml_fact_cron

  # Template uses:
  #   - $ruby_shebang_path
  #   - $yaml_fact_path_real
  if $yaml_fact_cron {
    if versioncmp($::facterversion, '3.0.0') >= 0 {
      cron { 'refresh-mcollective-metadata':
        command     => "facter --yaml >${yaml_fact_path_real} 2>&1",
        environment => 'PATH=/opt/puppet/bin:/opt/puppetlabs/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
        user        => 'root',
        minute      => [ '0', '15', '30', '45' ],
      }
      exec { 'create-mcollective-metadata':
        path    => "/opt/puppet/bin:/opt/puppetlabs/bin:${::path}",
        command => "facter --yaml >${yaml_fact_path_real} 2>&1",
        creates => $yaml_fact_path_real,
      }
    } else {
      file { "${::mcollective::site_libdir}/refresh-mcollective-metadata":
        owner   => '0',
        group   => '0',
        mode    => '0755',
        content => template('mcollective/refresh-mcollective-metadata.erb'),
      }

      # There is concern that cron jobs run with a reduced PATH, so we still
      # want to invoke this script with at least as full a path as the Puppet
      # service has itself. We want to avoid the environment parameter to set
      # PATH as environment is global. Therefore, prefix the command itself in
      # the cron job with the value of the PATH environment variable to use.
      cron { 'refresh-mcollective-metadata':
        command => "bash -c 'export PATH=${path}; ${::mcollective::site_libdir}/refresh-mcollective-metadata >/dev/null 2>&1'",
        user    => 'root',
        minute  => [ '0', '15', '30', '45' ],
        require => File["${::mcollective::site_libdir}/refresh-mcollective-metadata"],
      }

      exec { 'create-mcollective-metadata':
        path    => "/opt/puppet/bin:${::path}",
        command => "${::mcollective::site_libdir}/refresh-mcollective-metadata",
        creates => $yaml_fact_path_real,
        require => File["${::mcollective::site_libdir}/refresh-mcollective-metadata"],
      }
    }
    ::mcollective::server::setting { 'factsource':
      value => 'yaml',
    }
    ::mcollective::server::setting { 'plugin.yaml':
      value => $yaml_fact_path_real,
    }
  }
}