Forum: Cfengine Help
Subject: Verifying Packages with Cf3
Author: Authority
Link to topic: https://cfengine.com/forum/read.php?3,17008,17008#msg-17008
Verifying packages does not seem to work correctly using the snippet at the end
of the post.
Cfengine reports the package is installed.
rpm states otherwise.
# cf-agent -Kf ./test.cf
R: Package autofs5 is installed.
# rpm -q autofs5
package autofs5 is not installed
# echo $?
1
According to the package_method I've created, Cfengine is supposed to use "rpm
-q" to "verify" the package. I don't care to verify the package in the same
way rpm means to verify, that is, checking MD5 sums on files, various
permissions that were in place on install, and what have you, I just want to
check that the package is installed. A returncode of 1 indicates a failure to
verify, that is, not installed.
Is this a logical failure of my own or of Cfengine?
##########################
body common control
{
bundlesequence => { "test" };
}
bundle agent test
{
reports:
autofs5_installed::
"Package autofs5 is installed.";
packages:
"autofs5"
package_method => yum ,
package_policy => "verify" ,
classes => if_ok("autofs5_installed");
}
body package_method yum
{
package_changes => "bulk";
package_list_command => "/bin/rpm -qa --qf \"%{name} !!!
%{version}-%{release} !!! %{arch}\n\"";
package_list_name_regex => "([[:alnum:]\_\-\.]+?) !!! [[:alnum:]\_\-\.]+
!!! [[:alnum:]\_\-]+";
package_list_version_regex => "[[:alnum:]\_\-\.]+? !!! ([[:alnum:]\_\-\.]+)
!!! [[:alnum:]\_\-]+";
package_list_arch_regex => "[[:alnum:]\_\-\.]+? !!! [[:alnum:]\_\-\.]+
!!! ([[:alnum:]\_\-]+)";
package_installed_regex => ".*";
package_name_convention => "$(name)";
package_add_command => "/usr/bin/yum -y install";
package_delete_command => "/usr/bin/yum -y remove";
package_verify_command => "/bin/rpm --quiet -q";
package_noverify_returncode => "1";
}
body classes if_ok(x)
{
promise_repaired => { "$(x)" };
promise_kept => { "$(x)" };
}
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine