Skip to content

Commit b4e4d7e

Browse files
committed
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: theforeman#774 (comment)
1 parent 69c038e commit b4e4d7e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

manifests/plugin/discovery.pp

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
remote_location => "${source_url}${image_name}",
4343
mode => '0644',
4444
} ~> exec { "untar ${image_name}":
45-
command => "tar xf ${image_name}",
46-
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
47-
cwd => "${tftp_root_clean}/boot",
48-
creates => "${tftp_root_clean}/boot/fdi-image/initrd0.img",
45+
command => "tar xf ${image_name}",
46+
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
47+
cwd => "${tftp_root_clean}/boot",
48+
refreshonly => true,
4949
}
5050
}
5151
}

spec/classes/foreman_proxy__plugin__discovery_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
'command' => 'tar xf fdi-image-latest.tar',
7272
'path' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
7373
'cwd' => "#{tftproot}/boot",
74-
'creates' => "#{tftproot}/boot/fdi-image/initrd0.img",
74+
'refreshonly' => true,
7575
})
7676
end
7777
end

0 commit comments

Comments
 (0)