On Tue, Apr 26, 2011 at 09:38:25AM -0400, no-re...@cfengine.com wrote:
>Forum: Cfengine Help
>Subject: Re: Cfengine Help: rather complex scenario (pkg install+configure - 
>if necessary)
>Author: ticketo
>Link to topic: https://cfengine.com/forum/read.php?3,21559,21593#msg-21593
>
>If it's about chapter "2.1.2 Variation in hosts" then it's a bit simplistic. 
>It would mean that I have to manually change the cfengine configuration if I 
>add just one more host - and manually keep track of every change. I think i 
>saw someone announcing classes based on lspci's output (or similar). This 
>would help a lot.

I have a few bundles that I use for hardware-based stuff like this,
specifically including certain RAID controllers.  Below are snippets of
what I use on some systems.


bundle agent hardware {

vars:

     'generic_hw_packages' slist => {
         'smartmontools',
     };


commands:

     linux::
         "/sbin/lspci -v -v > ${g.lspcifile}"
             contain  => quiet_in_shell,
             action   => if_elapsed(600),
             classes  => if_ok('lspci_data_exists'),
             handle   => 'hardware_lspci_generate';

         "/usr/sbin/dmidecode > ${g.dmidecodefile}"
             contain  => quiet_in_shell,
             action   => if_elapsed(600),
             classes  => if_ok('dmifile_data_exists'),
             handle   => 'hardware_dmi_generate';

files:

     linux::
         "${g.lspcifile}"
             perms => paf;

         "${g.dmidecodefile}"
             perms => paf;

packages:

     linux::
         "${generic_hw_packages}"
             package_policy        => "add",
             package_method        => yum,
             package_architectures => { "x86_64"};
         
reports:

     hardware_VendorA.(verbose|inform)::
         "Host [${sys.uqhost}] is made by VendorB.";

     hardware_VendorA.(verbose|inform)::
         "Host [${sys.uqhost}] is made by VendorB.";

     hardware_VMware.(verbose|inform)::
         "Host [${sys.uqhost}] is a VMware VM.";

     hardware_KVM.(verbose|inform)::
         "Host [${sys.uqhost}] is a KVM VM.";

     hardware_OVZ.(verbose|inform)::
         "Host [${sys.uqhost}] is a OpenVZ VM.";

}


bundle common g {

vars:

     'lspcifile'       string => "/root/lspci.dat";
     'dmidecodefile'   string => "/root/dmidecode.dat";


classes:

     'lspci_data_exists'     expression => fileexists("${g.lspcifile}");
     'dmidecode_data_exists' expression => fileexists("${g.dmidecodefile}");


     lspci_data_exists::

         'hardware_VendorA'    expression => regline('^.*Product 
Name:.+VendorA.*', "${g.dmidecodefile}");
         'hardware_VendorB'    expression => regline('^.*Product 
Name:.+VendorB.*', "${g.dmidecodefile}");

         'hardware_IDE'        expression => regline('^.*IDE.*', 
"${g.lspcifile}");
         'hardware_SATA'       expression => regline('^.*SATA.*', 
"${g.lspcifile}");

         'hardware_VMware'     expression => regline('^.*VMware.*', 
"${g.lspcifile}");
         'hardware_KVM'        expression => regline('^.*Virtio memory 
balloon.*', "${g.lspcifile}");
         'hardware_OVZ'        expression => isplain('/prox/vz');
         
         'hardware_VM'                 or => { 'hardware_VMware',
                                               'hardware_KVM',
                                               'hardware_OVZ',
                                             }; 

}





-- 
Jesse Becker
NHGRI Linux support (Digicon Contractor)
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to