How to make rhevh to run a postscript after installatoin

Latest response

I am using the pxe to install the rhev-h, it succeeded. But I need an approach to run the postscript after the installation of rhev-h (run on the rhev-h) to configure the rhev-h.

 

Is there a good approach to do this?

Responses

What exactly do you need to configure? All the options you can provide in the initial setup are also available as PXEboot options

Dan, thanks for your reply.

 

At least the rhev-h needs to take with the dhcp/pxe server that installation finished, then the pxe configuration should be removed or changed that the rhev-h should boot to the disk instead of boot to pxe. Otherwise the installation of rhev-h will get into a loop. installing -> reboot -> installing -> reboot ...

We deploy lots of RHEV-H hosts daily and never had such a loop. Once the normal installation PXE boot runs through, the host has RHEV-H installed on the local disks, and so will not try to boot from PXE (if the options in BIOS are set right).

What do you use as the PXE server?

We use dhcp and then pxe to start the installation. So the first boot seq for the host is 'net' and second seq is 'hd'. Every time, the host boot from net, get dhcp, start the pxe, get the pxe configuration file, installing. But after the installing, reboot, then host will boot from net, then dhcp ...

What I usually do was to change the pxe configuration file of the hosts to make host to boot from hd. The operation that change pxe configuration was triggered by the postscript of host which running after the installation.

There are a couple different ways you can accomplish this.  

 

1.  Setup the boot options correctly in BIOS so that the local disk is earlier than PXE.  Then boot the machine and tell it to boot from PXE/Network on just this one boot.  That will run the installation and next time the machine boots, it will try the local disk first.

 

2.  There is also the local_boot_trigger pxe option.  The value can be set to any url and during the final steps of installation, RHEV-H will wget the URL you specify.  If your pxe server provides a way to disable pxe for a server with just a wget of a specifc URL, this can be used to disable it.  

 

For example, I use cobbler in my environment, and I can add this to the kernel command line:

 

local_boot_trigger=http://<cobbler_server>/cblr/svc/op/nopxe/system/@HOSTNAME@

 

@HOSTNAME@ is automatically replaced with the hostname of the machine (set either with dns lookup or the hostname option)

 

Hope this helps

 

Mike

Michael, thanks.

 

In my env, there's hundreds of hosts will be controlled remotely, so the method 1 that manually change the setting is impossible.

For the method 2, do you mean the 'local_boot_trigger' will be passed to rhev-h. And if this file existed, the boot will get to local disk? I did not understand it very well. And the same concern that when and how to change the state of this url (to local disk or NOT), since the before the installation, get to net boot; And after the installation, get to local disk.

Base on my experience, for the installation of a rhels, I'll run a post script to change the pxe status. So is that possible to add a post script to the rhev-h installation? 

What do you do in the RHEL post to disable pxe for a particular host?  If it is a simple wget, then it will work.  

 

What exists today in RHEVH is a script that will wget a url.  If you can disable pxe for a host using wget, then it will work with RHEV-H.  

 

The script does:  

 

wget <url> -O /dev/null

 

The url is found from local_boot_trigger=<url> on the kernel commandline.  

 

trigger_url=
for i in $(cat /proc/cmdline); do
    case $i in
        local_boot_trigger=*)
            trigger_url=${i#local_boot_trigger=}
            ;;
    esac
done
 
if [ -n "$trigger_url" ]; then
    trigger_url=$(echo $trigger_url | sed -e "s/@HOSTNAME@/$(hostname)/")
    wget "$trigger_url" -O /dev/null
fitrigger_url=
for i in $(cat /proc/cmdline); do
    case $i in
        local_boot_trigger=*)
            trigger_url=${i#local_boot_trigger=}
            ;;
    esac
done
 
if [ -n "$trigger_url" ]; then
    trigger_url=$(echo $trigger_url | sed -e "s/@HOSTNAME@/$(hostname)/")
    wget "$trigger_url" -O /dev/null
fitrigger_url=
for i in $(cat /proc/cmdline); do
    case $i in
        local_boot_trigger=*)
            trigger_url=${i#local_boot_trigger=}
            ;;
    esac
done
 
if [ -n "$trigger_url" ]; then
    trigger_url=$(echo $trigger_url | sed -e "s/@HOSTNAME@/$(hostname)/")
    wget "$trigger_url" -O /dev/nu

 

trigger_url=
for i in $(cat /proc/cmdline); do
    case $i in
        local_boot_trigger=*)
            trigger_url=${i#local_boot_trigger=}
            ;;
    esac
done
 
if [ -n "$trigger_url" ]; then
    trigger_url=$(echo $trigger_url | sed -e "s/@HOSTNAME@/$(hostname)/")
    wget "$trigger_url" -O /dev/null
fi

Ok, that is pretty ugly.  Sorry about that.  I tried to past the script and it didn't show up right...


trigger_url=
for i in $(cat /proc/cmdline); do
    case $i in
        local_boot_trigger=*)
            trigger_url=${i#local_boot_trigger=}
            ;;
    esac
done

if [ -n "$trigger_url" ]; then
    trigger_url=$(echo $trigger_url | sed -e "s/@HOSTNAME@/$(hostname)/")
    wget "$trigger_url" -O /dev/null
fi

Thanks Michael,

Do you mean I need to have a mechanism on the pxe server that when some one wget the url which set by the trigger_url, the pxe configure for this node should be disabled? That means there should be a callback action which should be triggered when a file is fetched, right?

And in your last post, you said the wget was not triggered from rhev-h?

Yes, with RHEV-H, you need to have a mechanism to disable pxe via wget.  There is no callback or anything else.  The code shown in my post does wget >/dev/null.  

 

The wget is triggered by rhev-h, but only if you specify local_boot_trigger.  It does nothing but a wget.  It doesn't do anything with what it gets.  The assumption is that just touching that url path will disable the pxe boot for that server.  

Get your point. Could you let me know which script handle the local_boot_trigger kernel parameter? I known most of the parameter will be handled in the /etc/init.d/ovirt-early, but did not find the logic to handle the local_boot_trigger.

The script is located on RHEV-H at /etc/ovirt-config-boot.d/local_boot_trigger.sh or in my post a few entries up.

 

Mike

Thanks, I'll try it.