I'm still struggling to get the expected behaviour from the below bundle.

What's odd is if I match for the "nodevs" line in mlocate.cron, specifying
"after" for the "before_after" field, I get the exit 0 statement inserted
in the correct location. If I change "before_after" to "before", I get the
exit 0 statement appended to the end of the file, several lines below the
supposed match line. This is the reverse of the behaviour I documented
below!

Neither 3.0.3 or 3.0.4p2 on CentOS 5.4 x64 work as expected.

Mark - which version of CFEngine and what operating environment did you
manage to get this working correctly in?

Cheers

Steve

>
> Works ok for me
>
> Steve Barnes wrote:
>> I'm trying to disable a few cron tasks by inserting an `exit 0`
>> statement
>> just after the shebang:
>>
>> ###################################################
>>
>> bundle agent cron {
>>
>>      files:
>>
>>              "/etc/cron.daily/mlocate.cron"
>>
>>                      edit_line => disable_task;
>>
>>              "/etc/cron.daily/makewhatis.cron"
>>
>>                      edit_line => disable_task;
>>
>>              "/etc/cron.weekly/makewhatis.cron"
>>
>>                      edit_line => disable_task;
>>
>>      }
>>
>> bundle edit_line disable_task {
>>
>>      insert_lines:
>>
>>        "exit 0"
>>
>>              location => after_shebang;
>>
>>      }
>>
>> body location after_shebang  {
>>
>>      select_line_matching => "^#!.*sh$";
>>      before_after => "after";
>>
>>      }
>>
>> ###################################################
>>
>> What I end up with in all of the files is this:
>>
>> [r...@box]# cat /etc/cron.daily/mlocate.cron
>> #!/bin/sh
>> nodevs=$(< /proc/filesystems awk '$1 == "nodev" { print $2 }')
>> renice +19 -p $$ >/dev/null 2>&1
>> /usr/bin/updatedb -f "$nodevs"
>> exit 0
>> exit 0
>> exit 0
>>
>> If I modify the promise to use `before_after => "before";` it does what
>> I
>> would expect:
>>
>> [r...@box]# cat /etc/cron.daily/mlocate.cron
>> exit 0
>> #!/bin/sh
>> nodevs=$(< /proc/filesystems awk '$1 == "nodev" { print $2 }')
>> renice +19 -p $$ >/dev/null 2>&1
>> /usr/bin/updatedb -f "$nodevs"
>> exit 0
>>
>> But that's not what I'm after. Is this a bug?
>>
>> Cheers
>>
>> Steve
>>
>> _______________________________________________
>> Help-cfengine mailing list
>> Help-cfengine@cfengine.org
>> https://cfengine.org/mailman/listinfo/help-cfengine
>
> --
> Mark Burgess
>
> -------------------------------------------------
> Professor of Network and System Administration
> Oslo University College, Norway
>
> Personal Web: http://www.iu.hio.no/~mark
> Office Telf : +47 22453272
> -------------------------------------------------
>


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

Reply via email to