]> gitweb.fluxo.info Git - puppet-virtual.git/commitdiff
Additional /etc/hosts entry at build_vserver
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 16 Aug 2011 02:15:35 +0000 (23:15 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 16 Aug 2011 02:15:35 +0000 (23:15 -0300)
files/vserver/build_vserver

index ddf37e0cb038a60db19d0f3b414588354e922454..6b8e33f7fff18374d40dce62d7579124dcd8e519 100644 (file)
@@ -8,26 +8,29 @@ VHOSTNAME="$5"
 VINTERFACE="$6"
 
 if [ "$VHOSTNAME" != "none" ]; then
-  VHOSTNAME="--hostname $VHOSTNAME"
+  VHOSTNAME_OPT="--hostname $VHOSTNAME"
 fi
 
 if [ ! -z "$VINTERFACE" ]; then
-  VINTERFACE="--interface $VINTERFACE"
+  VINTERFACE_OPT="--interface $VINTERFACE"
+  VIP="`echo $VINTERFACE | cut -d : -f 2 | cut -d '/' -f 1`"
 fi
 
 # create basic vserver
 vserver $NAME build -n $NAME --context $CONTEXT \
-        $VHOSTNAME $VINTERFACE -m debootstrap -- -d $RELEASE -m $DEBOOTSTRAP_MIRROR || exit 1
+        $VHOSTNAME_OPT $VINTERFACE_OPT -m debootstrap -- -d $RELEASE -m $DEBOOTSTRAP_MIRROR || exit 1
 
 # copy in some some defaults
 TARGET=/etc/vservers/$NAME/vdir/
 cp /etc/apt/{preferences,sources.list} $TARGET/etc/apt/
 
-# this is needed so puppet can find the puppetmaster and creates the right
-# certificate
-#grep -v $NAME /etc/hosts > $TARGET/etc/hosts
-#echo "127.0.0.1 $NAME" >> $TARGET/etc/hosts
-echo "127.0.0.1 $NAME" > $TARGET/etc/hosts
+# add minimum /etc/hosts entries
+if [ "$VHOSTNAME" != "none" ]; then
+  echo "$VIP $VHOSTNAME" > $TARGET/etc/hosts
+fi
+
+echo "127.0.0.1 $NAME" >> $TARGET/etc/hosts
+
 #mkdir -p $TARGET/var/lib/puppet/modules/dbp
 #cp /var/lib/puppet/modules/dbp/puppet_current.deb $TARGET/var/lib/puppet/modules/dbp/