https://github.com/aolabs/puppet-retrypuppet
Basic Python script to retry puppet-agent runs if the database is locked.
https://github.com/aolabs/puppet-retrypuppet
puppet puppet-agent puppet-forge puppet-module
Last synced: 5 days ago
JSON representation
Basic Python script to retry puppet-agent runs if the database is locked.
- Host: GitHub
- URL: https://github.com/aolabs/puppet-retrypuppet
- Owner: aolabs
- License: lgpl-3.0
- Created: 2017-02-28T22:55:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-29T23:06:34.000Z (about 9 years ago)
- Last Synced: 2026-04-19T20:11:57.759Z (about 1 month ago)
- Topics: puppet, puppet-agent, puppet-forge, puppet-module
- Language: Python
- Size: 26.4 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# retrypuppet
[](https://travis-ci.org/aolabs/puppet-retrypuppet)
[](https://coveralls.io/github/aolabs/puppet-retrypuppet)
[](https://github.com/aolabs/puppet-retrypuppet/issues)
[](https://forge.puppetlabs.com/aolabs/retrypuppet)
[](https://forge.puppetlabs.com/aolabs/retrypuppet)
[](https://aolabs.nz)
#### Table of Contents
1. [Description](#description)
1. [Usage](#usage)
1. [Contributors](#contributors)
1. [ChangeLog](#changelog)
## Description
Provides a simple python based wrapper script around `puppet agent` to automatically retry in the event that a run is already in progress.
Where the puppet agent is polling at a high frequency, whether in "apply" mode or "noop" mode for audit purposes, it is likely that any manual agent run will clash with the agent already running in the background. This can be especially irritating where an orchestration tool such as mCollective or Salt is used to run puppet - perhaps as part of a deployment process.
```shell
# puppet agent -tv
Notice: Run of Puppet configuration client already in progress; skipping (/opt/puppetlabs/puppet/cache/state/agent_catalog_run.lock exists)
```
## Usage
Add the below to your manifests for any machine on which you want to run `puppet agent`:
```puppet
class { '::retrypuppet': }
```
Then simply use the `retrypuppet` wrapper script in place of the `puppet` binary. The script passes any arguments specified on its command-line directly to the `puppet` binary, passes any output from the puppet binary on its standard output (note that any agent output to stderr will be flattened to stdout), and will return Puppet's returncode as its returncode. If the agent returns a notice that a run is already in progress, then `retrypuppet` will wait for a 30 second back-off period before trying again. After 10 "blocked" attempts, `retrypuppet` will exit returning 11 (EAGAIN). To reduce noise, `retrypuppet` will not display any output from a blocked run other than a notice.
```shell
# retrypuppet agent -tv
Run already in progress, will retry in 30 seconds, 9 attempts remain...
Run already in progress, will retry in 30 seconds, 8 attempts remain...
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for centos-puppet.localdomain
Info: Applying configuration version '1488412377'
Notice: Applied catalog in 1.14 seconds
```
## Contributors
Original module authored by Patrick Brennan and released under the LGPLv3 license courtesy of Hapara LLC. Ongoing maintenance by AO Labs courtesy of Patrick Brennan.
## ChangeLog
* 1.1.0 Documentation updates, Travis-CI test integration, return puppet's return code (issue #45).
* 1.0.1 Support Python 2 and 3.
* 1.0.0 Initial release, Python 3 only.