Defined Type: nginx::resource::snippet

Defined in:
manifests/resource/snippet.pp

Summary

Create a reusable config snippet that can be included by other resources

Overview

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: 'present')

    Enables or disables the specified snippet

  • owner (String) (defaults to: $nginx::global_owner)

    Defines owner of the .conf file

  • group (String) (defaults to: $nginx::global_group)

    Defines group of the .conf file

  • mode (Stdlib::Filemode) (defaults to: $nginx::global_mode)

    Defines mode of the .conf file

  • raw_content (String[1])

    Raw content that will be inserted into the snipped as-is



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
# File 'manifests/resource/snippet.pp', line 14

define nginx::resource::snippet (
  String[1] $raw_content,
  Enum['absent', 'present'] $ensure = 'present',
  String $owner                     = $nginx::global_owner,
  String $group                     = $nginx::global_group,
  Stdlib::Filemode $mode            = $nginx::global_mode,
) {
  if ! defined(Class['nginx']) {
    fail('You must include the nginx base class before using any defined resources')
  }

  $name_sanitized = regsubst($name, ' ', '_', 'G')
  $config_file = "${nginx::snippets_dir}/${name_sanitized}.conf"

  concat { $config_file:
    ensure  => $ensure,
    owner   => $owner,
    group   => $group,
    mode    => $mode,
    notify  => Class['nginx::service'],
    require => File[$nginx::snippets_dir],
    tag     => 'nginx_config_file',
  }

  concat::fragment { "snippet-${name_sanitized}-header":
    target  => $config_file,
    content => epp("${module_name}/snippet/snippet_header.epp", { 'raw_content' => $raw_content }),
    order   => '001',
  }
}