Re: Newbie questions
"'Richard Jones' via help-cfengine" <[email protected]> Sun, 3 Aug 2025 18:16:35 +0100
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
(I'm by no means any kind of expert, but I've been using CFE for a
number of years now)
On Aug 03, Jakub Wardyn wrote
> Hello,
> What doesn't make sense though, is the massive number of stuff I get in my
> "masterfiles" directory (I think it's called MPF), and contradicting
> documentation.
I tried briefly to write my own, a cut-down version, and failed
miserably. I suspect you'll receive similar advice from others, but
let's see.
> I have Alpine Linux and Debian Linux, as hub and agent respectively.
> They both use different directories for CFEngine's files
> (/var/lib/cfengine vs /var/lib/cfengine3), and this causes errors
> during bootstrap, unless I symlink, which seems hacky. In addition
> documentation everywhere says that /var/cfengine should be used, which
> is not the case.
If you use the community packages provided at cfengine.com, then
everything lives in /var/cfengine, much easier. Otherwise you can use
the $(sys.workdir) variable.
> Anyway, I think what I really want to know is:
> - Is there any "practical" guide for CFEngine which is reasonably recent,
> and can guide me through building small-scale stuff from the grounds up.
> I'd appreciate a link.
Diego Zamboni's "Learning CFEngine" might be a good place to start,
though it's probably a little out of date by now. I think he keeps his
errata and addendum up to date though.
> - Do I need MPF? If I have a git repo do I just copy MPF into it? What does
> MPF do for me? The very reason that I wanted to learn CFEngine is the
> simplicity and transparency of what it does, MPF seems to contradict that.
> - How to deal with the differences between paths in different distros?
> Should I just roll out CFEngine manually? I thought I can just install
> CFEngine in anyway, and then bootstrap and it will figure everything out
> from there, seems like that's not the case. I hope the "hub" can tell the
> agents where to look for the policies? Or is the files structure just
> coupled together everywhere?
I had, probably through my own fault, lots of problems getting clients
bootstrapped to the hub. In the end I just used a git repo and
bootstrapped to localhost "cf-agent -B 127.0.0.1"
I have my code in a separate directory and copy an autorun.cf file into
/var/cfengine/masterfiles/services/autorun/. This means, bar this one
file, you don't need to keep all of masterfiles in your repo and can
download the stock one. Something along the lines of the following,
which separates out machines by their DNS domain:
bundle common inputs {
# Despite its location, the bundles in services/autorun need the
# "autorun" tag.
meta:
"tags" slist => { "autorun" }
vars:
"inputs" slist => { findfiles("$(sys.workdir)/$(sys.domain)/cf/*.cf") };
reports:
"inputs are @(inputs)";
}
body file control {
inputs => { @(inputs.inputs) };
}
and then in /var/cfengine/cf/mydomain.com/mydomain.cf we can separate out machines roles:
bundle agent mydomain {
# Also needs to be tagged as autorun, the methods below then take
# care of running the other bundles per machine/role/whatever.
meta:
"tags" slist => { "autorun" };
methods:
webserver_host::
"webserver" usebundle => "webserver";
}
It's a steep initial learning curve, but in my opinion, once you've got
your bundles and files in place it's a breeze to automate systems.
The above was taken in part from:
https://cfengine.com/blog/2015/dynamic-bundlesequence-with-autorun-meta-tags-and-hard-classes/
which my also help.
Thanks,
Richard
--
junix.systems/privacy
+44 7843 588 599
--
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 [email protected].
To view this discussion visit https://groups.google.com/d/msgid/help-cfengine/aI%2BZc8JXjns%2BrL1M%40grey-area.junix.systems.