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

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