Skip to content

networking key in default_facts.yml masks all values from rspec-puppet-factsΒ #543

@silug

Description

@silug

Describe the Bug

Adding a top-level networking key in spec/default_facts.yml masks all values in the networking key from rspec-puppet-facts. For example, in tests networking.fqdn is not defined.

Expected Behavior

The networking facts provided by rspec-puppet-facts should work in tests.

Steps to Reproduce

Steps to reproduce the behavior:

  1. pdk new module
  2. Update template-url and template-ref to point to upstream.
  "template-url": "https://github.com/puppetlabs/pdk-templates#3.0.0",
  "template-ref": "tags/3.0.0-0-g5bfc1c0"
  1. pdk update
  2. Create an empty class with pdk new class and add the following to the generated spec test:
      let(:pre_condition) do
        <<~END
          if $facts['networking']['fqdn'].empty {
            fail("No fqdn fact: networking => ${facts['networking']}")
          }
        END
      end
  1. pdk test unit

The resulting error will look like this:

     Failure/Error: it { is_expected.to compile.with_all_deps }
       error during compilation: Evaluation Error: Error while evaluating a Function Call, No fqdn fact: networking => {ip => 172.16.254.254, ip6 => FE80:0000:0000:0000:AAAA:AAAA:AAAA, mac => AA:AA:AA:AA:AA:AA}

Environment

  • Version 3.0.0
  • Platform Fedora 39 (using the Fedora 36 package)

Additional Context

In previous versions of the templates, only top-level keys were defined in spec/default_facts.yml, so the merge that was happening in spec/spec_helper.rb worked fine with default values. With nested facts added to spec/default_facts.yml, the merge needs to be replaced with a deep_merge.

Note that simply removing spec/default_facts.yml by adding

spec/default_facts.yml:
  delete: true

to .sync.yml and running pdk update also works since the default provided facts are being provided by rspec-puppet-facts already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions