Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

Running an Exec resource *before* deleting a File resource

$
0
0
I have a class that is adding a (rhel6) 'upstart' configuration in /etc/init. When Puppet creates the configuration file, I have to execute "initctl start " based on the service name that I'm adding. The problem that I'm having is that I need an exec to run *before* I remove the file so that I shut down the service before the file gets removed. If I don't shut down the service, then 'initctl' complains that the service isn't there. Now, "service" isn't in the true sense of a Puppet service. It's more of a 'reload' or "telinit q' (for SysV). Here's what I have: case $enabled { true: { # Create the upstart file then start the 'service'. $file_ensure = file $cmd_refresh_init = "start" File[$iucvtty_file] ~> Exec[$refresh_init_exec] } false: { # Stop the upstart 'service' then delete the file. $file_ensure = absent $cmd_refresh_init = "stop" Exec[$refresh_init_exec] -> File[$iucvtty_file] } } # case file {$iucvtty_file: ensure => $file_ensure, content => template("${name}/${template_file}"), } exec {$refresh_init_exec: command => $cmd_refresh_init, refreshonly => true, logoutput => true, } When $enabled = true everything works just fine. When $enabled = false, the exec never runs yet the configuration file gets removed. I would have thought that with the following chain: Exec[$refresh_init_exec] -> File[$iucvtty_file] the resource ordering would have been satisfied. Unfortunately even when I remove "refreshonly" the exec still doesn't run. Is there any way (cleanly) to get this exec to run BEFORE the File resource gets removed?

Viewing all articles
Browse latest Browse all 6104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>