Created
October 16, 2014 04:35
-
-
Save treydock/2bf5e08caf4284c19c14 to your computer and use it in GitHub Desktop.
Puppet masterless script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| readonly ENVIRONMENTPATH="/apps/puppet/environments" | |
| readonly DEF_ENV="production" | |
| readonly PROGNAME=$(basename $0) | |
| usage () { | |
| cat << EOF | |
| usage: ${PROGNAME} [OPTIONS] | |
| Puppet masterless script. | |
| All arguments are passed to "puppet apply" except those listed under OPTIONS. | |
| OPTIONS: | |
| -d, --debug Show debug output | |
| -h, --help Show this message | |
| EXAMPLES: | |
| Run puppet apply against site.pp in ${ENVIRONMENTPATH}/${DEF_ENV}/manifests | |
| ${PROGNAME} | |
| Run puppet apply using --noop against site.pp in ${ENVIRONMENTPATH}/${DEF_ENV}/manifests | |
| ${PROGNAME} --noop | |
| EOF | |
| } | |
| ARGS=() | |
| while test ${#} -gt 0; do | |
| case $1 in | |
| -h|--help) usage ; exit 0 ;; | |
| -d|--debug) set -x ;; | |
| *) ARGS+=($1) ;; | |
| esac | |
| shift | |
| done | |
| ENVIRONMENT="${PUPPET_ENV:-$DEF_ENV}" | |
| PUPPET_ARGS="${ARGS[@]}" | |
| CONFDIR="${ENVIRONMENTPATH}/${ENVIRONMENT}" | |
| SITEPP="${CONFDIR}/manifests/site.pp" | |
| CMD="puppet apply --confdir ${CONFDIR} ${SITEPP} --write-catalog-summary ${PUPPET_ARGS}" | |
| if [ ! -f /var/lib/puppet/state/agent_disabled.lock ]; then | |
| eval $CMD | |
| ret=$? | |
| fi | |
| exit $ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment