Why don't you use packages: stanza instead? Cfengine will check a status of all
those packages behind the scene. A body package_method yum could be found in
cfengine_stdlib.cf
body common control
{
bundlesequence => { "checkrpms" };
}
#############################################
bundle agent checkrpms
{
vars:
"rpms_needed" slist => { "rpm-build", "createrepo" },
comment => "List of required RPMs";
packages:
"$(rpms_needed)"
package_policy => "add",
package_method => yum;
}
#############################################
body package_method yum
{
any::
package_changes => "bulk";
# Could use rpm for this
package_list_command => "/usr/bin/yum list installed";
# Remember to escape special characters like |
package_list_name_regex => "([^.]+).*";
package_list_version_regex => "[^\s]\s+([^\s]+).*";
package_list_arch_regex => "[^.]+\.([^\s]+).*";
package_installed_regex => ".*installed.*";
package_name_convention => "$(name).$(arch)";
package_add_command => "/usr/bin/yum -q -y install";
package_delete_command => "/bin/rpm -e --nodeps";
package_verify_command => "/bin/rpm -V";
}
Cheers,
--Nakarin
On Feb 4, 2010, at 11:47 AM, Andrew J. Millar wrote:
> Greetings all
>
> I'm struggling with a cfengine recipe - my goal is to check an slist of RPMs
> to
> see if they are installed, and install any missings ones. Alas, if at least
> one
> of the RPMs is installed, the class check fails, and the missings RPMS are not
> installed. If all of the RPMS are missing, then the class check passes and the
> RPMS are installed.
>
> In this example, I'm checking for the presence of rpm-build and createrepo
>
> Here is my setup:
> cf-agent --version
> This comprises cf-agent core community version 3.0.3 - (C) Cfengine AS 2008-
> (svn build)
>
> body common control
>
> {
> bundlesequence => { "checkrpms" };
> }
>
>
> bundle agent checkrpms
> {
> vars:
> "rpms_needed" slist => { "rpm-build", "createrepo" },
> comment => "List of required RPMs";
>
> classes:
> "rpms_installed" expression => returnszero("/bin/rpm -q
> $(rpms_needed)","noshell"),
> comment => "Check if required rpms are installed";
>
> commands:
> !rpms_installed::
> "/usr/bin/yum -q -y install $(rpms_needed)",
> comment => "Installing $(rpms_needed)";
> }
>
> If I uninstall createrepo and run the recipe, this is the output:
> # cf-agent -I -f ./check_rpms.cf
> rpm-build-4.4.2.3-18.el5
> package createrepo is not installed
> rpm-build-4.4.2.3-18.el5
> package createrepo is not installed
> rpm-build-4.4.2.3-18.el5
> package createrepo is not installed
> #
>
> If I uninstall both createrepo and rpm-build, the output is:
> # cf-agent -I -f ./check_rpms.cf
> package rpm-build is not installed
> package createrepo is not installed
> -> Executing '/usr/bin/yum -q -y install rpm-build'
> ...(timeout=-678,owner=-1,group=-1)
> -> Completed execution of /usr/bin/yum -q -y install rpm-build
> -> Executing '/usr/bin/yum -q -y install createrepo'
> ...(timeout=-678,owner=-1,group=-1)
> -> Completed execution of /usr/bin/yum -q -y install createrepo
> rpm-build-4.4.2.3-18.el5
> createrepo-0.4.11-3.el5
> rpm-build-4.4.2.3-18.el5
> createrepo-0.4.11-3.el5
> #
>
> Can anyone help me tweak the recipe to install the missing RPM if either are
> not installed?
>
> Many thanks
>
> Kind regards
> Andrew
>
>
>
> Shop spring’s building blocks at NET-A-PORTER.COM
> ______________________________________________________________________
>
> CONFIDENTIALITY NOTICE
> The information in this email is confidential and is intended solely for the
> addressee. Access to this email by anyone else is unauthorised. If you are
> not the intended recipient, you must not read, use or disseminate the
> information. Any views expressed in this message are those of the individual
> sender, except where the sender specifically states them to be the views of
> Net a Porter Ltd.
>
> Net A Porter Ltd is a company registered in England & Wales Number: 3820604
> Registered Office: The Dome, Whiteleys Centre, 151 Queensway, London, W2 4YN.
> _____________________________________________________________________
> _______________________________________________
> Help-cfengine mailing list
> [email protected]
> https://cfengine.org/mailman/listinfo/help-cfengine
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine