Puppet Class: r_profile::puppet::master::proxy

Inherits:
r_profile::puppet::params
Defined in:
manifests/puppet/master/proxy.pp

Overview

R_profile::Puppet::Proxy

Enable a Puppet Enterprise Master to work with a proxy server

Parameters:

  • proxy (Any) (defaults to: hiera("r_profile::puppet::master::proxy::proxy", false))

    proxy server to use in the form user@pass:proxyhost:proxyport or false to not use a proxy server



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
66
67
68
69
70
71
72
73
74
# File 'manifests/puppet/master/proxy.pp', line 6

class r_profile::puppet::master::proxy(
  $proxy                  = hiera("r_profile::puppet::master::proxy::proxy", false),
) inherits r_profile::puppet::params {

  $puppetconf             = $r_profile::puppet::params::puppetconf
  $sysconf_puppetserver   = $r_profile::puppet::params::sysconf_puppetserver

  #
  # Proxy server in settings file
  #
  if $proxy {
    $proxy_ensure = present
    $regexp = 'https?://(.*?@)?([^:]+):(\d+)'
    $proxy_host = regsubst($proxy, $regexp, '\2')
    $proxy_port = regsubst($proxy, $regexp, '\3')
    if $export_variable {
      # solaris needs a 2-step export
      $http_proxy_var   = "http_proxy=${proxy}; export http_proxy"
      $https_proxy_var  = "https_proxy=${proxy}; export https_proxy"
    } else {
      $http_proxy_var   = "http_proxy=${proxy}"
      $https_proxy_var  = "https_proxy=${proxy}"
    }
  } else {
    $proxy_ensure = absent
    $proxy_host = undef
    $proxy_port = undef
    # nasty hack - we MUST have two different space permuations here or
    # file_line will only remove a single entry as it has already matched
    $http_proxy_var  = " "
    $https_proxy_var = "  "
  }

  Ini_setting {
    ensure => $proxy_ensure,
  }

  # PMT (puppet.conf)
  ini_setting { "puppet.conf http_proxy_host":
    path    => $puppetconf,
    section => "user",
    setting => "http_proxy_host",
    value   => $proxy_host,
  }

  ini_setting { "puppet.conf http_proxy_port":
    path    => $puppetconf,
    section => "user",
    setting => "http_proxy_port",
    value   => $proxy_port,
  }

  # Enable pe-puppetserver to work with proxy
  file_line { "pe-puppetserver http_proxy":
    ensure => present,
    path   => $sysconf_puppetserver,
    line   => $http_proxy_var,
    match  => "http_proxy=",
  }

  file_line { "pe-puppetserver https_proxy":
    ensure => present,
    path   => $sysconf_puppetserver,
    line   => $https_proxy_var,
    match  => "https_proxy=",
  }


}