help-cfengine
[Top][All Lists]
Advanced

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

Re: Is this quirky for a simple copy, editfiles operation?


From: Brendan Strejcek
Subject: Re: Is this quirky for a simple copy, editfiles operation?
Date: Tue, 10 May 2005 13:21:47 -0500
User-agent: Mutt/1.5.6+20040907i

Joel Majka wrote:

> I also couldn't find a way to concatenate variables. For example, I'd
> like to InsertLine in my editfiles stanza for the localhost definition
> in my /etc/hosts. To do this, I wanted to use the built-in $(host)
> variable plus some text like:
> 
> InsertLine "127.0.0.1 $(host)"
> 
> or even split it into two lines like:
> 
> myvar = "127.0.0.1 " + $(host)
> InsertLine "$(myvar)"

My guess is that the problem is InsertLine. Are you using it within a
BeginGroup/EndGroup contruct? The manual says: "This should probably be
used in conjunction with the conditional begin-end tests to avoid lines
being inserted on every run," but I think it means "must" rather than
"should."

I would do:

    { /etc/hosts
        DeleteLinesContaining "${host}"
        AppendIfNoSuchLine "127.0.0.1 ${host}"
    }

That should work. In won't update the file unless the edited buffer
differs from the on-disk copy, so despite the fact that I am using
a delete command, most of the time if won't get edited.

If you give us the exact editfiles stanza you are using, we can make
other suggestions.




reply via email to

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