Ask Your Question
0

Puppet - rollback in a case of failure

asked 2018-06-28 03:54:39 -0500

Dan1 gravatar image

Hi, When I'm running my puppet (in order to install a new version of our product), and it fails (the error code isn't 0) - is there any option to do rollback (I mean, to install again the previous version [before the puppet's installation])?

Thanks a lot, Dan.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-06-30 14:52:39 -0500

reesek gravatar image

Hi Dan

A few things on this.

  1. If the puppet run failed, then it shouldn't have changed the resource on which it failed. Based on the context of your question, it seems it revolves around a particular resource as opposed to having changed other resources before failing on another.
  2. If you're insinuating that the error code returned isn't 0, meaning the exit code $? wasn't zero, this doesn't necessarily mean failure in the Puppet world. Refer to the --detailed-exitcodes on the agent man page.
  3. There's always the option of performing a --noop Puppet Agent run (a dry run) to get a preview into what Puppet will affect before actually implementing. See the aforementioned man page for details on the --noop option.
  4. File resource types have a built in file bucket where files can be stored and retrieved. Check out the documentation on this as well.
  5. Testing changes in Puppet code can always be performed inside of a dynamic Puppet environment by allowing the agent to override its assigned environment group during a single Puppet run. This of course works in the case where a resource that's already being managed by Puppet is being updated, otherwise new changes applied inside the dynamic environment will become unmanaged when the agent is returned to its console assigned environment group. This point is a bit of an advanced workflow, but is an efficient one at that when wanting to roll out a change to an entire fleet but want to test impact on a handful of nodes before doing so.
  6. If ever in doubt, and working in a virtualized environment, you can always snapshot the machine.

If I missed the mark on what you're asking, please elaborate.

-- Kris

edit flag offensive delete link more

Comments

Hi Kris, Thanks for your response. I will explain my question. Let's take an example - I have some sql files and I want to run them on one or more databases. Unfortunately, on some of databases it ran successfully, but on others databases - it failed.

Dan1 gravatar imageDan1 ( 2018-07-02 04:00:27 -0500 )edit

This is a problematic case because I don't want that only some of the databases will be updated. I want that all of them will be updated. So in this case, the expected result is to go back to the initial state (before the puppet running), You can call it "roll back" or "revert". Thanks a lot, Dan

Dan1 gravatar imageDan1 ( 2018-07-02 04:01:53 -0500 )edit
1

Hey Dan. Are these sql files being applied via an exec resource type? If so, that'll be tough to do. If these systems are the same, I'd start looking into why some fail, and others do not, and reconcile accordingly. Generally, consistent systems should succeed and/or fail consistently as a unit.

reesek gravatar imagereesek ( 2018-07-02 20:48:05 -0500 )edit
1

This is something that should probably be done, in a supervised manor, with puppet tasks, not baked into a regular puppet module.

DarylW gravatar imageDarylW ( 2018-07-05 06:51:28 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-06-28 03:54:39 -0500

Seen: 96 times

Last updated: Jun 30