help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Réf.: Import not working as expected?


From: Wipf, Stefan
Subject: Re: Réf.: Import not working as expected?
Date: Mon, 14 Apr 2003 10:23:29 -0500

You will also find that cfengine does not nest import statements as
you might have expected:

example:

cfagent.conf:
 import: 
  cf.classes
  cf.variables
  cf.main

cf.classes:
 import:
  cf.classes1
  cf.classes2
  ...

The current implementation of the import directive has the effect of
importing the files in this sequence:

importing cf.classes
importing cf.variables
importing cf.main
importing cf.classes1
importing cf.classes2

Notice that all definitions in cf.classes1 and cf.classes2 are unusable
as they do not get defined until the very end

If you desire the more intuitive and useful behavior, you need a code
fix which I have posted previously

importing cf.classes
importing cf.classes1
importing cf.classes2
importing cf.variables
importing cf.main


paguerlais@airfrance.fr wrote:
> 
> All the mystery comes from the way cfengine parses your files. What you
> want to do is :
> - load your cfagent.conf file. Then some classes are defined.
> - parsing your cfagent.conf file, load your cf.brsb.groups, and define some
> more classes (especially catw)
> - go on parsing cfagent.conf, and load cf.catw if catw is defined.
> 
> Unfortunately, cfengine doesn't work as you intend it to do (or as you are
> used to with other languages). What it does is :
> - loads your cfagent.conf file and parses it _completely_. It means that
> the parsing keeps track of the relevant actions only. As your catw classe
> isn't defined at this point, your cf.catw import is discarded.
> - proceeds with your cf.brsb.groups import. Then catw is defined, but it's
> too late for cfagent.conf to keep track of your cf.catw import :-(
> 
> You just forgot that cfengine proceeds with imports _after_ all other
> parsing operations.
> The solution for your problem is either to define catw earlier in your
> parsing (before the end of cfagent.conf parsing) or to force cfengine to
> keep in mind that catw could be defined later. The first solution implies
> that you add the definition of catw to your cfagent.conf file (but that's
> not what you want to do), or use the AddInstallable directive as an
> alternative. When you use AddInstallable, cfengine doesn't discard the
> lines conditionned by an "installable" class as they are parsed, but acts
> more dynamically as in a common programming language.
> 
> Shorter, add to your cfagent.conf file a line like "AddInstallable = ( catw
> )" to "declare" all the classes which could be defined later during an
> import or at execution time.
> 
> Patrice
> 
> help-cfengine-bounces+paguerlais=airfrance.fr@gnu.org@soda.csua.berkeley.edu
> 
> (Marco Nicosia) le 13/04/2003 01:36:59
> 
> Envoyé par :      marco@soda.csua.berkeley.edu (Marco Nicosia)
> 
> Pour : help-cfengine@gnu.org
> cc :
> 
> Objet :     Import not working as expected?
> 
> Hi all,
> 
> We're attempting a first-time cfengine install in a complex environment.
> I've been using the example configs from the reference guide. In that
> guide, I see:
> 
> ] import:
> ]     any::
> ]           cf.groups
> ]           cf.main
> ]           ...
> ]     hpux::      cf.hpux
> ]     linux::     cf.linux
> ]     ...
> 
> We like this style, and want to use it for ourselves, except that we
> want to load action definitions based on group membership, rather than
> membership defined by OS. So we wrote this cfagent.conf:
> 
> ] import:
> ]     all::
> ]           cf.brsb.groups
> ]
> ]     catw::      cf.catw
> ]     ...
> 
> The cf.catw file defines actions for copy and shellcommands, but we've
> run into an interesting problem. Even though it imports cf.brsb.groups,
> the remote system does not import cf.catw, despite knowing it is in the
> correct class:
> 
> ] Import file cf.brsb.groups
> ] ...
> ] Defined Classes = ( any cfengine_2_0_6 Saturday Hr12 Min19 Min15_20
> ] Q2 Hr12_Q2 Day12 April Yr2003 solarisx86 catw001 32_bit sunos_5_8
> ] i86pc sunos_i86pc sunos_i86pc_5_8 i386 sunos_i86pc_5_8_Generic_108529_14
> ] compiled_on_solaris2_8 catw001_f catw001_walmart_com net_iface_lo0
> ] net_iface_iprb0 172_28_101_130 catw001_f_walmart_com 172_28_101
> ] ipv4_172_28_101_130 ipv4_172_28_101 ipv4_172_28 ipv4_172 net_iface_iprb1
> ] 172_28_101_164 catw001_b_walmart_com catw001_b ipv4_172_28_101_164
> ] catw )
>   ^^^^
> 
> What boggles us is that if we do not import the cf.brsb.groups, rather,
> include the groups directly in cfagent.conf, it works!
> 
> ] groups:
> ]    catw = ( catw001 catw002 catw003 catw004 catw005 catw006 catw007 )
> ]
> ] import:
> ]    catw:: cf.catw
> 
> I'm thinking that import order cannot be deferred. I've read that
> the actionsequence order of evaluation can be manipulated, (ie,
> links.firstpass.include, links.secondpass) but I don't know how
> I'd do the same for include files?
> 
> Help? Do I have to edit all groups in cfagent.conf, or is there
> a way I can separate them out to a cf.groups file?
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-cfengine
> 
> 
> ----------------
> L'acces immediat aux meilleurs tarifs Air France et au billet electronique 
> sur http://www.airfrance.com
> 
> For immediate access to the best Air France fares and to electronic tickets, 
> visit our website http://www.airfrance.com
> 
> ----------------
> Les donnees et renseignements contenus dans ce message sont personnels, 
> confidentiels et secrets. Ce message est adresse a l'individu ou l'entite 
> dont les coordonnees figurent ci-dessus. Si vous n'etes pas le bon 
> destinataire, nous vous demandons de ne pas lire, copier, utiliser ou 
> divulguer cette communication. Nous vous prions de notifier cette erreur a 
> l'expediteur et d'effacer immediatement cette communication de votre systeme.
> The information contained in this message is privileged, confidential, and 
> protected from disclosure. This message is intended for the individual or 
> entity adressed herein. If you are not the intended recipient, please do not 
> read, copy, use or disclose this communication to others; also please notify 
> the sender by replying to this message, and then delete it from your system.
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-cfengine

-- 
Stefan Wipf
swipf@htc.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]