Skip to content

Commit

Permalink
Complete bootstrap with config and cron
Browse files Browse the repository at this point in the history
  • Loading branch information
edestecd committed Mar 12, 2015
1 parent d8c5019 commit 5f3a497
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
38 changes: 38 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
#
# Bootstrap script to install/config/start puppet on multi POSIX platforms
#
set -e

PLATFORM=${PLATFORM:-$1}

# Install Puppet Using the Puppet Labs Package Repositories
case "${PLATFORM}" in
redhat_5|centos_5|centos_5_x)
sudo ./centos_5_x.sh
;;
redhat_6|centos_6|centos_6_x)
sudo ./centos_6_x.sh
;;
redhat_7|centos_7|centos_7_x)
sudo ./centos_7_x.sh
;;
ubuntu)
sudo ./ubuntu.sh
;;
osx|mac_os_x)
PUPPET_ROOT_GROUP=${PUPPET_ROOT_GROUP:-"wheel"}
PUPPET_SERVICE=${PUPPET_SERVICE:-"com.puppetlabs.puppet"}
sudo ./mac_os_x.sh
*)
echo "Unknown/Unsupported PLATFORM. Usage: $0 {redhat_5|redhat_6|redhat_7|ubuntu|osx}" >&2
exit 1
esac

# Configure /etc/puppet/puppet.conf
. configure.sh

# Start the Puppet Agent Service
. service.sh

echo "Success!!"
58 changes: 58 additions & 0 deletions configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
#
# Configure /etc/puppet/puppet.conf
#
set -e

PUPPET_SERVER=${PUPPET_SERVER:-"pupt001.projectdragonfly.org"}
PUPPET_ENVIRONMENT=${PUPPET_ENVIRONMENT:-"staging"}
PUPPET_ROOT_GROUP=${PUPPET_ROOT_GROUP:-"root"}

echo "Configuring Puppet..."
sudo cat > /etc/puppet/puppet.conf <<-EOF
# Deployment puppet.conf config for puppet
# WARNING: this file has been automatically setup by puppet-bootstrap
# Please make changes there and rerun setup, not here, as they will be overwritten....
#
# http://docs.puppetlabs.com/references/latest/configuration.html
#
[main]
# The Puppet log directory.
# The default value is '\$vardir/log'.
logdir = \$vardir/log
# Where Puppet PID files are kept.
# The default value is '\$vardir/run'.
rundir = \$vardir/run
# Where SSL certificates are kept.
# The default value is '\$confdir/ssl'.
ssldir = \$vardir/ssl
server = ${PUPPET_SERVER}
masterport = 8140
report = true
pluginsync = true
[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate ``puppet`` executable using the ``--loadclasses``
# option.
# The default value is '\$confdir/classes.txt'.
classfile = \$vardir/classes.txt
# Where puppetd caches the local configuration. An
# extension indicating the cache format is added automatically.
# The default value is '\$confdir/localconfig'.
localconfig = \$vardir/localconfig
environment = ${PUPPET_ENVIRONMENT}
runinterval = 60m
splay = true
splaylimit = 20m
#ignorecache = true
EOF
sudo chown root:${PUPPET_ROOT_GROUP} /etc/puppet/puppet.conf
sudo chmod 0644 /etc/puppet/puppet.conf
15 changes: 15 additions & 0 deletions service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
#
# Start the Puppet Agent 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"}

# Start the Puppet Agent Service
# echo "Starting Puppet Agent..."
# sudo puppet resource service ${PUPPET_SERVICE} ensure=running enable=true
# Create a Cron Job Instead
echo "Starting Puppet Cron..."
sudo puppet resource cron puppet-agent ensure=present command="${PUPPET_CRON}" user=root minute=0

0 comments on commit 5f3a497

Please sign in to comment.