VMware Cloud Community
ttarps
Contributor
Contributor

Problem getting %post config to run

Hello all,

This is my first attempt at getting an automated build created for VMware ESX 3.5 Update 3, the configuration script i'm using is below. It goes through the install okay and creates the file /etc/rc.d/rc.local but the script doesn't seem to run when the server boots up. I've read a few articles on this and have tried several different files and locations /etc/rc.d/S99postconfig, /etc/rc.d/rc3.d/S99postconfig, /etc/rc.d/S11servercfg, /etc/rc.d/rc3.d/S11servercfg and none of them seem to run. Can anybody tell me what i'm doing wrong.

Many thanks in advance.

Kickstart script

*

  1. Auto-Generated Scripted Install Configuration file.*

    1. This file is used for VMware ESX Server Scripted Install Deployment

*

    1. Installation Method*

*cdrom

  1. root Password*

*rootpw --iscrypted $zsbrvjhagwovuigakvgluizg/

  1. Authconfig*

*auth --enableshadow --enablemd5

  1. BootLoader ( The user has to use grub by default )*

*bootloader --location=mbr

  1. Timezone*

*timezone Europe/London

  1. X windowing System*

*skipx

  1. Install or Upgrade*

*install

  1. Text Mode*

*text

  1. Language*

*lang en_US

  1. Langauge Support*

*langsupport --default en_US

  1. Keyboard*

*keyboard us

  1. Mouse*

*mouse none

  1. Reboot after install ?*

*reboot

  1. Firewall settings*

*firewall --disabled

  1. Clear Partitions*

*clearpart --all --initlabel --drives=sda

  1. Partitioning*

part /boot --fstype ext3 --size 102 --ondisk sda

part / --fstype ext3 --size 4997 --ondisk sda

part swap --size 1600 --ondisk sda

part None --fstype vmfs3 --size 10000 --grow --ondisk sda

part None --fstype vmkcore --size 110 --ondisk sda

*part /var/log --fstype ext3 --size 1992 --ondisk sda

*

%packages

*@base

%vmlicense_text

%post*

cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bk

cat > /etc/rc.d/rc.local << EOC

*#!/bin/bash

  1. Put host into maintenance mode*

*vmware-vim-cmd /hostsvc/maintenance_mode_enter

  1. Update DNS resolution*

*vmware-vim-cmd /hostsvc/net/dns_set --dns-searchdomain=\`dnsdomainname\`,net.\`dnsdomainname\`

  1. Configure NTP*

esxcfg-firewall -e ntpClient

cat > /etc/ntp.conf << EOF

restrict kod nomodify notrap noquery nopeer

restrict 127.0.0.1

server 192.168.2.1

server 192.168.2.2

server 192.168.2.3

server 192.168.2.4

driftfile /var/lib/ntp/drift

EOF

cat > /etc/ntp/step-tickers << EOF

server 192.168.2.1

server 192.168.2.2

server 192.168.2.3

server 192.168.2.4

EOF

chkconfig ntpd on

service ntpd restart

*hwclock --systohc

  1. Modify service console memory*

*vmware-vim-cmd /hostsvc/memoryinfo 838860800

  1. Rename local storage*

*vmware-vim-cmd /hostsvc/datastore/rename \`hostname -s\`:storage1 "\`hostname -s\` local"

  1. Network config*

/usr/sbin/esxcfg-vswitch vSwitch0 -L vmnic1

vmware-vim-cmd /hostsvc/net/vswitch_setpolicy --nicorderpolicy-standby=vmnic1 vSwitch0

/usr/sbin/esxcfg-vswitch -a vSwitch1

/usr/sbin/esxcfg-vswitch -A "VMotion" vSwitch1

/usr/sbin/esxcfg-vswitch -M vmnic2 vSwitch1 -p "VMotion"

/usr/sbin/esxcfg-vswitch -L vmnic2 vSwitch1

/usr/sbin/esxcfg-vswitch -L vmnic4 vSwitch1

vmware-vim-cmd /hostsvc/net/vswitch_setpolicy --nicorderpolicy-active=vmnic2 vSwitch1

vmware-vim-cmd /hostsvc/net/vswitch_setpolicy --nicorderpolicy-standby=vmnic4 vSwitch1

/usr/sbin/esxcfg-vswitch -a vSwitch2

/usr/sbin/esxcfg-vswitch -L vmnic3 vSwitch2

/usr/sbin/esxcfg-vswitch -L vmnic6 vSwitch2

vmware-vim-cmd /hostsvc/net/vswitch_setpolicy --nicorderpolicy-active=vmnic3 vSwitch2

vmware-vim-cmd /hostsvc/net/vswitch_setpolicy --nicorderpolicy-standby=vmnic6 vSwitch2

vmware-vim-cmd /hostsvc/net/vswitch_setpolicy --securepolicy-promisc=false vSwitch2

vmware-vim-cmd /hostsvc/net/vswitch_setpolicy --securepolicy-macchange=false vSwitch2

*vmware-vim-cmd /hostsvc/net/vswitch_setpolicy --securepolicy-forgedxmit=false vSwitch2

  1. Allow DR LUN Availability*

*vmware-vim-cmd /hostsvc/advopt/update LVM.DisallowSnapshotLun int 0

  1. Reset system to boot normally*

mv /etc/rc.d/rc.local /tmp/rc.local

*cp /etc/rc.d/rc.local.bk /etc/rc.d/rc.local

EOC

  1. Make script executable*

*chmod +x /etc/rc.d/rc.local

*

Tags (2)
0 Kudos
3 Replies
Texiwill
Leadership
Leadership

Hello,

Within your script use 'full path names' to all commands. Or add a PATH setting as when /etc/rc.d/rc.local runs there is no PATH set.


Best regards,

Edward L. Haletky

VMware Communities User Moderator

====

Author of the book 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', Copyright 2008 Pearson Education.

Blue Gears and SearchVMware Pro Blogs: http://www.astroarch.com/wiki/index.php/Blog_Roll

Top Virtualization Security Links: http://www.astroarch.com/wiki/index.php/Top_Virtualization_Security_Links

--
Edward L. Haletky
vExpert XIV: 2009-2023,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill
0 Kudos
ttarps
Contributor
Contributor

Thanks , i've not had chance to try your suggestion yet will try and do so by the end of the week.

0 Kudos
ttarps
Contributor
Contributor

I've still not been ablt to this to work and have given up, i'm just going to run the script manually and wait for VI4.0 to be released.

0 Kudos