not if clauses work in some cases, but our team leverages chef tags as sentinels for controlling deployments as well. We just wrap the 'run once' code within an unless tagged('<yourtagnamehere>') block to prevent it from running if the node is tagged. This works for larger concerns such as wrapping an application resource block from deploying new versions of custom applications, but also works in the smaller cases like yours. Just remove the chef tag from the node and the next chef-client run will execute the controlled block. A few tips with this technique: 1. just make sure your recipe adds the tag back to the node object if it's successfully run. If you don't add the tag back it will execute on every chef-client run and what use is all that pretty code then, right? 2. If you use the recipe in more then one environment, you may want to use a compound condition in your if/unless block that checks for the existence of the tag as well as a the correct chef_environment. This allows you to control say the prod environment from continuously redeploying/restarting an app (especially if the devs make you use the HEAD of a git branch instead of a git tag) while still giving you the rapid updating in your dev envs without the hassle of having to run knife tag delete... each time. Greg Sent from my iPhone
|
Archive powered by MHonArc 2.6.16.