From 8ebd4cfe0348452778c856d305dff64a54705ec8 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 2 Oct 2024 12:18:55 +0900 Subject: [PATCH] Use native package resource to install tox The native package resource type provides the pip provider which can be used instead of direct exec call. Change-Id: I0ffd81116e4cc576caf6f4830becba183fd9e708 --- manifests/init.pp | 11 +++++------ spec/classes/tempest_init_spec.rb | 7 +++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 538a3800..ee6e3d4d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -536,15 +536,14 @@ class tempest( ensure_packages('pip', { name => $::tempest::params::pip_package_name, }) - Package['pip'] -> Exec['install-tox'] + Package['pip'] -> Package['tox'] } else { warning('pip package is not available in this distribution.') } - exec { 'install-tox': - command => [$tempest::params::pip_command, 'install', '-U', 'tox'], - unless => 'which tox', - path => ['/bin','/usr/bin','/usr/local/bin'], + package { 'tox': + ensure => present, + provider => 'pip', } if $git_clone { @@ -566,7 +565,7 @@ class tempest( creates => "${tempest_clone_path}/.venv", path => ['/bin', '/usr/bin', '/usr/local/bin'], require => [ - Exec['install-tox'], + Package['tox'], Package[$tempest::params::dev_packages], ], } diff --git a/spec/classes/tempest_init_spec.rb b/spec/classes/tempest_init_spec.rb index 74dc9e49..62542bda 100644 --- a/spec/classes/tempest_init_spec.rb +++ b/spec/classes/tempest_init_spec.rb @@ -182,10 +182,9 @@ describe 'tempest' do ) end - is_expected.to contain_exec('install-tox').with( - :command => [platform_params[:pip_command], 'install', '-U', 'tox'], - :unless => 'which tox', - :path => ['/bin', '/usr/bin', '/usr/local/bin'], + is_expected.to contain_package('tox').with( + :ensure => 'present', + :provider => 'pip', ) is_expected.to contain_vcsrepo('/var/lib/tempest').with(