that would be nice wouldn't it? however, the following code does not work:

body common control
{
   bundlesequence => { "test" };
   inputs => { "cfengine_stdlib.cf",
               "dls_std_lib.cf" };
}

bundle agent test {
   vars:

   files:
     "/tmp/ifcfg-eth0-range0"
       create => "true",
       edit_line => insert_lines("# comment",
                                 "NETMASK=255.255.255.0",
                                 "BROADCAST=172.23.7.255",
                                 "IPADDR_START=172.23.4.1",
                                 "IPADDR_END=172.23.4.1",
                                 "CLONENUM_START=0"),
       comment => "some comment",
       classes => if_repaired("some_class");
}

it results in:

Formal =  {'lines'}, Actual =  {'# 
comment','NETMASK=255.255.255.0','BROADCAST=172.23.7.255','IPADDR_START=172.23.4.1','IPADDR_END=172.23.4.1','CLONENUM_START=0'}

which I interpret as "I was expecting a string but you passed a list"

The only other way to do it that I've found is to define the file as a 
slist of lines which can be iterated over:

       edit_line => insert_lines( $(eth00) ),

But in that case you cannot use "edit_defaults => empty" (you end up 
with only the last line in the file).

G

On 31/08/12 17:30, Diego Zamboni wrote:
> Greg,
>
> You could split the lines into a list, then you can still pass them to
> insert_lines but they will not be indented. Just separate them by
> commas in your code, should work fine.
>
> --Diego
>
> On Aug 31, 2012, at 7:56 AM, Gregory Matthews
> <greg.matth...@diamond.ac.uk>  wrote:
>
>> how do ppl reconcile indentation for readability in .cf files with the
>> needs to insert lines that are not indented? for example:
>>
>>      g_dnsserver.my_serv_name::
>>        "/etc/sysconfig/network-scripts/ifcfg-eth0-range0"
>>          create =>  "true",
>>          edit_defaults =>  empty,
>>          edit_line =>  insert_lines("# extra IP address for legacy clients
>>          NETMASK=255.255.255.0
>>          BROADCAST=172.23.7.255
>>          IPADDR_START=172.23.4.1
>>          IPADDR_END=172.23.4.1
>>          CLONENUM_START=0"),
>>          classes =>  if_repaired("needsnetworkrestart");
>>
>> results in all but the first line of the created file being
>> unnecessarily indented.
>>
>> G
>> --
>> Greg Matthews        01235 778658
>> Scientific Computing Group Leader
>> Diamond Light Source Ltd. OXON UK
>>
>> --
>> This e-mail and any attachments may contain confidential, copyright and or 
>> privileged material, and are for the use of the intended addressee only. If 
>> you are not the intended addressee or an authorised recipient of the 
>> addressee please notify us of receipt by returning the e-mail and do not 
>> use, copy, retain, distribute or disclose the information in or attached to 
>> the e-mail.
>> Any opinions expressed within this e-mail are those of the individual and 
>> not necessarily of Diamond Light Source Ltd.
>> Diamond Light Source Ltd. cannot guarantee that this e-mail or any 
>> attachments are free from viruses and we cannot accept liability for any 
>> damage which you may sustain as a result of software viruses which may be 
>> transmitted in or with the message.
>> Diamond Light Source Limited (company no. 4375679). Registered in England 
>> and Wales with its registered office at Diamond House, Harwell Science and 
>> Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
>>
>>
>>
>>
>> _______________________________________________
>> Help-cfengine mailing list
>> Help-cfengine@cfengine.org
>> https://cfengine.org/mailman/listinfo/help-cfengine
>


-- 
Greg Matthews        01235 778658
Scientific Computing Group Leader
Diamond Light Source Ltd. OXON UK

-- 
This e-mail and any attachments may contain confidential, copyright and or 
privileged material, and are for the use of the intended addressee only. If you 
are not the intended addressee or an authorised recipient of the addressee 
please notify us of receipt by returning the e-mail and do not use, copy, 
retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not 
necessarily of Diamond Light Source Ltd. 
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments 
are free from viruses and we cannot accept liability for any damage which you 
may sustain as a result of software viruses which may be transmitted in or with 
the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and 
Wales with its registered office at Diamond House, Harwell Science and 
Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
 



_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to