So setting aside if this is a good idea or not, you can do this in a
single exec resource. Look at
https://docs.puppet.com/puppet/latest/reference/types/exec.html
Pay particular attention to onlyif, refreshonly, unless, and creates.
Used either alone or in concert with the file resource type
(
https://docs.puppet.com/puppet/4.6/reference/types/file.html#file-attribute-source),
you can set up something roughly like:
file { 'somepath/vmtools.tar.gz': source =>
'
http://somesite/vmtools.tar.gz', notify => exec['vmtoolsinst'] } ->
exec { 'vmtoolsinst': command => 'stuffs', refreshonly => true }
which will download the file then run a command on it if it had to
download the file. You could also chain execs ala:
exec { 'curl -o somepath
http://somesite/vmtoolsd': onlyif =>
'shell eval of vmware-toolbox-cmd -v output', notify => vmtoolsinst }
exec { 'vmtoolsinst': command => 'stuffs', refreshonly => true }
Now going beyond that, you could add in a custom fact to capture the
value of vmware-toolbox-cmd. This would look something like:
Facter.add('vmtools-toolbox-cmd') do
setcode do
Facter::Core::Execution.exec(' vmware-toolbox-cmd -v')
end
end
You would then be able to do logic based off this fact.
Really though, you should just use the forge - there's a puppet
approved module for vmtools:
https://forge.puppet.com/razorsedge/vmwaretools
HTH,
--Nick
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
puppet-users...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/puppet-users/7e990f42-22b6-4aff-8887-83768e086cb8%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.