#!/usr/bin/python
########################################################################
#vmwareInstall.py
#
#This will automatically complete the vmware-install.pl for a VMware
# Server 1.0.4. After that runs, the script hand over the
# vmware-config.pl to you. At some point, I'll rework this to
# complete the other half of it as well
#
#Author: Mike Dunphy <mdunphy AT spu DOT edu>
#
# License:
# This Script is hereby placed in the public domain. Anyone
# is encouraged to use or modify it, and distribute modified or
# unmodified copies.
#
# Disclaimer:
# Mike Dunphy takes no responsibility for and will not support your
# use of this script.
########################################################################
import os
import pexpect
import sys
user = 'your username goes here'
EULA = "answer EULA_AGREED yes"
URL = raw_input("Please enter URL for VMware download: ")
os.system('wget -P /home/%s/ %s' % (user,URL)
os.system('tar zxf VMware-server*')
os.chdir('/home/%s/vmware-server-distrib' % user)
p = pexpect.spawn('/home/%s/vmware-server-distrib/vmware-install.pl' % user)
p.expect('/bin]')
p.sendline()
p.expect('/etc]')
p.sendline()
p.expect('/init.d]')
p.sendline()
p.expect('/sbin]')
p.sendline()
p.expect('/vmware]')
p.sendline()
p.expect('yes]')
p.sendline()
p.expect('/man]')
p.sendline()
p.expect('/vmware]')
p.sendline()
p.expect('yes]')
p.sendline()
p.expect('yes]')
p.sendline('yes')
p.close(force=True)
os.system('echo %s >> /etc/vmware/locations' % EULA)
p2 = pexpect.spawn('/usr/bin/vmware-config.pl')
p2.expect('/icons]')
p2.sendline()
p2.expect('/applications]')
p2.sendline()
p2.expect('/pixmaps]')
p2.sendline()
p2.expect('yes]')
p2.sendline()
p2.expect('/include]')
p2.sendline()
p2.expect('yes]')
p2.sendline()
p2.expect('yes]')
p2.sendline()
p2.expect('yes]')
p2.sendline()
p2.expect('no]')
p2.sendline()
p2.expect('yes]')
p2.sendline()
p2.expect('yes]')
p2.sendline()
p2.expect('no]')
p2.sendline()
p2.expect('902]')
p2.sendline()
p2.expect('Machines]')
p2.sendline('/VMs')
p2.expect('yes]')
p2.sendline()
p2.expect('cancel:')
p2.sendline('Enter your serial')
sys.exit(0)
Friday, March 14, 2008
VMware Automation Part 2
Eureka! I found it. So now I can automate the vmware-config.pl part of the installation. It turns out that VMware Server keeps a database of sorts in /etc/vmware/locations. This is created during the vmware-install.pl run. If you append "answer EULA_AGREED yes" (without the quotes) to the locations file, it will not present you with the EULA. Here is the complete code. Again, please comment.
Thursday, March 13, 2008
VMware Automation
I've been looking around the net to find a way to automate a VMware Server install on Linux. In the documentation there is a way to automate the install for Windows, but not Linux. In our environment, we run a minimal Ubuntu 7.10 install for our hosts. Below is my hackish attempt to automate it. This works for our environment but I make no claims it will work for yours. The first script installs the packages and sets a couple variables that are important to us. The second script handles the vmware-install.pl portion automatically, but hands the vmware-config.pl over to the user. I welcome any comments as I know that there is a better way to do this.
#!/bin/bash
########################################################################
#hostprep.sh
#
#Prep base Ubuntu 7.10 install for VMware Server Use
#
#Author: Mike Dunphy <mdunphy AT spu DOT edu>
#
# License:
# This Script is hereby placed in the public domain. Anyone
# is encouraged to use or modify it, and distribute modified or
# unmodified copies.
#
# Disclaimer:
# Mike Dunphy takes no responsibility for and will not support your
# use of this script.
########################################################################
#Fix /bin/dash symlink
ln -s -f /bin/bash /bin/sh
echo "Setting http_proxy environment variable"
#We use a proxy server
echo "http_proxy=ourproxyserver" > /etc/bash.bashrc
export http_proxy=ourproxyserver:8888
#Set sources list to the latest known full list of repositories
echo "Setting up apt sources list"
echo "3";sleep 1;echo "2";sleep 1;echo "1";sleep 1
cp -vpr /etc/apt/sources.list /etc/apt/sources.list.orig
echo "
deb http://us.archive.ubuntu.com/ubuntu/ gutsy main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ gutsy main restricted
deb http://us.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ gutsy universe
deb-src http://us.archive.ubuntu.com/ubuntu/ gutsy universe
deb http://us.archive.ubuntu.com/ubuntu/ gutsy-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ gutsy-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ gutsy multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ gutsy multiverse
deb http://us.archive.ubuntu.com/ubuntu/ gutsy-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ gutsy-updates multiverse
deb http://us.archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu gutsy partner
deb-src http://archive.canonical.com/ubuntu gutsy partner
deb http://security.ubuntu.com/ubuntu gutsy-security main restricted
deb-src http://security.ubuntu.com/ubuntu gutsy-security main restricted
deb http://security.ubuntu.com/ubuntu gutsy-security universe
deb-src http://security.ubuntu.com/ubuntu gutsy-security universe
deb http://security.ubuntu.com/ubuntu gutsy-security multiverse
deb-src http://security.ubuntu.com/ubuntu gutsy-security multiverse
" > /etc/apt/sources.list
echo "running update"
echo "3";sleep 1;echo "2";sleep 1;echo "1";sleep 1
#update and upgrade the system
apt-get update
echo "running upgrade"
echo "3";sleep 1;echo "2";sleep 1;echo "1";sleep 1
apt-get -y -q dist-upgrade
echo "running installs"
echo "3";sleep 1;echo "2";sleep 1;echo "1";sleep 1
#put ia32-libs into list if it's a 64-bit system
apt-get -y -q install build-essential linux-headers-`uname -r` icewm xserver-xfree86 x-window-system-core xdm ssh python-pexpect
apt-get -y -q install xinetd open-iscsi
DEBIAN_FRONTEND=noninteractive apt-get -y -q install postfix mailx
postconf -e "relayhost=smtp.spu.edu" #Change back to alertmail.spu.edu
echo "Setting mail stuff and sending test"
echo "3";sleep 1;echo "2";sleep 1;echo "1";sleep 1
echo "mailing account" > /home/<username>/.forward
chown <username:username> /home/<username>/.forward
chmod 644 /home/<username>/.forward
echo "Test message from $HOSTNAME" |mailx -s "$HOSTNAME test message" srommen
apt-get -y -q install ntp
cp /etc/ntp.conf /etc/ntp.conf.orig
sed -e 's/server ntp.ubuntu.com/server spu.local/g' /etc/ntp.conf > /etc/ntp.holder && mv /etc/ntp.holder /etc/ntp.conf
sed -e 's/#statsdir/statsdir/g' /etc/ntp.conf > /etc/ntp.holder && mv /etc/ntp.holder /etc/ntp.conf
/etc/init.d/ntp restart
echo "Script has finsihed prepping system, please reboot by typing sudo reboot"
#!/usr/bin/python
########################################################################
#vmwareInstall.py
#
#This will automatically complete the vmware-install.pl for a VMware
# Server 1.0.4. After that runs, the script hand over the
# vmware-config.pl to you. At some point, I'll rework this to
# complete the other half of it as well
#
#Author: Mike Dunphy <mdunphy AT spu DOT edu>
#
# License:
# This Script is hereby placed in the public domain. Anyone
# is encouraged to use or modify it, and distribute modified or
# unmodified copies.
#
# Disclaimer:
# Mike Dunphy takes no responsibility for and will not support your
# use of this script.
########################################################################
import os
import pexpect
import sys
user = 'your username goes here'
URL = raw_input("Please enter URL for VMware download: ")
os.system('wget -P /home/%s/ %s' % (user,URL)
os.system('tar zxf VMware-server*')
os.chdir('/home/%s/vmware-server-distrib' % user)
p = pexpect.spawn('/home/%s/vmware-server-distrib/vmware-install.pl' % user)
p.expect('/bin]')
p.sendline()
p.expect('/etc]')
p.sendline()
p.expect('/init.d]')
p.sendline()
p.expect('/sbin]')
p.sendline()
p.expect('/vmware]')
p.sendline()
p.expect('yes]')
p.sendline()
p.expect('/man]')
p.sendline()
p.expect('/vmware]')
p.sendline()
p.expect('yes]')
p.sendline()
p.expect('yes]')
p.sendline('yes')
p.interact()
Beginning the Journey
My name is Mike and I'm a Sys Admin for a local university in Western Washington. I decided to start this blog to chronicle the everyday issues and problems I face during the work day. I am a self taught system administrator primarily responsible for supporting the email environment for the university. I am a troubleshooter at heart so while my method's may not be traditional in approach, my goal is always to get to the base issues of a problem and get them solved.
My hope is that the issues I face will resonate with you and that I can hopefully find some resolutions that might help you with your work/hobby. Please feel free to comment and point out things that you don't agree with or might do better. I'm not a coder so many of my programming methods may make you scratch your head. I thank you for reading and enjoy.
Thus begins the journey...
My hope is that the issues I face will resonate with you and that I can hopefully find some resolutions that might help you with your work/hobby. Please feel free to comment and point out things that you don't agree with or might do better. I'm not a coder so many of my programming methods may make you scratch your head. I thank you for reading and enjoy.
Thus begins the journey...
Subscribe to:
Posts (Atom)