hashicorp/vagrant · error · Vagrant::Errors.CFEngineNotInstalled

CFEngine appears not to be installed on the guest machine. V

Error message

CFEngine appears not to be installed on the guest machine. Vagrant
can attempt to install CFEngine for you if you set the "install"
setting to "true", but this setting was not set. Please install
CFEngine on the guest machine or enable the "install" setting for
Vagrant to attempt to install it for you.

What it means

Raised by handle_cfengine_installation when the `cfengine_installed` guest capability reports CFEngine is absent (or `install == :force`) and the `install` config option is not enabled. Vagrant deliberately will not install software on the guest unless you opt in with `cfengine.install = true`, so an uninstalled CFEngine plus no opt-in aborts provisioning. Note the earlier branch: if the guest has no `cfengine_installed` capability at all, it only warns and continues.

Source

Thrown at plugins/provisioners/cfengine/provisioner.rb:119

        if @config.am_policy_hub
          @machine.ui.info(I18n.t("vagrant.cfengine_bootstrapping_policy_hub"))
          cfagent("-KI -f /var/cfengine/masterfiles/failsafe.cf#{cfagent_classes_args}")
          cfagent("-KI #{cfagent_classes_args}#{cfagent_extra_args}")
        end
      end

      # This handles verifying the CFEngine installation, installing it
      # if it was requested, and so on. This method will raise exceptions
      # if things are wrong.
      def handle_cfengine_installation
        if !@machine.guest.capability?(:cfengine_installed)
          @machine.ui.warn(I18n.t("vagrant.cfengine_cant_detect"))
          return
        end

        installed = @machine.guest.capability(:cfengine_installed)
        if !installed || @config.install == :force
          raise Vagrant::Errors::CFEngineNotInstalled if !@config.install

          @machine.ui.info(I18n.t("vagrant.cfengine_installing"))
          @machine.guest.capability(:cfengine_install, @config)

          if !@machine.guest.capability(:cfengine_installed)
            raise Vagrant::Errors::CFEngineInstallFailed
          end
        end
      end

      # This installs a set of files into the CFEngine folder within
      # the machine.
      #
      # @param [Pathname] local_path
      def install_files(local_path)
        @logger.debug("Copying local files to CFEngine: #{local_path}")
        @machine.communicate.sudo("rm -rf /tmp/cfengine-files")
        @machine.communicate.upload(local_path.to_s, "/tmp/cfengine-files")

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Enable opt-in installation: `cfengine.install = true` in the Vagrantfile block
  2. Use `cfengine.install = :force` to reinstall even when the guest reports it installed
  3. Or bake CFEngine into a custom box / preinstall it so the capability check passes

Example fix

# Vagrantfile - before
config.vm.provision "cfengine" do |cfengine|
  cfengine.policy_server_address = "10.0.2.2"
end

# Vagrantfile - after
config.vm.provision "cfengine" do |cfengine|
  cfengine.policy_server_address = "10.0.2.2"
  cfengine.install = true
end
Defensive patterns

Strategy: validation

Validate before calling

# Vagrantfile: make the intent explicit instead of relying on box contents
config.vm.provision "cfengine" do |cfengine|
  cfengine.install = true          # or omit if you guarantee the box ships CFEngine
  cfengine.policy_server_address = "10.0.2.2"
end

Type guard

def cfengine_available?(machine)
  machine.guest.capability?(:cfengine_installed) &&
    machine.guest.capability(:cfengine_installed)
end

Prevention

When it happens

Trigger: Running the cfengine provisioner on a box without CFEngine binaries present while `@config.install` is nil/false - i.e. the capability check `cfengine_installed` returned false and `raise ... if !@config.install` fired.

Common situations: Using stock base boxes (ubuntu/jammy, centos/stream) that ship no CFEngine; Vagrantfile copied from a CFEngine-ready environment into a plain box; expecting Vagrant to auto-install like the shell provisioner does.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/5be5e08c8bb7a5d9. Report an issue: GitHub.