|
32 | 32 | # This parameter is used only if the `verify_config` parameter's value is `true`. If the |
33 | 33 | # `verify_command` fails, the Puppet run deletes the configuration file and raises an error, |
34 | 34 | # but does not notify the Apache service. |
| 35 | +# Command can be passed through as either a String, i.e. `'/usr/sbin/apache2ctl -t'` |
| 36 | +# An array, i.e. `['/usr/sbin/apache2ctl', '-t']` |
| 37 | +# Or an array of arrays with each one having to pass succesfully, i.e. `[['/usr/sbin/apache2ctl', '-t'], '/usr/sbin/apache2ctl -t']` |
35 | 38 | # |
36 | 39 | # @param verify_config |
37 | 40 | # Specifies whether to validate the configuration file before notifying the Apache service. |
|
49 | 52 | # show_diff property for configuration file resource |
50 | 53 | # |
51 | 54 | define apache::custom_config ( |
52 | | - Enum['absent', 'present'] $ensure = 'present', |
53 | | - Stdlib::Absolutepath $confdir = $apache::confd_dir, |
54 | | - Optional[String] $content = undef, |
55 | | - Apache::Vhost::Priority $priority = 25, |
56 | | - Optional[String] $source = undef, |
57 | | - String $verify_command = $apache::params::verify_command, |
58 | | - Boolean $verify_config = true, |
59 | | - Optional[String] $filename = undef, |
60 | | - Optional[String] $owner = undef, |
61 | | - Optional[String] $group = undef, |
62 | | - Optional[Stdlib::Filemode] $file_mode = undef, |
63 | | - Boolean $show_diff = true, |
| 55 | + Enum['absent', 'present'] $ensure = 'present', |
| 56 | + Stdlib::Absolutepath $confdir = $apache::confd_dir, |
| 57 | + Optional[String] $content = undef, |
| 58 | + Apache::Vhost::Priority $priority = 25, |
| 59 | + Optional[String] $source = undef, |
| 60 | + Variant[String, Array[String], Array[Array[String]]] $verify_command = $apache::params::verify_command, |
| 61 | + Boolean $verify_config = true, |
| 62 | + Optional[String] $filename = undef, |
| 63 | + Optional[String] $owner = undef, |
| 64 | + Optional[String] $group = undef, |
| 65 | + Optional[Stdlib::Filemode] $file_mode = undef, |
| 66 | + Boolean $show_diff = true, |
64 | 67 | ) { |
65 | 68 | if $content and $source { |
66 | 69 | fail('Only one of $content and $source can be specified.') |
|
90 | 93 | $notifies = undef |
91 | 94 | } |
92 | 95 |
|
| 96 | + $_file_path = "${confdir}/${_filename}" |
93 | 97 | $_file_mode = pick($file_mode, $apache::file_mode) |
94 | 98 |
|
95 | 99 | file { "apache_${name}": |
96 | 100 | ensure => $ensure, |
97 | | - path => "${confdir}/${_filename}", |
| 101 | + path => $_file_path, |
98 | 102 | owner => $owner, |
99 | 103 | group => $group, |
100 | 104 | mode => $_file_mode, |
|
115 | 119 | require => Anchor['::apache::modules_set_up'], |
116 | 120 | } |
117 | 121 |
|
| 122 | + $remove_command = ['/bin/rm', $_file_path] |
118 | 123 | exec { "remove ${name} if invalid": |
119 | | - command => "/bin/rm ${confdir}/${_filename}", |
120 | | - unless => $verify_command, |
| 124 | + command => $remove_command, |
| 125 | + unless => [$verify_command], |
121 | 126 | subscribe => File["apache_${name}"], |
122 | 127 | refreshonly => true, |
123 | 128 | } |
|
0 commit comments