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

Vagrant was unable to automatically detect the IP address of

Error message

Vagrant was unable to automatically detect the IP address of the
running machine to use as the policy server address. Please specify
the policy server address manually, or verify that the networks are
configured properly internally.

What it means

Raised by the CFEngine provisioner's handle_cfengine_bootstrap when `policy_server_address` is not set in the Vagrantfile and the guest's `read_ip_address` capability fails to auto-detect an IP (returns nil/false). Vagrant needs the policy server address to run `cf-agent --bootstrap`, so it aborts instead of guessing. The error means either the guest OS lacks an IP-detection capability implementation or the detection command failed inside the box.

Source

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

      def cfagent_extra_args
        return "" if !@config.extra_agent_args
        return " #{@config.extra_agent_args}"
      end

      # This handles checking if the CFEngine installation needs to
      # be bootstrapped, and bootstraps if it does.
      def handle_cfengine_bootstrap
        @logger.info("Bootstrapping CFEngine...")
        if !@machine.guest.capability(:cfengine_needs_bootstrap, @config)
          @machine.ui.info(I18n.t("vagrant.cfengine_no_bootstrap"))
          return
        end

        # Needs bootstrap, let's determine the parameters
        policy_server_address = @config.policy_server_address
        if !policy_server_address
          policy_server_address = @machine.guest.capability(:read_ip_address)
          raise Vagrant::Errors::CFEngineCantAutodetectIP if !policy_server_address
          @machine.ui.info(I18n.t("vagrant.cfengine_detected_ip", address: policy_server_address))
        end

        @machine.ui.info(I18n.t("vagrant.cfengine_bootstrapping",
                                policy_server: policy_server_address))
        result = cfagent("--bootstrap #{policy_server_address}", error_check: false)
        raise Vagrant::Errors::CFEngineBootstrapFailed if result != 0

        # Policy hubs need to do additional things before they're ready
        # to accept agents. Force that run now...
        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

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Set the address explicitly in the Vagrantfile: `cfengine.policy_server_address = "10.0.2.2"` (or your hub's IP)
  2. Verify networking inside the guest: `vagrant ssh` then `ip addr` / `ifconfig` to confirm an address is detectable
  3. Install missing network tools in the guest (iproute2 or net-tools) and re-run `vagrant provision`
  4. Switch to a box that fully supports Vagrant guest capabilities for your OS family

Example fix

# Vagrantfile - before
config.vm.provision "cfengine" do |cfengine|
  cfengine.am_policy_hub = true
end

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

Strategy: validation

Validate before calling

# Vagrantfile: never rely on auto-detection in automation
config.vm.provision "cfengine" do |cfengine|
  cfengine.policy_server_address = ENV.fetch("CFENGINE_POLICY_SERVER", "10.0.2.2")
end

Prevention

When it happens

Trigger: Provisioning with `config.vm.provision "cfengine"` while `cfengine.policy_server_address` is unset, and `@machine.guest.capability(:read_ip_address)` returning nil because the guest has no capability implementation for that OS or the underlying detection command (ip/ifconfig parsing) fails.

Common situations: Using an exotic or minimal guest box whose OS has no read_ip_address capability plugin; NAT-only networking where the internal interface lookup fails; boxes missing `iproute2`/`ifconfig`; DHCP not yet finished when the capability runs.

Related errors


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