Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2697

verbose message "if/ifvarclass is not defined"

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: 3.11.0b1
    • Fix Version/s: 3.12.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ubuntu 14.04.5 server
      CFEngine Core 3.11.0
    • Platform:
      Ubuntu
    • Steps to reproduce:
      Manual steps provided

      Description

      After talking with some people in the cfengine freenode.net irs room, it was suggested that I submit this as a bug. Setting verbosity on the cf-agent output indicates many promises are being skipped because the variables aren't defined. I think this is actually misleading. Here are the details:
       
      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.cf
      verbose: END   parsing file: /var/cfengine/inputs/controls/def.cf
      verbose: 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 and for the same variables.
       
      4. The "mailto" promise is one of the promises where this message appears, but the promise should simply be defining the variable if it doesn't exist. Ex (from def.cf: https://github.com/cfengine/masterfiles/blob/master/controls/def.cf#L63) :
       
            "mailto"
              string => "root@$(def.domain)",
              ifvarclass => not(isvariable("mailto"));

      What should happen with this promise is that "mailto" gets defined if it's not. It definitely shouldn't be skipped if it's not defined.

      5. Nick Anderson demonstrated in his response to my Email in the Google group that this promise does actually end up working correctly at some point, because the variable does get defined if it doesn't exist:

      I added a reports promise in =services/main.cf= to emit =mailto
      $(def.mailto)= and it did report =mailto root@= (there is no domain configured
      on the hub in the vagrant environment)...

      #+BEGIN_EXAMPLE
      cf-agent -Kv --show-evaluated-vars | grep mailto
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      verbose: Skipping promise 'mailto' because 'if'/'ifvarclass' is not defined
      default:control_executor.mailto root@ source=promise
      default:def.mailto root@ source=promise
      #+END_EXAMPLE

       
      6. My guess is that this message gets logged, and the promise skipped, because at some point "ifvarclass" itself is not defined. Eventually ifvarclass is defined, and at that time the promise is executed and a default value for "mailto" is defined if it's not already. So perhaps def.cf is being called too early, ifvarclass isn't being defined early enough, or these messages shouldn't be logged?

       
      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 
           wget O https://s3.amazonaws.com/cfengine.packages/quick-install-cfengine-community.sh | sudo bash 
           /var/cfengine/bin/cf-agent --bootstrap 192.168.50.2 
           apt-get install -y git 
           git config --global user.name "********" 
           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 
           wget https://cfengine-package-repos.s3.amazonaws.com/community_binaries/Community-3.10.2/agent_deb_x86_64/cfengine-community_3.10.2-1_amd64-debian4.deb 
           dpkg -i cfengine-community_3.10.2-1_amd64-debian4.deb 
           /var/cfengine/bin/cf-agent --bootstrap 192.168.50.2 
         SHELL 
       
       end 
       
      end
       

        Attachments

          Activity

            People

            • Assignee:
              a10038 jimis (Dimitrios Apostolou)
              Reporter:
              elimtaft Eli Taft
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel