Fix unsafe interpolations in exec

... to resolve the following warning detected by puppet-lint.

WARNING: unsafe interpolation of variable 'foo' in exec command

Note that the lint rule is currently disabled[1].

[1] 56cf30b7e26d2c1a440a83f67ec4d7041dcf5cdb

Change-Id: I5576174e964a9a181603e1f06145415c8ce27344
This commit is contained in:
Takashi Kajinami 2024-04-14 15:40:20 +09:00
parent f9d07c8d75
commit 5fe702bcc2
8 changed files with 8 additions and 8 deletions

View File

@ -292,7 +292,7 @@ class vswitch::dpdk (
# when any vs_config resource with restart => true is enabled.
exec { 'restart openvswitch':
path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
command => "systemctl -q restart ${service_name}.service",
command => ['systemctl', '-q', 'restart', "${service_name}.service"],
refreshonly => true,
}

View File

@ -99,7 +99,7 @@ class vswitch::ovs(
# when any vs_config resource with restart => true is enabled.
exec { 'restart openvswitch':
path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
command => "systemctl -q restart ${service_name}.service",
command => ['systemctl', '-q', 'restart', "${service_name}.service"],
refreshonly => true,
}

View File

@ -5,7 +5,7 @@
class vswitch::pki::cacert {
exec { 'ovs-pki-init-ca-authority':
command => 'ovs-pki init --force',
command => ['ovs-pki', 'init', '--force'],
creates => '/var/lib/openvswitch/pki/switchca',
path => ['/usr/sbin', '/sbin', '/usr/bin', '/bin'],
}

View File

@ -13,7 +13,7 @@ define vswitch::pki::cert(
) {
exec { "ovs-req-and-sign-cert-${name}":
command => "ovs-pki req+sign ${name}",
command => ['ovs-pki', 'req+sign', $name],
cwd => $cert_dir,
creates => "${cert_dir}/${name}-cert.pem",
path => ['/usr/sbin', '/sbin', '/usr/bin', '/bin'],

View File

@ -73,7 +73,7 @@ describe 'vswitch::dpdk' do
it 'restarts the service when needed' do
is_expected.to contain_exec('restart openvswitch').with(
:path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
:command => "systemctl -q restart %s.service" % platform_params[:ovs_service_name],
:command => ['systemctl', '-q', 'restart', "#{platform_params[:ovs_service_name]}.service"],
:refreshonly => true
)
end

View File

@ -48,7 +48,7 @@ describe 'vswitch::ovs' do
it 'restarts the service when needed' do
is_expected.to contain_exec('restart openvswitch').with(
:path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'],
:command => "systemctl -q restart %s.service" % platform_params[:ovs_service_name],
:command => ['systemctl', '-q', 'restart', "#{platform_params[:ovs_service_name]}.service"],
:refreshonly => true
)
end

View File

@ -5,7 +5,7 @@ describe 'vswitch::pki::cacert' do
shared_examples_for 'vswitch::pki::cacert' do
it 'shoud initialize ca authority' do
is_expected.to contain_exec('ovs-pki-init-ca-authority').with(
:command => 'ovs-pki init --force',
:command => ['ovs-pki', 'init', '--force'],
:creates => '/var/lib/openvswitch/pki/switchca',
:path => ['/usr/sbin', '/sbin', '/usr/bin', '/bin'],
)

View File

@ -7,7 +7,7 @@ describe 'vswitch::pki::cert' do
shared_examples_for 'vswitch::pki::cert' do
it 'shoud generate a certificate' do
is_expected.to contain_exec('ovs-req-and-sign-cert-foo').with(
:command => 'ovs-pki req+sign foo',
:command => ['ovs-pki', 'req+sign', 'foo'],
:cwd => '/etc/openvswitch',
:creates => '/etc/openvswitch/foo-cert.pem',
:path => ['/usr/sbin', '/sbin', '/usr/bin', '/bin'],