Forum: Cfengine Help
Subject: Re: Hostname based classes and virtual machines in Cfengine 3
Author: dnaeon
Link to topic: https://cfengine.com/forum/read.php?3,22131,22139#msg-22139

mark Wrote:
-------------------------------------------------------
> Yes, but I still don't understand. Cfengine gets
> the real host name from uname(), which is what you
> get from printing the shell command. So your
> example is no different from using the hostname of
> the machine. 
> 
> Also, I don't see what the IP addresses have to do
> with the hostname,
> 
> Is there not rather a way of determining what is
> not a jail? The presence of a special file, the
> ability to see the jail directories, to qualify
> the class?
> 
> isdir("/jail") ?
> 
> I'm afraid I don't know much about jails or how
> they look in practice.
> 
> M

Hello again,

Thanks for the quick replies!

@Mark

Yes, there is a way to determine if you are running in a jail or a host instead:


bundle common myclasses {

vars:

    "sysctl_jailed" string => execresult("/sbin/sysctl -n 
security.jail.jailed", "noshell");

classes:

    "freebsd_jail" expression => strcmp("$(sysctl_jailed)", "1");
    "freebsd_host" expression => strcmp("$(sysctl_jailed)", "0");


@toddnni

The example given by toddnni in his last post is the exact issue - the host 
inherits the classes for the jails as well. It is not a jail related issue, but 
an interface actually, because the interface's IP address is looked up and 
automatically creates a hard class in the form of host_domain_tld for that IP 
address.

And when you have a jail on the host (and interface for it) you get the classes 
for the jail on the host as well.

Hope that makes any sense.

Regards,
Marin

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

Reply via email to