Puppet Function: logrotate::find_match

Defined in:
functions/find_match.pp
Function type:
Puppet Language

Summary

convert the passed string to a regex to search with

Overview

logrotate::find_match(Any $setting)String

Figure out the regexp we need to use with ‘fm_replace` in order to update the passed in setting

Examples:

logrotate::find_match("weekly")

Parameters:

  • setting (Any)

    The setting to match (eg “weekly”)

Returns:

  • (String)

    representing the regex to match the main config file for



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'functions/find_match.pp', line 11

function logrotate::find_match($setting) >> String {

  case $setting {
    "daily", "weekly", "monthly", "yearly": {
      $match = "^(daily|weekly|monthly|yearly)"
    }
    "rotate": {
      $match = "^rotate"
    }
    default: {
      # strip any 'no' from setting
      $setting_stripped = regsubst($setting, '^(no)?(.+)', '\2')
      $match = "^(no)?${setting_stripped}"
    }
  }

  $match
}