Created
June 29, 2013 18:01
-
-
Save marten-cz/5892071 to your computer and use it in GitHub Desktop.
Create new OpenVZ container and setup Puppet
This file contains 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 | |
ID=$1 | |
NAME=$2 | |
if [ $# -ne 2 ] | |
then | |
echo "Usage: `basename $0` <id> <name>" | |
exit 65 | |
fi | |
if [ $ID -lt 100 -o $ID -ge 255 ]; then | |
echo "ID must be in range 100 to 200" | |
exit 1 | |
fi | |
if [ -z $NAME ]; then | |
echo "Name cannot be empty" | |
exit 1 | |
fi | |
vzlist $ID > /dev/null 2>&1 | |
if [ $? -ne 1 ]; then | |
echo "Container already exists" | |
exit 1 | |
fi | |
vzctl create $ID --root /mnt/md2/vz/root/$ID --private /mnt/md2/vz/private/$ID --ostemplate debian-6.0-amd64-minimal && \ | |
vzctl set $ID --ipadd 192.168.1.$ID --save && \ | |
vzctl set $ID --nameserver 192.168.1.100 --nameserver 127.0.1.1 --searchdomain home.lan --save && \ | |
vzctl set $ID --hostname $NAME --save | |
read -p "Install puppet? (y/N) " -n 1 -r | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
vzctl start $ID | |
sleep 10 | |
vzctl exec $ID apt-get update | |
vzctl exec $ID apt-get install puppet | |
vzctl exec $ID puppet agent --server puppet.home.lan | |
vzctl exec 200 puppet cert sign $NAME | |
vzctl exec $ID puppet agent -tdv | |
vzctl exec $ID sed "s/START=no/START=yes/" -i /etc/default/puppet | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment