Aleksey,

I don't think that {{{ files: "/tmp/filename.txt"; }}} means that it is 
promised to *exist* since one of the attributes is delete, which means that the 
file promises to *not* exist.

The way I read the files: promisetype for agent is that the promiser only 
promises to be a valid path name, and it's up to the attributes (create, copy, 
link, delete, etc) which determine what action will be taken on the promiser, 
or in other words the promiser (/tmp/filename.txt) promises to (create/delete).

In your example the promiser is making an explicit promise of nothing, rather 
than promising *something*.

Granted, I've been using cfengine3 less than two weeks, but this how I 
understand it.

-- 
Brian

On Feb 29, 2012, at 2:01 PM, Aleksey Tsalolikhin wrote:

> Using CFEngine 3.2.1,  I've observed that the promise_kept classes
> attribute is not getting set on files type promises when there are no
> attributes.  Either that, I don't misunderstand files type promises,
> in which case I'd like to clear that up, please.
> 
> 
> Doesn't   {{{ files:  "/tmp/filename"; }}} mean that /tmp/filename
> promises to continue to exist?  (But not to be auto-created if it does
> not exist?)
> 
> Based on that assumption,I tried to chain two promises together, to
> install the Fedora RPM that provides the YUM configuration to enable
> the EPEL (Extra Packages for Enterprise Linux) repository, but
> apparently CFEngine does not consider it a promise_kept if the file is
> already there:
> 
> 
> ### start test.cf ###
> 
> body common control {
> 
>        inputs => { "/var/cfengine/inputs/cfengine_stdlib.cf" };
> }
> 
> bundle agent epel_repo_is_installed {
> 
> files:
> 
>    "/etc/yum.repos.d/epel.repo"
> 
>       classes =>  if_ok("epel_repo_is_installed");
> 
> 
> reports:
> 
>  !epel_repo_is_installed::
> 
>    "EPEL RPM is not installed.  We need to install it.";
> 
> }
> 
> ### end test.cf ###
> 
> 
> # ls /etc/yum.repos.d/epel.repo
> /etc/yum.repos.d/epel.repo
> # cf-agent -f ./test.cf -b epel_repo_is_installed -K
> R: EPEL RPM is not installed.  We need to install it.
> #
> 
> I've replaced the files type promise with
> 
> {{{
> 
> classes:
> 
>    "epel_repo_is_installed"
> 
>           expression => fileexists("/etc/yum.repos.d/epel.repo");
> 
> }}}
> 
> which has the advantage of expressing my intention very clearly but
> I'd like to understand why the files type promise did not behave as I
> expected.
> 
> Do I misunderstand something, or am I running into a corner case or
> unexpected use of the language?
> 
> Best,
> -at
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine

Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

Reply via email to