Skip to content

Cannot use file($settings::localcacert) in my manifest, tests fail #59

Open
@threepistons

Description

@threepistons

Describe the Bug

When I try to write tests for a manifest to replace the CA cert across my nodes, very like this one.
I get

1) profiles::replace_ca_cert All tests is expected to compile into a catalogue without dependency cycles
     Failure/Error: it { is_expected.to compile.with_all_deps }
       error during compilation: Evaluation Error: Error while evaluating a Function Call, Could not find any files from /dev/null/ssl/certs/ca.pem (file: /home/ucs/102/redacted/git/computing_linux_puppet_controlrepo/site/profiles/spec/fixtures/modules/profiles/manifests/replace_ca_cert.pp, line: 16, column: 16) on node redacted.uni.ac.uk
  7) profiles::replace_ca_cert All tests is expected to contain File[/etc/puppetlabs/puppet/ssl/certs/ca.pem] with ensure => "file" and replace => "yes"
     Failure/Error:
       is_expected.to contain_file('/etc/puppetlabs/puppet/ssl/certs/ca.pem').with(
         'ensure'  => 'file',
         'replace' => 'yes',
       )

     Puppet::PreformattedError:
       Evaluation Error: Error while evaluating a Function Call, Could not find any files from /dev/null/ssl/certs/ca.pem (file: /home/ucs/102/redacted/git/computing_linux_puppet_controlrepo/site/profiles/spec/fixtures/modules/profiles/manifests/replace_ca_cert.pp, line: 16, column: 16) on node redacted.uni.ac.uk

and further identical errors for each OS under test.

Expected Behaviour

I expected the manifest to compile.

Steps to Reproduce

Steps to reproduce the behaviour:

  1. pdk new class replace_ca_cert in my profiles module.
  2. Paste replace_ca_cert.pp.txt into manifests/replace_ca_cert.pp.
  3. Paste replace_ca_cert_spec.rb.txt into spec/classes/replace_ca_cert_spec.rb.
  4. pdk validate ; pdk test unit

Environment

  • PDK 2.6.1 (I don't get to update this, I don't have root on the timeshare I'm using).
  • Control repo with roles and profiles. The rest of the control repo passes unit tests.
  • CentOS Linux release 7.9.2009 (Core)

Additional Context

Replacing the file resource's content with a string instead of file($settings::localcacert) in replace_ca_cert.pp compiled perfectly, but that's not the behaviour I need.

I'm hoping that the answer turns out to be something really simple like "put X line into Y file". Google, Stack Exchange, etc revealed nothing of the sort.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions