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

On Wed, Aug 10, 2016 at 11:45 PM, Alex Samad <a...@samad.com.au> wrote:
> Hi
>
> so I have a repo of vmware-tools.*.tgz files located at a website.
>
> how do I build a module to check
> 1) is vmware tool install - check does vmware-toolbox-cmd  exist
> 2) is it the right version - check for current version is vmware-toolbox-cmd
> -v
>
> I want to add version number into my hiera DB.  think i have worked out. but
> not sure how to do the client test.
>
> I am guessing (psydo code)
>
> if exist vmware-toolbox-cmd  and if vmware-toolbox-cmd -v >= <version
> wanted>
> then
>   do nothing
> else
>   wget file
>   run vmware-install
> fi
>
>
>
> --
> 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+unsubscr...@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.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAKJ8awfg4Z1ZoWXsvtykZjFOJ7%3DwqKSYoFi5q%3DJkZwq90o1ugw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to