Puppet Class: stunnel

Defined in:
manifests/init.pp

Summary

Basic Stunnel config. Installs the packages and creates essential directories.

Overview

Examples:

Basic usage

include stunnel

Parameters:

  • bin_name (Optional[String]) (defaults to: undef) —

    Name of the stunnel executable.

  • bin_path (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Path to the directory containing the stunnel executable.

  • cert_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Path to the directory containing the certificates.

  • config_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Path to the directory containing the configuration files.

  • log_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Path to the directory containing the output files.

  • packages (Optional[Array[String[1]]]) (defaults to: undef) —

    List of packages to install.

  • packages_ensure (Optional[Stunnel::PackagesEnsure]) (defaults to: undef) —

    If packages should be updated or not.

  • packages_provider (Optional[String]) (defaults to: undef) —

    Provider to use to install the packages. Mandatory on Windows.

  • pid_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Path to the directory containing the pid file. Linux only.

  • user (Optional[String]) (defaults to: undef) —

    User that will own the files and run the service.

  • group (Optional[String]) (defaults to: undef) —

    Group that will own the files and run the service.

  • chroot_enable (Optional[Boolean]) (defaults to: undef) —

    Enable chroot jail for the stunnel process (Linux only).

  • chroot_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef) —

    Path to the directory to use for the chroot jail.

  • manage_selinux (Optional[Boolean]) (defaults to: undef) —

    Opt-in to manage SELinux contexts and port labeling (Linux only).

Author:

  • Aaron Russo Stephen Hoekstra Philippe Ganz

Since:

  • 0.0.0



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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'manifests/init.pp', line 61

class stunnel (
  Optional[String]                  $bin_name            = undef,
  Optional[Stdlib::Absolutepath]    $bin_path            = undef,
  Optional[Stdlib::Absolutepath]    $cert_dir            = undef,
  Optional[Stdlib::Absolutepath]    $config_dir          = undef,
  Optional[Stdlib::Absolutepath]    $log_dir             = undef,
  Optional[Array[String[1]]]        $packages            = undef,
  Optional[Stunnel::PackagesEnsure] $packages_ensure     = undef,
  Optional[String]                  $packages_provider   = undef,
  Optional[Stdlib::Absolutepath]    $pid_dir             = undef,
  Optional[String]                  $user                = undef,
  Optional[String]                  $group               = undef,
  Optional[Boolean]                 $chroot_enable       = undef,
  Optional[Stdlib::Absolutepath]    $chroot_dir          = undef,
  Optional[Boolean]                 $manage_selinux      = undef,
) {
  package { $packages:
    ensure   => $packages_ensure,
    provider => $packages_provider,
  }

  $_base_dirs = [
    $cert_dir,
    $config_dir,
    $log_dir,
  ]

  $stunnel_dirs = if $facts['kernel'] == 'Linux' and $chroot_enable and $chroot_dir {
    $_base_dirs + [$chroot_dir]
  } else {
    $_base_dirs
  }

  file { $stunnel_dirs:
    ensure => directory,
    owner  => $user,
    group  => $group,
    mode   => '0775',
  }

  if $facts['kernel'] == 'Linux' and $chroot_enable and $chroot_dir {
    file { "${chroot_dir}/${pid_dir}":
      ensure => 'directory',
      owner  => $user,
      group  => $group,
      mode   => '0755',
    }
  }

  if $manage_selinux and $facts.dig('os', 'selinux', 'enabled') {
    if $cert_dir {
      selinux::fcontext { "${cert_dir}(/.*)?":
        seltype => 'stunnel_etc_t',
      }
    }
    if $config_dir {
      selinux::fcontext { "${config_dir}(/.*)?":
        seltype => 'stunnel_etc_t',
      }
    }
    if $log_dir {
      selinux::fcontext { "${log_dir}(/.*)?":
        seltype => 'stunnel_log_t',
      }
    }
    if $chroot_enable and $chroot_dir {
      selinux::fcontext { "${chroot_dir}(/.*)?":
        seltype => 'stunnel_var_run_t',
      }
    }
  }
}