Howdy cfengineers,
I filed a bug last month at the sourceforge and
haven't seen any notice of attention. On
#cfengine I was told I'd have better luck here.
The report is at:
http://sourceforge.net/tracker/index.php?func=detail&aid=1848895&group_id=126712&atid=706640
but I'll repeat it here just in case.
======================================================
I'm having a problem with cfengine 2.2.3 involving
conditionals/group testing in the editfiles section.
I've attached a test case. It still has some
crud from the original task I was using it for
so it has to be run with sudo (in order to stop
cups).
Basically, what I was trying to do is:
1) stop cupsd
2) add a printer definition to /etc/cups/printers.conf
3) restart cupsd
However, it didn't work at first. The is something
wrong with the conditional testing in the editfiles.
I had to rewrite the rule using DeMorgan's law in order
for cfengine to do the right thing, but I shouldn't have too.
When I run it, I get something like this:
=============
$ sudo ./cfbug.cf
Password:
cfengine:myhost:nit.d/cups stop: Stopping cups: [ OK ]
cfengine:myhost:nit.d/cups star: Starting cups: [ OK ]
cfengine:myhost: linux, and centos, and cups stopped, and not a print
server, and don't have G85 (should foo)
cfengine:myhost: linux, and centos, and cups stopped, and not a print
server or have G85 (should bar)
cfengine:perrymason: did bar
$ cat /tmp/foo
$ cat /tmp/bar
bar
=============
Note that conditional for the alert and the edit files is the same. That
is, if it shows the "should foo" alert then it should similarly make the
edit to /tmp/foo. However, it doesn't.
I have a feeling it has something to do with a limit on
the number of conditionals that the editfiles section
is looking at (i.e. only seems ot have the problem
when there are 5 or more conditions), but I'm
not sure.
======================================================
The revised/cleaned-up test case is attached.
Any help appreciated.
jack/slick
#!/usr/sbin/cfagent -f
## above line uses 2.2.0 from RPM (RPM Forge's)
##/tmp/cfengine-2.2.3/src/cfagent -f
## above uses 2.2.3 in /tmp
# example to show apparent bug in editfiles conditionals testing
# fix the path on the first line and chmod 755
control:
actionsequence = ( shellcommands editfiles shellcommands )
groups:
special = ( hostABC ) # define a group of special hosts
shellcommands:
!special:: "/bin/cat /dev/null > /tmp/foo" umask=033 # blank file
!special:: "/bin/cat /dev/null > /tmp/bar" umask=033 # blank file
!special:: "/usr/bin/test -S /tmp/foo" define=some_class # should fail to
define
!special.!some_class:: "/bin/echo did something" define=did_something #
should define
alerts:
any.any.did_something.!special.!some_class:: # this works
"any, and any, and did something, and not special, and not some class
(should foo)"
any.any.did_something.!(special|some_class):: # and this
"any, and any, and did something, and not special or some class (should
bar)"
editfiles:
any.any.did_something.!special.!some_class::
# THIS DOESN'T WORK??? same condition as above
{ /tmp/foo
AppendIfNoSuchLine "foo"
DefineClasses "did_foo"
}
# DeMorgan's Law to the rescue
any.any.did_something.!(special|some_class)::
{ /tmp/bar
AppendIfNoSuchLine "bar"
DefineClasses "did_bar"
}
alerts:
did_foo:: "did foo"
did_bar:: "did bar"
shellcommands:
did_something.(did_foo|did_bar):: "/bin/echo undid something"
# EOF
_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine