How to apply specific revision from Git of a configuration file and roll-back if not ok?

75 views Asked by At

Problem: I want to be able to install an RPM with a specific revision of a configuration file.

Take the following example:

Say I have an RPM I want to guarantee is installed and running. No problem here. Now say I want to provide a different configuration file for each puppet environment. Also no problem here.

But now say I want to do versioning control specifically and only on the configuration files, would then like to be able to detect that a new version exists of a configuration file, say in a Git repository and if so, the config file is applied and services restarted. If services run correctly then ok, if not, then old revision of configuration file should be re-applied (roll-back of configuration file to previous revision).

Is this at all possible with puppet? If so, what kind of architecture would be the best approach for such a scenario?

Any point in the right direction or help on this matter will be very much appreciated.

Thanks,

1

There are 1 answers

1
Felix Frank On BEST ANSWER

You could build a scheme after the following fashion:

  1. Have Puppet deploy credentials for your central git repository on each agent
  2. Use the vcsrepo type to allow Puppet to maintain a clone of the repo on each agent with the desired revision
  3. Have the config file resources use local sources.

    source => '/path/to/local/git/clone/my_config.ini'
    
  4. Use the validate_cmd parameter to make Puppet roll back if things are not OK.

    validate_cmd => 'apache2ctl configtest'
    
  5. Have the file notify the respective service, or the service subscribe to make Puppet reload the configuration upon changing it.

I don't see why you keep referencing RPM packages - they are not pertinent to the issue as far as I can tell.