After talking with some people in the cfengine
freenode.net irs room, it was suggested that I submit this to the mail group to get more eyes on a possible bug I've found.
1. Using Vagrant, I've got an Ubuntu 14.04.5 server, and I'm using CFEngine Core 3.11.0. I've set both of those up without any initial changing (Vagrantfile below in case it's of interest).
2. As root, I run this command:
/var/cfengine/bin/cf-agent --no-lock --verbose
3. I see a lot of messages indicating promises are being skipped, and all for the same reason 'if'/'ifvarclass' is not defined". Example:
verbose: BEGIN parsing file: /var/cfengine/inputs/controls/
def.cfverbose: END parsing file: /var/cfengine/inputs/controls/
def.cfverbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
The log indicates that this happens in the "Loading policy" section, right after the
def.cf file is parsed. I see these messages multiple times on the same run, so I don't think it's a matter of it not being defined on the first pass and then being defined later. I think it's not getting defined during this run, period.
"mailto"
string => "root@$(def.domain)",
ifvarclass => not(isvariable("mailto"));
... gives me the impression this promise is supposed to define "mailto" as "root@$(def.domain)" if it's not already defined.
5. To test whether this is happening, I created a small test policy (provided in detail below) to report the value of "mailto." It was not defined when I ran my policy. It's not even getting a default, apparently.
6. For a workaround, I can define "def.mailto" in /var/cfengine/inputs/def.json (file provided below), and then the message goes away for mailto. But there are many other variables that still have this message in the logs, and it seems like I shouldn't have to do this when
def.cf is supposed to be defining default values if they aren't defined.
VagrantFile
Vagrant.configure("2") do |config|
config.vm.define "policy_server", primary: true do |policy_server|
policy_server.vm.box = "ubuntu/trusty64"
policy_server.vm.hostname = "cfengine-policy-server"
policy_server.vm.network "private_network", ip: "192.168.50.2"
policy_server.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 512]
v.customize ["modifyvm", :id, "--name", "cfengine-policy-server"]
end
policy_server.vm.provision "shell", inline: <<-SHELL
/var/cfengine/bin/cf-agent --bootstrap 192.168.50.2
apt-get install -y git
git config --global user.email "*********"
SHELL
end
config.vm.define "host" do |host|
host.vm.box = "ubuntu/trusty64"
host.vm.hostname = "cfengine-host"
host.vm.network "private_network", ip: "192.168.50.3"
host.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 512]
v.customize ["modifyvm", :id, "--name", "cfengine-host"]
end
host.vm.provision "shell", inline: <<-SHELL
dpkg -i cfengine-community_3.10.2-1_amd64-debian4.deb
/var/cfengine/bin/cf-agent --bootstrap 192.168.50.2
SHELL
end
end
body common control
{
bundlesequence => { 'testing' };
}
bundle agent testing
{
reports:
"def.mailto is set to $(def.mailto)";
/var/cfengine/inputs/def.json