Puppet Class: foreman::puppetmaster

Inherits:
foreman::puppetmaster::params
Defined in:
manifests/puppetmaster.pp

Summary

Set up Foreman integration for a Puppetserver

Overview

This class includes the necessary scripts for Foreman on the puppetmaster and is intented to be added to your puppetmaster

Parameters:

  • foreman_url (Stdlib::HTTPUrl) (defaults to: $foreman::puppetmaster::params::foreman_url)

    The Foreman URL

  • enc (Boolean) (defaults to: $foreman::puppetmaster::params::enc)

    Whether to install the ENC script

  • receive_facts (Boolean) (defaults to: $foreman::puppetmaster::params::receive_facts)

    Whether to configure the ENC to send facts to Foreman

  • puppet_home (Stdlib::Absolutepath) (defaults to: $foreman::puppetmaster::params::puppet_home)

    The Puppet home where the YAML files with facts live. Used for the ENC script

  • reports (Boolean) (defaults to: $foreman::puppetmaster::params::reports)

    Whether to enable the report processor

  • puppet_user (String) (defaults to: $foreman::puppetmaster::params::puppet_user)

    The user used to run the Puppetserver

  • puppet_group (String) (defaults to: $foreman::puppetmaster::params::puppet_group)

    The group used to run the Puppetserver

  • puppet_basedir (Stdlib::Absolutepath) (defaults to: $foreman::puppetmaster::params::puppet_basedir)

    The directory used to install the report processor to

  • puppet_etcdir (Stdlib::Absolutepath) (defaults to: $foreman::puppetmaster::params::puppet_etcdir)

    The directory used to put the configuration in.

  • timeout (Integer) (defaults to: $foreman::puppetmaster::params::puppetmaster_timeout)

    The timeout to use on HTTP calls in the ENC script

  • report_timeout (Integer) (defaults to: $foreman::puppetmaster::params::puppetmaster_report_timeout)

    The timeout to use on HTTP calls in the report processor

  • ssl_ca (Variant[Enum[''], Stdlib::Absolutepath]) (defaults to: $foreman::puppetmaster::params::client_ssl_ca)

    The SSL CA file path to use

  • ssl_cert (Variant[Enum[''], Stdlib::Absolutepath]) (defaults to: $foreman::puppetmaster::params::client_ssl_cert)

    The SSL certificate file path to use

  • ssl_key (Variant[Enum[''], Stdlib::Absolutepath]) (defaults to: $foreman::puppetmaster::params::client_ssl_key)

    The SSL key file path to use



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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
# File 'manifests/puppetmaster.pp', line 34

class foreman::puppetmaster (
  Stdlib::HTTPUrl $foreman_url = $foreman::puppetmaster::params::foreman_url,
  Boolean $reports = $foreman::puppetmaster::params::reports,
  Boolean $enc = $foreman::puppetmaster::params::enc,
  Boolean $receive_facts = $foreman::puppetmaster::params::receive_facts,
  Stdlib::Absolutepath $puppet_home = $foreman::puppetmaster::params::puppet_home,
  String $puppet_user = $foreman::puppetmaster::params::puppet_user,
  String $puppet_group = $foreman::puppetmaster::params::puppet_group,
  Stdlib::Absolutepath $puppet_basedir = $foreman::puppetmaster::params::puppet_basedir,
  Stdlib::Absolutepath $puppet_etcdir = $foreman::puppetmaster::params::puppet_etcdir,
  Integer $timeout = $foreman::puppetmaster::params::puppetmaster_timeout,
  Integer $report_timeout = $foreman::puppetmaster::params::puppetmaster_report_timeout,
  Variant[Enum[''], Stdlib::Absolutepath] $ssl_ca = $foreman::puppetmaster::params::client_ssl_ca,
  Variant[Enum[''], Stdlib::Absolutepath] $ssl_cert = $foreman::puppetmaster::params::client_ssl_cert,
  Variant[Enum[''], Stdlib::Absolutepath] $ssl_key = $foreman::puppetmaster::params::client_ssl_key,
) inherits foreman::puppetmaster::params {

  case $facts['os']['family'] {
    'Debian': { $json_package = 'ruby-json' }
    default:  { $json_package = 'rubygem-json' }
  }

  ensure_packages([$json_package])

  file {"${puppet_etcdir}/foreman.yaml":
    content => template("${module_name}/puppet.yaml.erb"),
    mode    => '0640',
    owner   => 'root',
    group   => $puppet_group,
  }

  if $reports {   # foreman reporter

    exec { 'Create Puppet Reports dir':
      command => "/bin/mkdir -p ${puppet_basedir}/reports",
      creates => "${puppet_basedir}/reports",
    }
    file {"${puppet_basedir}/reports/foreman.rb":
      mode    => '0644',
      owner   => 'root',
      group   => '0',
      source  => "puppet:///modules/${module_name}/foreman-report_v2.rb",
      require => Exec['Create Puppet Reports dir'],
    }
  }

  if $enc {
    file { "${puppet_etcdir}/node.rb":
      source => "puppet:///modules/${module_name}/external_node_v2.rb",
      mode   => '0550',
      owner  => $puppet_user,
      group  => $puppet_group,
    }

    file { "${puppet_home}/yaml":
      ensure                  => directory,
      owner                   => $puppet_user,
      group                   => $puppet_group,
      mode                    => '0750',
      selinux_ignore_defaults => true,
    }

    file { "${puppet_home}/yaml/foreman":
      ensure => directory,
      owner  => $puppet_user,
      group  => $puppet_group,
      mode   => '0750',
    }

    file { "${puppet_home}/yaml/node":
      ensure => directory,
      owner  => $puppet_user,
      group  => $puppet_group,
      mode   => '0750',
    }

    file { "${puppet_home}/yaml/facts":
      ensure => directory,
      owner  => $puppet_user,
      group  => $puppet_group,
      mode   => '0750',
    }
  }
}