Skip to content

Commit

Permalink
Allow for masterless setups
Browse files Browse the repository at this point in the history
  • Loading branch information
edestecd committed May 17, 2015
1 parent dfefff3 commit 4301c08
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions service.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#!/usr/bin/env bash
#
# Start the Puppet Agent Service or Cron
# Start the Puppet Service or Cron
#
set -e

PUPPET_SERVICE=${PUPPET_SERVICE:-"puppet" # "com.puppetlabs.puppet"}
PUPPET_CRON=${PUPPET_CRON:-"/usr/bin/puppet agent --onetime --no-daemonize --splay"}

case "${PUPPET_SERVER}" in
localhost)
PUPPET_CRON_NAM=${PUPPET_CRON_NAM:-"puppet-apply"}
PUPPET_CRON_CMD=${PUPPET_CRON_CMD:-"/usr/bin/puppet apply --parser future /etc/puppet/manifests"}
;;
*)
PUPPET_CRON_NAM=${PUPPET_CRON_NAM:-"puppet-agent"}
PUPPET_CRON_CMD=${PUPPET_CRON_CMD:-"/usr/bin/puppet agent --onetime --no-daemonize --splay"}
;;
esac

if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root." >&2
Expand All @@ -17,6 +27,6 @@ fi
# sudo puppet resource service ${PUPPET_SERVICE} ensure=running enable=true
# Create a Cron Job Instead
echo "Starting Puppet Cron..."
puppet resource cron puppet-agent ensure=present command="${PUPPET_CRON}" user=root minute=0
puppet resource cron ${PUPPET_CRON_NAM} ensure=present command="${PUPPET_CRON_CMD}" user=root minute=0
# Force a run to generate ssl sign request
puppet agent --test || true
# puppet agent --test || true

0 comments on commit 4301c08

Please sign in to comment.