[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Cfengine-develop] Re: Homework
From: |
Andrews, Martin |
Subject: |
RE: [Cfengine-develop] Re: Homework |
Date: |
Wed, 5 Mar 2003 17:42:07 -0500 |
Cool. My first impression is that something like "with" and "over" namespace
manipulation would be perfect to resolve some of my yearnings. I have been
wanting to reuse an imported config file with different class and macro
settings within the same run. For example if I have a cfengine file that
would manage an /etc/init.d service (copies the script, manages the rc
links, makes sure the service is running). I would like to reimport that
file once for each service. I imagine something like this"
import:
with {
service="cfexecd"
src_script=$(golddir)/cfexecd.init
run_in_rc2=any
reload=updated_config_files
startnum=70
killnum=30
}
sysvinit.cf
Note that I mix macro definitions and group/class definitions. Maybe the
difference between the two should be better indicated, but I would like
classes to be namespaced as well.
Not sure where you are going with multiple interpolation - how would you use
that. The current method to avoid single interpolation by escaping the
refence as "echo $(DOLLAR)(myvar)" has worked for me so far.
Martin
> -----Original Message-----
> From: Andrew Stribblehill [mailto:address@hidden
> Sent: Wednesday, March 05, 2003 5:24 AM
> To: address@hidden
> Subject: Re: [Cfengine-develop] Re: Homework
>
...
> Zope has a <dtml-over> tag for iteration over a list, and <dtml-with>
> to put an associative array into the current namespace. It is used
> thus:
>
> <dtml-over "mySimpleList">
> <a href="&dtml-item;">This item</a>
> </dtml-over>
>
> <dtml-over "myListOfDicts">
> <dtml-with "item">
> <a href="&dtml-webpage;">&dtml-description;</a>
> </dtml-with>
> </dtml-over>
>
>
> By analogy, Cfengine could have something like this:
>
> control:
> rootCrontabs = [ { minute="05" command="gratuitousMonitor" },
> { minute="10" command="pkill gratuitousMonitor" } ]
>
> editfiles:
> linux::
> over rootCrontabs
> with item
> { /etc/cron.d/local
> AppendIfNoSuchLine "$(minute) * * * * root $(command)"
> }
>
> Thinking about implementation details just for a moment, the 'over'
> and 'with' keywords would overlay a namespace onto the base one so
> you'd have:
>
> namespace of 'item'
> namespace of rootCrontabs which contains 'item' and maybe 'itemNumber'
> base namespace (contains, for ecample, sysadm)
>
> in order of visibility. This is also pleasant because if, for
> example, you didn't want to define some properties for some
> associative arrays, you could just use the default one lower down the
> namespace stack:
>
>
> control:
> minute = "10"
> hour = "*"
> day = "*"
> month = "*"
> dow = "*"
> user = "root"
> rootCrontabs = [ { command="hello" },
> { minute="13" command="goodbye"}
>
> editfiles:
> linux::
> over rootCrontabs with item
> { /etc/cron.d/local
> AppendIfNoSuchLine "$(minute) $(hour) $(day) $(month) ". \
> "$(dow) $(user) $(command)"
> }
>
> Something else we need to look at is string interpolation. How to
> stop it happening, how to cause it to be interpolated multiple times?
>
> Perl has '' to mean don't interpolate; Python allows either '' or ""
> and doesn't interpolate unless you give it an associative array to
> work on, i.e.
> "Charlie had %(num) pigeon%(plural)" % {num="1", plural=""}
>
- RE: [Cfengine-develop] Re: Homework,
Andrews, Martin <=
- RE: [Cfengine-develop] Re: Homework, Andrews, Martin, 2003/03/06
- RE: [Cfengine-develop] Re: Homework, Andrews, Martin, 2003/03/06
- Re: [Cfengine-develop] Re: Homework, Mark Burgess, 2003/03/06
- Re: [Cfengine-develop] Re: Homework, Luke A. Kanies, 2003/03/06