Skip to content

Commit a565ea9

Browse files
committed
(maint) Update $verify_command type
The unless variable in an exec manifest, which $verify_command is directly passed too, accepts either an Array or and Array of Arrays as input. Updating the variables type and default values to match this. In the case where it is passed a String it proceeds to wrap it in an Array and then treat it as such.
1 parent 2dc32cc commit a565ea9

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

manifests/custom_config.pp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
# This parameter is used only if the `verify_config` parameter's value is `true`. If the
3333
# `verify_command` fails, the Puppet run deletes the configuration file and raises an error,
3434
# 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']`
3538
#
3639
# @param verify_config
3740
# Specifies whether to validate the configuration file before notifying the Apache service.
@@ -49,18 +52,18 @@
4952
# show_diff property for configuration file resource
5053
#
5154
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,
6467
) {
6568
if $content and $source {
6669
fail('Only one of $content and $source can be specified.')

manifests/params.pp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,13 +713,13 @@
713713
}
714714

715715
if $facts['os']['name'] == 'SLES' {
716-
$verify_command = '/usr/sbin/apache2ctl -t'
716+
$verify_command = ['/usr/sbin/apache2ctl', '-t']
717717
} elsif $facts['os']['name'] == 'FreeBSD' {
718-
$verify_command = '/usr/local/sbin/apachectl -t'
718+
$verify_command = ['/usr/local/sbin/apachectl', '-t']
719719
} elsif ($apache::version::scl_httpd_version) {
720-
$verify_command = "/opt/rh/${_scl_httpd_name}/root/usr/sbin/apachectl -t"
720+
$verify_command = ["/opt/rh/${_scl_httpd_name}/root/usr/sbin/apachectl", '-t']
721721
} else {
722-
$verify_command = '/usr/sbin/apachectl -t'
722+
$verify_command = ['/usr/sbin/apachectl', '-t']
723723
}
724724

725725
if $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'], '8') >= 0 {

spec/defines/custom_config_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121

2222
it {
2323
is_expected.to contain_exec('syntax verification for rspec')
24-
.with('refreshonly' => 'true', 'command' => ['/usr/sbin/apachectl -t'])
24+
.with('refreshonly' => 'true', 'command' => ['/usr/sbin/apachectl', '-t'])
2525
.that_subscribes_to('File[apache_rspec]')
2626
.that_notifies('Class[Apache::Service]')
2727
.that_comes_before('Exec[remove rspec if invalid]')
2828
}
2929
it {
3030
is_expected.to contain_exec('remove rspec if invalid')
31-
.with('unless' => ['/usr/sbin/apachectl -t'], 'refreshonly' => 'true')
31+
.with('unless' => [['/usr/sbin/apachectl', '-t']], 'refreshonly' => 'true')
3232
.that_subscribes_to('File[apache_rspec]')
3333
}
3434
it {
@@ -43,16 +43,16 @@
4343
'confdir' => '/dne',
4444
'priority' => 30,
4545
'source' => 'puppet:///modules/apache/test',
46-
'verify_command' => '/bin/true',
46+
'verify_command' => ['/bin/true'],
4747
}
4848
end
4949

5050
it {
51-
is_expected.to contain_exec('syntax verification for rspec').with('command' => '/bin/true')
51+
is_expected.to contain_exec('syntax verification for rspec').with('command' => ['/bin/true'])
5252
}
5353
it {
5454
is_expected.to contain_exec('remove rspec if invalid').with('command' => ['/bin/rm', '/dne/30-rspec.conf'],
55-
'unless' => ['/bin/true'])
55+
'unless' => [['/bin/true']])
5656
}
5757
it {
5858
is_expected.to contain_file('apache_rspec')

0 commit comments

Comments
 (0)