Tag: vmware tools

  • Redhat 6 Minimal Kickstart Configuration with VMware Tools and Puppet Agent Install

    smartaHere is my small, crude, little Kickstart configuration and post install script that I have up and running in my lab at home. Don’t expect to find anything too fancy here, as this Kickstart was purposefully built to be small and to the point. Here, the point was to spin up a VM, run through a basic install of CentOS/Redhat Linux,  and install VMware Tools along with a Puppet agent.

    Note that this post assumes that you have a working Kickstart server.

    First lets take a look at our kickstart file, CentOS-6.6-x86_64-minimal.ks

    The section directly below kicks off our kickstart ks file. Here we set our root password (no that’s not my hash) and setup our network interface for DHCP. We do a tiny bit of disk partitioning, and setup very simple LVM. Then we choose our packages. As you can see my package list is not at all fancy, I just want to make sure that I have pretty much every package that might need for a lab VM.

    [code language=”bash”]
    # Kickstart file for RHEL 6 Minimal
    # Small Disk

    text
    install
    url –url=http://10.1.0.106/ks/loop/CentOS-6.6-x86_64-bin-DVD1
    lang en_US.UTF-8
    keyboard us
    network –onboot yes –device eth0 –bootproto dhcp –noipv6
    rootpw –iscrypted $6$X/4YYZPN$4Sv.khxXms8N8vRssR/Vl35w/m80FF5P6p7aX0D7EFfD9p734F6tU4kXdcSCoOjPiXLrVxqfKxxxxxxxxxxxq5551
    firewall –disabled
    authconfig –enableshadow –passalgo=sha512
    selinux –permissive
    timezone America/New_York

    # Disk
    bootloader –location=mbr –driveorder=sda –append="crashkernel=auto rhgb"
    zerombr
    clearpart –all –drives=sda
    part pv.1 –grow –size=1
    part /boot –fstype=ext4 –size=1024
    volgroup VolGroup pv.1
    logvol / –fstype=ext4 –name=lv_root –vgname=VolGroup –size=1024 –grow
    logvol swap –name=lv_swap –vgname=VolGroup –size=1024

    #Network
    network –device=eth0 –bootproto=dhcp –nameserver=10.1.0.110

    # Package Selection
    %packages –nobase –excludedocs
    @Base
    @core
    kernel-headers
    wget
    perl
    sysstat
    bind-utils
    tcpdump
    [/code]

    Now let me pause to point out the section below. This is the %pre script that I am using to prompt me for the VM hostname before the install begins. The hostname needs to be set before you install puppet on the VM, otherwise you are going to have to recreate your puppet certificates after you set properly set your hostname post install and reboot.

    [code language=”bash”]
    %pre –log=/root/ks_pre.log
    #change to tty6 to get input
    chvt 6
    exec </dev/tty6 > /dev/tty6

    #Prompt for hostname
    echo "What is my hostname?"
    read NAME
    echo "NETWORKING=yes
    HOSTNAME=${NAME}" > network
    chvt 1
    [/code]

    Now we run a simple post install, along with a custom post install script. It is this script that will install Vmware tools and Puppet. Myself, I prefer keeping most of my code out of the actual Kickstart ks file, however you can always jam all your code into it if you like. You will just need to validate your syntax first, as I have not tested my config this way.

    [code language=”bash”]
    %post –nochroot
    # bring in hostname collected from %pre, then source it
    cp network /mnt/sysimage/etc/sysconfig/network
    . /mnt/sysimage/etc/sysconfig/network
    # force hostname change
    /mnt/sysimage/bin/hostname $HOSTNAME
    #Post Install
    %post –log=/root/ks-post.log
    cd /root
    echo "Getting the post install script – if this takes a long time check network or path"
    wget http://10.1.0.106/ks/scripts/centos-6-postinstall.bash
    echo "Running the post install script"
    /bin/bash centos-6-postinstall.bash
    [/code]

    Ok, so below is the post install script that I am calling in the section above. After a quick modification of my hosts file, I pull down the Puppet installer from my local Puppet server. Next we install the open source VMware tools packages, after creating the required yum repofile.

     

    [code language=”bash”]
    #!/bin/bash
    #centos-6-postinstall.bash

    #Switch to the 6th console and redirect all i/o
    exec < /dev/tty6 > /dev/tty6 2> /dev/tty6
    chvt 6

    # Lets make sure we know who the puppet server is before we get too far
    echo "Adding hosts entry for puppet master"
    echo "10.1.0.115 puppet puppet.lab.localdomain" >> /etc/hosts

    ## Update Via Yum – not doing this for now in order to save time
    #yum -y update
    # Install puppet from local puppet master
    echo "Downloading and running Puppet installer"
    curl -k https://10.1.0.115:8140/packages/current/install.bash | sudo bash
    #Install Open Source VMware Tools
    rpm –import http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-DSA-KEY.pub
    rpm –import http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-RSA-KEY.pub

    echo -e "[vmware-tools]\nname=VMware Tools\nbaseurl=http://packages.vmware.com/tools/esx/5.1latest/rhel6/$HOSTTYPE\nenabled=1\ngpgcheck=1" > /etc/yum.repos.d/vmware-tools.repo

    echo "Installing Vmware Tools"
    yum -y install vmware-tools-esx-nox

    #Minor grub.conf modifications
    sed -i ‘s/rhgb quiet//’ /boot/grub/grub.conf
    sed -i ‘s/hiddenmenu//’ /boot/grub/grub.conf
    sed -i ‘s/timeout=5/timeout=10/’ /boot/grub/grub.conf

    #Kick off first puppet run, for some reason I think you might need to do this twice.
    sleep 5
    echo "Running Puppet for the first time"
    puppet agent –test
    puppet agent –test

    #Tell us we have reached the end
    echo "We have reached the end of the post-install script"
    [/code]

    A couple of additional details to note about the post install script above. I like to modify the grub.conf so that I unhide the menu and increase the time out. I also like to make sure that we disable the Redhat graphical boot screen… I want to make sure its easy to catch any errors or miss-configurations in my kickstarts.
     

  • How to Configure NTP in a RHEL/CentOS Vmware Guest

    HourglassSuccessful time keeping in a Virtual Machine can be a bit confusing. At times I have been told to use Vmware Tools to sync time between the Guest and the Host, and at time I have been advised to avoid this functionality and use NTP. The following information is direct from a VMware KB article (updated, 4/16/2010) so I am going to follow their lead on this and use NTP exclusively.

    First off VMware advises using the NTP service to keep time in sync, but it suggests
    using an additional kernel parameter that you add to your grub.conf. See the KB Article for more info on how to do this.

    • notsc for RHEL/Centos 4.6 64bit
    • notsc divider=10 for  RHEL/Centos 5.3 64bit

    Note that there are no additional params needed for 5.4

    http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006427

    Also, inside the ntp.conf the following line should be added to the top of the file.

    tinker panic 0

    This configuration directive instructs NTP not to give up
    if it sees a large jump in time. This is important for coping with large
    time drifts and also resuming virtual machines from their suspended state.

    It is also important not to use the local clock as a time source, often
    referred to as the Undisciplined Local Clock. NTP has a tendency to fall
    back to this in preference to the remote servers when there is a large
    amount of time drift.

    An example of such a configuration is below. You should comment out both
    lines.

    server 127.127.1.0

    fudge 127.127.1.0 stratum 10

    Also, if you are using ntp, you want to make sure that you disable
    Vmware tools time sync. You can do so with the following command via the
    guest OS.

    vmware-guestd –cmd “vmx.set_option synctime 1 0”