Skip to content

Instantly share code, notes, and snippets.

@cwolferh
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save cwolferh/8850735 to your computer and use it in GitHub Desktop.

Select an option

Save cwolferh/8850735 to your computer and use it in GitHub Desktop.
# Installs libvirt, vftool.bash, readies a foreman server with three
# clients, and starts vncserver. Intended to be run on a fresh el6
# system to get a working development environment. If you already
# have VM's / libvirt running on your system, you probably don't want
# to run this script (things like the default network and storage pool
# path get changed during the "./vftool" commands).
export INSTALLURL=<your el6 repo, e.g. http://<your host>/6.5/Server/x86_64/os/>
export REG_SCRIPT=<path to script that registers/points host to el and openstack (rdo or rhos) repos>
export INITIMAGE=rhel65
export FOREMAN_NODE=fore1a
# next two vars means 3 foreman-client vms are created: c1a1 c1a2 c1a3
VMSET_CHUNK=c1a
NUM_CLIS=3
ASTAPOR=https://github.com/redhat-openstack/astapor
BRANCH=master
mkdir -p /mnt/vm-share
chmod ugo+rwx /mnt/vm-share
cd /mnt/vm-share
git clone https://github.com/cwolferh/vms-and-foreman vftool
git clone https://github.com/cwolferh/moar-cowbell-scripts mcs
git clone $ASTAPOR; cd astapor; git checkout $BRANCH; cd /mnt/vm-share
# could be useful to yum update the initimage (a todo):
# git clone https://gist.github.com/3728817.git virtip
export PATH=$PATH:/mnt/vm-share/vftool
cd vftool
./vftool.bash host_depends
./vftool.bash host_permissive
./vftool.bash libvirt_prep
./vftool.bash default_network_ip
./vftool.bash create_foreman_networks
./vftool.bash vm_auth_keys
./vftool.bash kick_first_vm
sleep 60
echo 'waiting for kick_first_vm to complete'
check='$(virsh domstate '$INITIMAGE' | grep -q "shut off")'
while ! eval $check; do
sleep 10
echo .
done
# TODO yum update initimage vm before it gets cloned
# virsh start $INITIMAGE ...
# install the foreman vm
INITIMAGE=rhel65 \
FOREMAN_NODE=$FOREMAN_NODE \
UNATTENDED=true \
FROM_SOURCE=true \
POST_INSTALLER_SNAP=true \
FOREMAN_CLIENT_SCRIPT=/mnt/vm-share/${FOREMAN_NODE}_client.sh \
REG_SCRIPT=$REG_SCRIPT \
bash -x /mnt/vm-share/mcs/foreman/install-foreman.bash
# install the foreman client vm's
INITIMAGE=rhel65 \
FOREMAN_NODE=$FOREMAN_NODE \
UNATTENDED=true \
REG_SCRIPT=$REG_SCRIPT \
FOREMAN_CLIENT_SCRIPT=/mnt/vm-share/${FOREMAN_NODE}_client.sh \
SKIPSNAP=true \
VMSET_CHUNK=$VMSET_CHUNK \
bash -x /mnt/vm-share/mcs/client-vms/new-foreman-clients.bash $NUM_CLIS
# set static IP's on client vm's
for i in 1 2 3; do
vftool.bash configure_nic ${VMSET_CHUNK}$i static eth2 192.168.200.${i}0 255.255.255.0
vftool.bash configure_nic ${VMSET_CHUNK}$i static eth3 192.168.201.${i}0 255.255.255.0
done
yum -y install gnome-session firefox xterm
mkdir -p /root/.vnc
cd /root/.vnc
wget <your startup file>
chmod ugo+x xstartup
echo 'foreman' | vncpasswd -f >passwd
chmod go-rw passwd
vncserver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment