Cleaning up temp files with puppet

337 views
Skip to first unread message

nfwlpw

unread,
Mar 11, 2014, 10:09:26 PM3/11/14
to puppet...@googlegroups.com
So I have a puppet module, that gets a script from files/, runs that script, and after it's done, I'd like to remove it.

Unfortunately puppet doesn't seem to like to have 2 different File resource aliased to the same, so I can't do

file { "myfile":
    ensure => present,
    source => "puppet:///...",
}

file { "remove myfile":
    path => "myfile",
   ensure => absent,
}

Puppet gave the error: err: Failed to apply catalog: Cannot alias File[remove myfile]...myfile already declared...

The only work around I've found is using an exec resource.  Anyone know how to do this without exec?

Thank you

Johan De Wit

unread,
Mar 11, 2014, 10:36:38 PM3/11/14
to puppet...@googlegroups.com
Thats the nature of puppet.

It describes the 'state' of your node. So the file cannot be present
and absent at the same time.


you could use an exec that wget/curl/... your tempfile, execute it, and
remove it, and using a creates => <some file created by the script> to
run it only when needed.

depends on what you exactly wants to achieve.











--
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013 (PCP0000006)
_________________________________________________________

Open-Future Phone +32 (0)2/255 70 70
Zavelstraat 72 Fax +32 (0)2/255 70 71
3071 KORTENBERG Mobile +32 (0)474/42 40 73
BELGIUM http://www.open-future.be
_________________________________________________________


Next Events:
Zabbix Certified Training | http://www.open-future.be/zabbix-certified-training-10-till-12th-march
Zabbix for Large Environments Training | http://www.open-future.be/zabbix-large-environments-training-13-till-14th-march
Puppet Intruction Course | http://www.open-future.be/puppet-introduction-course-14th-april
Puppet Advanced Training | http://www.open-future.be/puppet-advanced-training-15-till-17th-april
Subscribe to our newsletter | http://eepurl.com/BUG8H

Kenton Brede

unread,
Mar 12, 2014, 9:43:16 PM3/12/14
to puppet...@googlegroups.com
How about ending your script with a command that removes itself?

/bin/rm path_to_script
or
/bin/rm $0

Kent


--
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/d503ce3f-7678-4056-8386-b7eaaa02eb66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kent Brede




Reply all
Reply to author
Forward
0 new messages