if_repaired

52 views
Skip to first unread message

Christian Linden

unread,
Jun 2, 2016, 6:57:36 AM6/2/16
to help-cfengine
Hi,

I use:
files:
 "MyFile" edit_line => append_if_no_line("MyLine"), classes => if_repaired("myClass");

I expect that myClass is just set if MyLine was appended.
But it's also set if MyLine was already in MyFile and therefor the promise wasn't repaired but kept.

What do I miss?

Thanks,
Chris

Christian Linden

unread,
Jun 2, 2016, 7:06:56 AM6/2/16
to help-cfengine
.. same with results, getting MyClass_repaired as well 

c

Nick Anderson

unread,
Jun 2, 2016, 9:24:21 AM6/2/16
to Christian Linden, help-cfengine
On 06/02/2016 06:06 AM, Christian Linden wrote:
> .. same with results, getting MyClass_repaired as well

It would help if you could post a self contained example and the version
you are running with.




signature.asc

Christian Linden

unread,
Jun 2, 2016, 11:52:49 AM6/2/16
to help-cfengine, lindo...@gmail.com
pls touch /tmp/append_and_repair.txt in advance.

bundle agent i_repair2often
{
        files:
                any::
                        "/tmp/append_and_repair.txt" edit_line => default:append_if_no_line("I_append_and_repair_on_each_run"), classes => results("namespace", "added_ready");

        commands:
                added_ready_repaired::
                        "/bin/true" classes => if_ok("true_done");

        reports:
                true_done::
                        "I run true always because I don't care about _repaired or _kept and the same line gets appended on each run.";
}

But damned this works as expected: this is what I miss in my product promise.. I go nuts..


verbose: P:    Comment:  Append a line to the file if it doesn't already exist
 verbose: P: .........................................................
 verbose:
 verbose: Additional promise info: version 'CFEngine Promises.cf 3.7.2' source path '/var/cfengine/inputs/lib/3.7/files.cf' at line 217 comment 'Append a line to the file if it doesn't already exist'
 verbose: Promised chunk 'I_append_and_repair_on_each_run' exists within selected region of /tmp/append_and_repair.txt (promise kept)

.. digging..

c

Christian Linden

unread,
Jun 2, 2016, 1:08:24 PM6/2/16
to help-cfengine, lindo...@gmail.com
You see above that I understand how it works.
But why the hack behaves this one differently:
(create /tmp/whatever-$(sys.fqhost) in advance pls)

body file control
{
        namespace => "HSLinux";
}

bundle agent append_hell
{
        files:
                any::
                        "/tmp/whatever-$(sys.fqhost)" edit_line => default:append_if_no_line("APPEND=HELL"), classes => default:results("namespace", "added_ready");

        commands:
                HSLinux:added_ready_repaired::
                        "/bin/true" classes => default:if_ok("ran_true");


        reports:
                HSLinux:ran_true::
                "I ran true to discover the append ever hell.";
}


This one repairs on each run here on 3.7.2.

I'm out for today, thanks Nick..
.
Chris

Nick Anderson

unread,
Jun 2, 2016, 2:22:28 PM6/2/16
to help-c...@googlegroups.com
It seems to be working when i ran with 3.8.1. Haven't tried 3.7.2
specifically.

https://gist.github.com/f8cad26e361eb9b2e78307ae380515dc

nickanderson@nickanderson-ThinkPad-W550s /tmp [13:20:03]
> $ cat /tmp/whatever-nickanderson-thinkpad-w550s

nickanderson@nickanderson-ThinkPad-W550s /tmp [13:20:05]
> $ cf-agent -Kf ./example.cf --define HSLinux:DEBUG
R: Considering: /tmp/whatever-nickanderson-thinkpad-w550s
R: I ran true to discover the append ever hell.

nickanderson@nickanderson-ThinkPad-W550s /tmp [13:20:10]
> $ cf-agent -Kf ./example.cf --define HSLinux:DEBUG
R: Considering: /tmp/whatever-nickanderson-thinkpad-w550s

nickanderson@nickanderson-ThinkPad-W550s /tmp [13:20:12]
> $ cat /tmp/whatever-nickanderson-thinkpad-w550s
APPEND=HELL

nickanderson@nickanderson-ThinkPad-W550s /tmp [13:20:16]
> $ cf-agent -Kf ./example.cf --define HSLinux:DEBUG
R: Considering: /tmp/whatever-nickanderson-thinkpad-w550s

nickanderson@nickanderson-ThinkPad-W550s /tmp [13:20:18]
> $ cat /tmp/whatever-nickanderson-thinkpad-w550s
APPEND=HELL


signature.asc

Christian Linden

unread,
Jun 3, 2016, 5:54:50 AM6/3/16
to Nick Anderson, help-c...@googlegroups.com
on 3.8.2 it works as well.. not on 3.7.2

Cheers & have a great weekend!
Chris
> --
> You received this message because you are subscribed to a topic in the Google Groups "help-cfengine" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/help-cfengine/B1N-jpGG-3Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to help-cfengin...@googlegroups.com.
> To post to this group, send email to help-c...@googlegroups.com.
> Visit this group at https://groups.google.com/group/help-cfengine.
> For more options, visit https://groups.google.com/d/optout.

signature.asc

Christian Linden

unread,
Jun 10, 2016, 7:30:55 AM6/10/16
to help-cfengine, nick.a...@cfengine.com
This works on 3.8.2 in production here as well now.. there's presumably a bug in 3.7.2.

c
> To unsubscribe from this group and all its topics, send an email to help-cfengine+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages