puppetlabs/puppet · error · Puppet::Error

Duplicate device found at

Error message

Duplicate device found at %{file_error_location}, already found at %{device_error_location}

What it means

Raised while parsing a network device configuration file: a [device.fqdn] section header names a device that has already been defined earlier in the same file. Duplicate device definitions are ambiguous — Puppet cannot decide which entry describes the device — so parsing aborts with both locations reported.

Solutions

  1. Remove or rename the duplicate [device.fqdn] section in the device config file
  2. Keep only one entry per device, using the later or correct location
  3. Search the file for repeated section headers with the same device name
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/puppet/util/network_device/config.rb:59 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/e48b1d92a3bc0933. Report an issue: GitHub.

Appendix: source

Thrown at lib/puppet/util/network_device/config.rb:59

      devices = {}
      device = nil
      File.open(@file) do |f|
        file_line_count = 1
        f.each do |line|
          case line
          when /^\s*#/ # skip comments
            file_line_count += 1
            next
          when /^\s*$/ # skip blank lines
            file_line_count += 1
            next
          when /^\[([\w.-]+)\]\s*$/ # [device.fqdn]
            name = ::Regexp.last_match(1)
            name.chomp!
            if devices.include?(name)
              file_error_location = Puppet::Util::Errors.error_location(nil, file_line_count)
              device_error_location = Puppet::Util::Errors.error_location(nil, device.line)
              raise Puppet::Error, _("Duplicate device found at %{file_error_location}, already found at %{device_error_location}") %
                                   { file_error_location: file_error_location, device_error_location: device_error_location }
            end
            device = OpenStruct.new
            device.name = name
            device.line = file_line_count
            device.options = { :debug => false }
            Puppet.debug "found device: #{device.name} at #{device.line}"
            devices[name] = device
          when /^\s*(type|url|debug)(\s+(.+)\s*)*$/
            parse_directive(device, ::Regexp.last_match(1), ::Regexp.last_match(3), file_line_count)
          else
            error_location_str = Puppet::Util::Errors.error_location(nil, file_line_count)
            raise Puppet::Error, _("Invalid entry at %{error_location}: %{file_text}") %
                                 { error_location: error_location_str, file_text: line }
          end
        end
      end
    rescue Errno::EACCES

View on GitHub (pinned to e227c27540)