Re: [Puppet Users] Copy script from source -> run it -> delete it again

80 views
Skip to first unread message

Denmat

unread,
May 20, 2013, 1:19:26 AM5/20/13
to puppet...@googlegroups.com
Hmm, this?

  exec { "/root/get_phantomjs.sh && rm -f /root/get_phantomjs.sh":

Maybe?

Den
On 19/05/2013, at 21:01, flip <flip...@gmail.com> wrote:

Hi,

i want to deploy a build script, run it and delete if afterwards.

To deploy and run, i use this:

  file { "/root/get_phantomjs.sh":
    ensure => present,
    mode => "0700",
    source => "puppet:///modules/phantomjs/get_phantomjs.sh",
    require => Package["libfontconfig1-dev"],
  }

  exec { "/root/get_phantomjs.sh":
    creates => "/usr/local/bin/phantomjs",
    require => File["/root/get_phantomjs.sh"],
  }

What would be an elegant way to delete the get_phantom.js file after the exec?

flip

--
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 post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jakov Sosic

unread,
Jul 2, 2013, 6:14:52 PM7/2/13
to puppet...@googlegroups.com
On 05/20/2013 07:19 AM, Denmat wrote:
> Hmm, this?
>
>> exec { "/root/get_phantomjs.sh && rm -f /root/get_phantomjs.sh":

Yeah but the puppet resource 'file' will bring it back next run.


Assuming script is not containing anything of a security issue, you can
put it on a web server and do an exec like this:

exec { 'get_phantomjs':
command => 'wget http://example.com/get_phantomjs.sh &&
./get_phantomjs.sh && rm -f get_phantomjs.sh',
}

Another solution is a custom fact, which will say if the
'/usr/local/bin/phantomjs' file exists, but that's an
over-engineering... building a dam when all you need is a bridge :D


--
Jakov Sosic
www.srce.unizg.hr

Pete Brown

unread,
Jul 3, 2013, 9:42:43 PM7/3/13
to puppet-users
Hi,

So from a guess based on the name of the script it installs some
javascript file somewhere.
Am I correct?
With maybe something extra like optimising it afterwards?

Is there any reason you can't optimize that file and get puppet to
"install" it on your node?
This will give you a whole lot more repeatability than using a script.
You could even put in in an rpm or dpkg and put it in local repository
and install it as a package.
Reply all
Reply to author
Forward
0 new messages