Skip to content

Commit

Permalink
plugin/discovery: use refreshonly on the untar exec
Browse files Browse the repository at this point in the history
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: #774 (comment)
  • Loading branch information
kenyon committed Dec 1, 2023
1 parent 69c038e commit b4e4d7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions manifests/plugin/discovery.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
2 changes: 1 addition & 1 deletion spec/classes/foreman_proxy__plugin__discovery_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b4e4d7e

Please sign in to comment.