From d1cac687e27563893b67a7b7bf157e0db4833c4a Mon Sep 17 00:00:00 2001 From: Kenyon Ralph Date: Thu, 30 Nov 2023 15:55:54 -0800 Subject: [PATCH] plugin/discovery: use refreshonly on the untar exec Previously, if you change the image_name (such as for updating the Foreman Discovery Image version), the new tar file would be downloaded but not untarred because the content of the previous tar file would be there and pass the `creates` check. If we use `refreshonly` instead of `creates`, the untar exec will be executed when the tar file is updated, as expected. See also: https://github.com/theforeman/puppet-foreman_proxy/pull/774#issuecomment-1834709446 --- manifests/plugin/discovery.pp | 8 ++++---- spec/classes/foreman_proxy__plugin__discovery_spec.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/plugin/discovery.pp b/manifests/plugin/discovery.pp index b27826fae..e395c598e 100644 --- a/manifests/plugin/discovery.pp +++ b/manifests/plugin/discovery.pp @@ -42,10 +42,10 @@ remote_location => "${source_url}${image_name}", mode => '0644', } ~> exec { "untar ${image_name}": - command => "tar xf ${image_name}", - path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - cwd => "${tftp_root_clean}/boot", - creates => "${tftp_root_clean}/boot/fdi-image/initrd0.img", + command => "tar xf ${image_name}", + path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + cwd => "${tftp_root_clean}/boot", + refreshonly => true, } } } diff --git a/spec/classes/foreman_proxy__plugin__discovery_spec.rb b/spec/classes/foreman_proxy__plugin__discovery_spec.rb index 07904c2c2..22ff3b247 100644 --- a/spec/classes/foreman_proxy__plugin__discovery_spec.rb +++ b/spec/classes/foreman_proxy__plugin__discovery_spec.rb @@ -71,7 +71,7 @@ 'command' => 'tar xf fdi-image-latest.tar', 'path' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'cwd' => "#{tftproot}/boot", - 'creates' => "#{tftproot}/boot/fdi-image/initrd0.img", + 'refreshonly' => true, }) end end