Forum: CFEngine Help
Subject: Re: CFEngine Help: How-to restart machine after certain package have 
been installed.
Author: juriskrumins
Link to topic: https://cfengine.com/forum/read.php?3,26673,26691#msg-26691

Sorry for not being specific enough.
So lets start from the beginning.
What I need is:
1. Install custom kernel on newly deployed machine.
2. Since kernel activation requires reboot, I need to restart the machine.

So, what I got is:

1. Define custom kernel package I'd like to install.
By the way this variable gets defined only if 2 global classes
are not true.  Works fine.


vars:

!vz_hardware_node.!vz_container::
                "kernel_package" slist => {
                        "vzkernel",
                },
                comment => "Define kernel to install arch specifi",
                handle => "packages_vars_kernel_package";


2. I need to install custom kernel, defined in step 1. using packages promise 
and define
class called restart_machine in case packages promise gets repaired 
successfully.
This is probably the place where I have an issue.


packages:
        !vz_hardware_node.!vz_container::
                "$(packages.kernel_package)"
                package_policy => "add",
                package_architectures => { "x86_64" },
                package_method => yum,
                classes => if_repaired("restart_machine");


3. And then commands promise will execute command depending on previously 
defined restart_machine
class


commands:
        restart_machine::
                "/sbin/shutdown -r now";


So what happened after cf-agent have been executed
1. Package gets installed (if we lack vzkernel package, otherwise nothing 
happens)
2. No restart_machine class have been defined.
3. And no shutdown -r now command have been executed.

If package gets removed, then after a while cf-agent install it once again and 
that all.
The only way I was able to make it work is the way I posted in "July 26, 2012 
04:43PM".

I've also tested yum command, by manually installing vzkernel package and in 
case everything 
is fine we get exit code equal 0, otherwise it's > 0. So I believe return code 
is not the problem.

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to