sync_cp for files and directories

41 views
Skip to first unread message

Nicolas Ecarnot

unread,
Dec 7, 2016, 8:23:05 AM12/7/16
to help-cfengine
Hello,

I'm trying to sync a list of item that may be files or folders, this way :

bundle agent env_root {
        vars:
                        [...]
                        "env_cfgfiles"
                                                slist => {
                                                        ".bashrc",
                                                        ".vimrc",
                                                        ".vim/",
                                                };

        files:
                        "$(local_cache)$(root_dir)/$(env_cfgfiles)"
                                comment => "Populating the local cache",
                                copy_from => sync_cp("$(master_directory)$(root_dir)/$(env_cfgfiles)","$(master_server)"),
                                depth_search => recurse("inf");

        [...]
}

This is working, but the addition of "depth_search => recurse("inf")" leads to a warning when dealing with files.
Not a big deal, but I'm looking either a way to properly deal with files AND folders, or a way to remove the warning.

Thank you.

--
Nicolas ECARNOT

Neil Watson

unread,
Dec 7, 2016, 9:00:44 AM12/7/16
to help-cfengine
Look how EFL deals with this. It sets classes if the promiser is a file
or dir based on using dir/. The dot.

https://github.com/neilhwatson/evolve_cfengine_freelib/blob/c8e8aeff7190a60b427ede9d62a9aae7b543f17c/masterfiles/lib/3.7/EFL/evolve_freelib.cf#L779-L787

Then use different promises based on those classes.
> --
> You received this message because you are subscribed to the Google
> Groups "help-cfengine" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [1]help-cfengin...@googlegroups.com.
> To post to this group, send email to [2]help-c...@googlegroups.com.
> Visit this group at [3]https://groups.google.com/group/help-cfengine.
> For more options, visit [4]https://groups.google.com/d/optout.
>
>References
>
> Visible links
> 1. mailto:help-cfengin...@googlegroups.com
> 2. mailto:help-c...@googlegroups.com
> 3. https://groups.google.com/group/help-cfengine
> 4. https://groups.google.com/d/optout
>ELinks: No such file or directory


--
Neil H Watson @neil_h_watson
CFEngine reporting: https://github.com/neilhwatson/delta_reporting
CFEngine policy: https://github.com/neilhwatson/evolve_cfengine_freelib
CFEngine and vim: https://github.com/neilhwatson/vim_cf3

Nicolas Ecarnot

unread,
Dec 8, 2016, 8:16:40 AM12/8/16
to help-cfengine, cfen...@watson-wilson.ca
Wow, thank you Neil for your answer.
To me, that seems a pity we even have to deal with this. Too bad this is not managed by design.

Nicolas ECARNOT

Nick Anderson

unread,
Dec 8, 2016, 6:24:22 PM12/8/16
to Nicolas Ecarnot, help-cfengine, cfen...@watson-wilson.ca

Nicolas Ecarnot writes:

> Wow, thank you Neil for your answer.
> To me, that seems a pity we even have to deal with this. Too bad this is
> not managed by design.

The warning you are referring to is this:

warning: depth_search (recursion) is promised for a base object '/tmp/place/promises.cf' that is not a directory

Indeed, the agent does what you intend regardless if you ask for a file or a
directory, so the warning seems to be somewhat useless. Moving the warning to
DEBUG is pretty easy.

https://github.com/cfengine/core/pull/2767

I wonder why we are warning about it, maybe something from the past. Anyway PR
is up in case its truly only useful for deep debugging.


Nick Anderson
Doer of things, CFEngine

Reply all
Reply to author
Forward
0 new messages