Rewrote puppet/bootstrap-server.sh with support for apache and webrick

This commit is contained in:
Ossi Salmi 2012-04-18 16:28:21 +03:00
parent b32de307b1
commit 9ca7751a0c
2 changed files with 42 additions and 67 deletions

View file

@ -1,5 +1,16 @@
#!/bin/sh
case $1 in
apache|webrick)
SERVER=$1
;;
*)
echo "usage: $0 apache|webrick" 1>&2
exit 1
;;
esac
hostname -f | fgrep "." > /dev/null
if [ $? -ne 0 ]; then
echo "error, command 'hostname -f' does not return domainname" 1>&2
@ -18,31 +29,40 @@ if [ $? -ne 0 ]; then
exit 1
fi
mkdir -p /etc/puppet/manifests
if [ ! -s /etc/puppet/manifests/site.pp ]; then
echo "" > /etc/puppet/manifests/site.pp
if [ -s /etc/puppet/puppet.conf ]; then
mv /etc/puppet/puppet.conf /etc/puppet/puppet.conf.orig
fi
cat /dev/null > /etc/puppet/puppet.conf
FQDN="$(hostname -f)"
ssldir=`echo "require 'puppet'; Puppet.parse_config; print Puppet.settings.value('ssldir')" | ruby`
mkdir -p /etc/puppet/manifests/node
if [ ! -d ${ssldir}/ca ]; then
puppetca --certname ca --keylength 4096
cat > /etc/puppet/manifests/site.pp << EOF
import "node/*.pp"
\$puppet_server = "${FQDN}"
EOF
cat > /etc/puppet/manifests/node/${FQDN}.pp << EOF
node "${FQDN}" {
EOF
if [ "${SERVER}" = "apache" -a -f /etc/redhat-release ]; then
cat >> /etc/puppet/manifests/node/${FQDN}.pp << EOF
include user::system
realize(User["httpsd"], Group["httpsd"])
EOF
fi
puppet --version | egrep "^0\." > /dev/null 2>&1
if [ $? -eq 0 ]; then
(
echo "\$homename = '`hostname -f`'"
echo "\$puppet_ssldir = '${ssldir}'"
echo "\$puppet_storeconfigs = 'none'"
echo "include puppet::server::apache"
echo "include puppet::manual"
) | puppet --no-report
else
(
echo "include puppet::server::apache"
echo "include puppet::manual"
) | puppet apply --no-report --manifest /dev/stdin /dev/null
fi
cat >> /etc/puppet/manifests/node/${FQDN}.pp << EOF
include puppet::server::${SERVER}
include puppet::manual
}
EOF
puppet cert --keylength 4096 --list
puppet apply --no-report --tags bootstrap /etc/puppet/manifests/site.pp
puppet apply --no-report /etc/puppet/manifests/site.pp

View file

@ -1,45 +0,0 @@
#!/bin/sh
hostname -f | fgrep "." > /dev/null
if [ $? -ne 0 ]; then
echo "error, command 'hostname -f' does not return domainname" 1>&2
exit 1
fi
which ruby > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "error, ruby binary not in path" 1>&2
exit 1
fi
which puppet > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "error, puppet binary not in path" 1>&2
exit 1
fi
if [ -s /etc/puppet/puppet.conf ]; then
mv /etc/puppet/puppet.conf /etc/puppet/puppet.conf.orig
fi
FQDN="$(hostname -f)"
mkdir -p /etc/puppet/manifests/node
cat > /etc/puppet/manifests/site.pp << EOF
import "node/*.pp"
\$puppet_server = "${FQDN}"
EOF
cat > /etc/puppet/manifests/node/${FQDN}.pp << EOF
node "${FQDN}" {
include puppet::server::webrick
include puppet::manual
}
EOF
puppet cert --keylength 4096 --list
puppet apply --no-report /etc/puppet/manifests/site.pp