|
1717 | 1717 | # client request exceeds that limit, the server will return an error response |
1718 | 1718 | # instead of servicing the request. |
1719 | 1719 | # |
| 1720 | +# @param $use_servername_for_filenames |
| 1721 | +# When set to true, default log / config file names will be derived from the sanitized |
| 1722 | +# value of the $servername parameter. |
| 1723 | +# When set to false (default), the existing behaviour of using the $name parameter |
| 1724 | +# will remain. |
| 1725 | + |
1720 | 1726 | define apache::vhost ( |
1721 | 1727 | Variant[Boolean,String] $docroot, |
1722 | 1728 | $manage_docroot = true, |
|
1782 | 1788 | $access_log_format = false, |
1783 | 1789 | $access_log_env_var = false, |
1784 | 1790 | Optional[Array] $access_logs = undef, |
| 1791 | + Optional[Boolean] $use_servername_for_filenames = false, |
1785 | 1792 | $aliases = undef, |
1786 | 1793 | Optional[Variant[Hash, Array[Variant[Array,Hash]]]] $directories = undef, |
1787 | 1794 | Boolean $error_log = true, |
|
2036 | 2043 | $priority_real = '25-' |
2037 | 2044 | } |
2038 | 2045 |
|
2039 | | - ## Apache include does not always work with spaces in the filename |
2040 | | - $filename = regsubst($name, ' ', '_', 'G') |
| 2046 | + # IAC-1186: A number of configuration and log file names are generated using the $name parameter. It is possile for |
| 2047 | + # the $name parameter to contain spaces, which could then be transferred to the log / config filenames. Although |
| 2048 | + # POSIX compliant, this can be cumbersome. |
| 2049 | + # |
| 2050 | + # It seems more appropriate to use the $servername parameter to derive default log / config filenames from. We should |
| 2051 | + # also perform some sanitiation on the $servername parameter to strip spaces from it, as it defaults to the value of |
| 2052 | + # $name, should $servername NOT be defined. |
| 2053 | + # |
| 2054 | + # We will retain the default behaviour for filenames but allow the use of a sanitized version of $servername to be |
| 2055 | + # used, using the new $use_servername_for_filenames parameter. |
| 2056 | + # |
| 2057 | + # This will default to false until the next major release (v6.0.0), at which point, we will default this to true and |
| 2058 | + # warn about it's imminent deprecation in the subsequent major release (v7.0.0) |
| 2059 | + # |
| 2060 | + # In v7.0.0, we will deprecate the $use_servername_for_filenames parameter altogether and use the sanitized value of |
| 2061 | + # $servername for default log / config filenames. |
| 2062 | + $filename = $use_servername_for_filenames ? { |
| 2063 | + true => regsubst($servername, ' ', '_', 'G'), |
| 2064 | + false => $name, |
| 2065 | + } |
| 2066 | + |
| 2067 | + if ! $use_servername_for_filenames { |
| 2068 | + $use_servername_for_filenames_warn_msg = ' |
| 2069 | + It is possible for the $name parameter to be defined with spaces in it. Although supported on POSIX systems, this |
| 2070 | + can lead to cumbersome file names. The $servername attribute has stricter conditions from Apache (i.e. no spaces) |
| 2071 | + When $use_servername_for_filenames = true, the $servername parameter, sanitized, is used to construct log and config |
| 2072 | + file names. |
| 2073 | +
|
| 2074 | + From version v6.0.0 of the puppetlabs-apache module, this parameter will default to true. From version v7.0.0 of the |
| 2075 | + module, the $use_servername_for_filenames will be removed and log/config file names will be dervied from the |
| 2076 | + sanitized $servername parameter when not explicitly defined.' |
| 2077 | + warning($use_servername_for_filenames_warn_msg) |
| 2078 | + } |
2041 | 2079 |
|
2042 | 2080 | # This ensures that the docroot exists |
2043 | 2081 | # But enables it to be specified across multiple vhost resources |
|
2096 | 2134 | $error_log_destination = $error_log_syslog |
2097 | 2135 | } else { |
2098 | 2136 | if $ssl { |
2099 | | - $error_log_destination = "${logroot}/${name}_error_ssl.log" |
| 2137 | + $error_log_destination = "${logroot}/${filename}_error_ssl.log" |
2100 | 2138 | } else { |
2101 | | - $error_log_destination = "${logroot}/${name}_error.log" |
| 2139 | + $error_log_destination = "${logroot}/${filename}_error.log" |
2102 | 2140 | } |
2103 | 2141 | } |
2104 | 2142 |
|
|
2117 | 2155 | $modsec_audit_log_destination = $modsec_audit_log_pipe |
2118 | 2156 | } elsif $modsec_audit_log { |
2119 | 2157 | if $ssl { |
2120 | | - $modsec_audit_log_destination = "${logroot}/${name}_security_ssl.log" |
| 2158 | + $modsec_audit_log_destination = "${logroot}/${filename}_security_ssl.log" |
2121 | 2159 | } else { |
2122 | | - $modsec_audit_log_destination = "${logroot}/${name}_security.log" |
| 2160 | + $modsec_audit_log_destination = "${logroot}/${filename}_security.log" |
2123 | 2161 | } |
2124 | 2162 | } else { |
2125 | 2163 | $modsec_audit_log_destination = undef |
|
0 commit comments