Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
threepistons opened this issue Jun 26, 2023 · 2 comments
Open

Comments

@threepistons
Copy link

threepistons commented Jun 26, 2023

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.

@threepistons
Copy link
Author

I get the same result with PDK 3.0.0 on a different system.

@mmarseglia
Copy link

Hi @threepistons did you ever find a solution? I have the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants