From b4e4d7ed32cd1ca3615e4212dab87c20c551f51e 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 b27826fa..e395c598 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 9455ebfd..7b4beff3 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