Skip to content

Impossible to have server_facts without servername #37

Open
@ekohl

Description

@ekohl

Describe the Bug

When configuring rspec-puppet to provide the $server_facts hash it's impossible to unset the servername entry. However, that is what happens when you run Puppet serverless (i.e., puppet apply). This means it's impossible to have a single codebase be tested using rspec-puppet in both serverless and server-mode.

Expected Behavior

A way to (locally) control whether the environment pretends to be connected or not.

Steps to Reproduce

Configure the test suite with server facts

RSpec.configure do |c|
  c.trusted_server_facts = true
end

Then have code that uses $server_facts['servername']:

if $server_facts['servername'] {
  file { '/tmp/puppetserver':
    ensure  => file,
    content => $server_facts['servername'],
  }
}

Test this out with the following code:

it { is_expected.not_to contain_file('/tmp/puppetserver') }

This will fail, while it's expected to pass.

Environment

  • Version 2.12.0
  • Ruby 3.1.3

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