diff modules/apache/manifests/custom_config.pp @ 275:d9352a684e62

Mass update of modules to remove deprecation warnings
author IBBoard <dev@ibboard.co.uk>
date Sun, 26 Jan 2020 11:36:07 +0000
parents 675c1cc61eaf
children b8d6ada284dd
line wrap: on
line diff
--- a/modules/apache/manifests/custom_config.pp	Sat Jan 04 11:42:45 2020 +0000
+++ b/modules/apache/manifests/custom_config.pp	Sun Jan 26 11:36:07 2020 +0000
@@ -1,13 +1,66 @@
-# See README.md for usage information
+# @summary
+#   Adds a custom configuration file to the Apache server's `conf.d` directory. 
+#
+# If the file is invalid and this defined type's `verify_config` parameter's value is 
+# `true`, Puppet throws an error during a Puppet run.
+#
+# @param ensure
+#   Specifies whether the configuration file should be present.
+#
+# @param confdir
+#   Sets the directory in which Puppet places configuration files.
+#
+# @param content
+#   Sets the configuration file's content. The `content` and `source` parameters are exclusive 
+#   of each other.
+#
+# @param filename
+#   Sets the name of the file under `confdir` in which Puppet stores the configuration.
+#
+# @param priority
+#   Sets the configuration file's priority by prefixing its filename with this parameter's 
+#   numeric value, as Apache processes configuration files in alphanumeric order.<br />
+#   To omit the priority prefix in the configuration file's name, set this parameter to `false`.
+#
+# @param source
+#   Points to the configuration file's source. The `content` and `source` parameters are 
+#   exclusive of each other.
+#
+# @param verify_command
+#   Specifies the command Puppet uses to verify the configuration file. Use a fully qualified 
+#   command.<br />
+#   This parameter is used only if the `verify_config` parameter's value is `true`. If the 
+#   `verify_command` fails, the Puppet run deletes the configuration file and raises an error, 
+#   but does not notify the Apache service.
+#
+# @param verify_config
+#   Specifies whether to validate the configuration file before notifying the Apache service.
+#
+# @param owner
+#   File owner of configuration file
+#
+# @param group
+#   File group of configuration file
+#
+# @param file_mode
+#   File mode of configuration file
+#
+# @param show_diff
+#   show_diff property for configuration file resource
+#
 define apache::custom_config (
-  $ensure         = 'present',
-  $confdir        = $::apache::confd_dir,
-  $content        = undef,
-  $priority       = '25',
-  $source         = undef,
-  $verify_command = $::apache::params::verify_command,
-  $verify_config  = true,
-  $filename       = undef,
+  Enum['absent', 'present'] $ensure = 'present',
+  $confdir                          = $::apache::confd_dir,
+  $content                          = undef,
+  $priority                         = '25',
+  $source                           = undef,
+  $verify_command                   = $::apache::params::verify_command,
+  Boolean $verify_config            = true,
+  $filename                         = undef,
+  $owner                            = undef,
+  $group                            = undef,
+  $file_mode                        = undef,
+  Boolean $show_diff                = true,
 ) {
 
   if $content and $source {
@@ -18,12 +71,6 @@
     fail('One of $content and $source must be specified.')
   }
 
-  validate_re($ensure, '^(present|absent)$',
-  "${ensure} is not supported for ensure.
-  Allowed values are 'present' and 'absent'.")
-
-  validate_bool($verify_config)
-
   if $filename {
     $_filename = $filename
   } else {
@@ -44,13 +91,19 @@
     $notifies = undef
   }
 
+  $_file_mode = pick($file_mode, $::apache::file_mode)
+
   file { "apache_${name}":
-    ensure  => $ensure,
-    path    => "${confdir}/${_filename}",
-    content => $content,
-    source  => $source,
-    require => Package['httpd'],
-    notify  => $notifies,
+    ensure    => $ensure,
+    path      => "${confdir}/${_filename}",
+    owner     => $owner,
+    group     => $group,
+    mode      => $_file_mode,
+    content   => $content,
+    source    => $source,
+    show_diff => $show_diff,
+    require   => Package['httpd'],
+    notify    => $notifies,
   }
 
   if $ensure == 'present' and $verify_config {