bug-cfengine
[Top][All Lists]
Advanced

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

Re: DefineInGroup'd classes not really being defined?


From: Chip Seraphine
Subject: Re: DefineInGroup'd classes not really being defined?
Date: Tue, 13 May 2003 09:20:39 -0500
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.2.1) Gecko/20030121

Excellent, thanks. I had been confused about wether or not AddInstallable was relevant since foo1 was being defined but not foo2.

So then does it make sense that foo2 was appearing in the CFALLCLASSES even though it was not Installable? Is that just a side effect of it not being explicitly AddInstallable()'d, or is it the way things are supposed to be? This kinda concerns me, because it means that my shellouts might be seeing a different state than my cfengine script.



Andrew Stribblehill wrote:

Quoting Chip Seraphine <address@hidden> (2003-05-12 18:43:26 BST):
2.06, solaris/intel:

Mark pointed me at the DefineInGroup command, but I can't get it to work. -d2 shows that the code for it in edittools.c does in fact fire and it tries to add the appropriate classname (string) to the heap (via AddClassToHeap(currentitem)), but subsequent actions that require that class do not see the class. Running cfagent in a debugger confirms what the d2 output.

Basically, the edittools stuff seems to be Doing The Right Thing but the class is not defined for purposes of subsequent actions. The *really* wierd thing is that the CFALLCLASSES environment variable appears to have the DefineInGroup'd class set properly in it.

Specifically, this cfagent.conf file:

  control:

      Inform                = ( on )
      actionsequence        = ( editfiles shellcommands )

  editfiles:
      { /tmp/foo
          BeginGroupIfNoSuchLine "nomatching"
              Append "appended line $(date)"
              DefineInGroup "foo2"
          EndGroup
          DefineClasses "foo1"
      }

  shellcommands:
      "/usr/bin/logger -p local1.info running a test"
      foo1::
"/usr/bin/logger -p local1.notice foo1 $(date)" foo2::
          "/usr/bin/logger -p local1.notice foo2 $(date)"

Curiouser and curiouser (to quote Alice). When I replace the
shellcommands chunk with

alerts:
 foo1:: "foo1 defined"
 foo2:: "foo2 defined"

it works fine.

Ah, the foo2 class isn't counted as installable when the shell
command gets parsed. Verified that AddInstallable = ( foo2 ) makes it
work.

The following patch Works For Me(tm):

diff -ruN cfengine-2.0.6-old/src/install.c cfengine-2.0.6/src/install.c
--- cfengine-2.0.6-old/src/install.c    2003-04-07 18:38:31.000000000 +0100
+++ cfengine-2.0.6/src/install.c        2003-05-13 12:26:02.000000000 +0100
@@ -2735,6 +2735,7 @@
                   {
                   yyerror("DefineInGroup outside a group");
                   }
+                AddInstallable(new->data);
                break;
         case SetLine:
                if (FOREACHLEVEL > 0)
@@ -2760,7 +2761,7 @@
         case DefineClasses:
             if (EDITGROUPLEVEL > 0 || FOREACHLEVEL > 0)
                {
-               yyerror("Class definitions inside conditionals or loops are not 
allowed");
+               yyerror("Class definitions inside conditionals or loops are not 
allowed. Did you mean DefineInGroup?");
                }
             AddInstallable(new->data);
             break;

------------------------------------------------------------------------

_______________________________________________
Bug-cfengine mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/bug-cfengine






reply via email to

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