[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: convergent principle and editfile issue
From: |
Brendan Strejcek |
Subject: |
Re: convergent principle and editfile issue |
Date: |
Wed, 21 Jul 2004 17:06:54 -0500 |
User-agent: |
Mutt/1.3.28i |
How about this? Maybe overkill. This particular code is untested, but
I've used the same idea before.
control:
hosts_equiv_netgroup = ( examplenetgroup )
editfiles:
{ /etc/hosts.equiv
# Make sure we have some lines to edit
BeginGroupIfNoLineMatching "^\+@${hosts_equiv_netgroup}$"
Append "+@${hosts_equiv_netgroup}"
EndGroup
BeginGroupIfNoLineMatching "^${host}$"
Append "${host}"
EndGroup
# And make sure the lines are correct
ResetSearch "1"
BeginGroupIfNoMatch "^\+@${hosts_equiv_netgroup}$"
ReplaceLineWith "+@${hosts_equiv_netgroup}"
EndGroup
IncrementPointer "1"
BeginGroupIfNoMatch "^${host}$"
ReplaceLineWith "${host}"
EndGroup
DeleteLinesAfterThisMatching "^.*$"
}
Zeev Fisher wrote:
> Hi,
>
> I would like to discuss again the concept of convergent and editfiles.
>
> From earlier discussion:
>
> "The real reason for me using editfiles over copy for managing
> configuration is that sometimes the values being set differ per machine,
> which makes a single file less useful. I certainly use copy for every
> file that I want identical across all machines, but these files are
> rarely configuration files.
> I also like to make the minimum amount of change to any configuration
> file, and I want any automatic edits to respect formatting changes that
> a human makes."
>
> I totally agree with this and i can't understand how such great software
> like cfengine which is based on the principle of convergent , doesn't have
> editfiles ability to check if certain file match certain structure ( which
> is dynamic according to
> the machine it runs on but the template is fixed)
>
> For example , i'm trying to find a way which will make sure that only the
> following 2 lines will appear in my hosts.equiv file :
>
> +@examplenetgroup
> examplehost
>
> The netgroup name is constant but the hostname is the hostname of the
> machine itself so i can't use copy.
>
> With all current editfiles feature , except of creating from scratch
> every time the file with emptyentirefileplease and inserts , i can't
> make sure that if someone added there host , it will be removed next
> time cfengine run.
>
> I will be happy to hear how to do this if it's possible.
>
>
> Thanks,
> Zeev