Last active
March 13, 2019 23:18
-
-
Save alex-harvey-z3q/47b2238ec9183491dceaae1d31837820 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# common.yaml: | |
--- | |
service::common::httpd::packages: [ "Package['package-x']", "Package['package-y']" ] | |
# init.pp: | |
class test { | |
package { 'package-x': ensure => installed } | |
package { 'package-y': ensure => installed } | |
$packages = lookup('service::common::httpd::packages') | |
notify { 'message': | |
require => $packages, | |
} | |
} | |
# test case | |
describe 'test' do | |
let(:hiera_config) { 'spec/fixtures/hiera/hiera.yaml' } | |
it 'should compile' do | |
is_expected.to compile | |
File.write( | |
'myclass.json', | |
PSON.pretty_generate(catalogue) | |
) | |
end | |
end | |
Results: | |
Puppet 6.3 | |
Failures: | |
1) test should compile | |
Failure/Error: is_expected.to compile | |
error during compilation: Could not find resource 'Package['package-x']' in parameter 'require' (file: /Users/alexharvey/git/home/puppet-test/spec/fixtures/modules/test/manifests/init.pp, line: 7) on node alexs-macbook-pro.local | |
# ./spec/classes/test_spec.rb:6:in `block (2 levels) in <top (required)>' | |
Interestingly it fails in a different way for Puppet 4.10.12 and 5.5.10: | |
Failures: | |
1) test should compile | |
Failure/Error: is_expected.to compile | |
error during compilation: Could not retrieve dependency 'Package['package-x']' of Notify[message] | |
# ./spec/classes/test_spec.rb:6:in `block (2 levels) in <top (required)>' | |
For both latest Puppet 6 and 4, the fix is the same, to remove the single quotes from the YAML. | |
Testing for Puppet 3 was too much trouble to set up. | |
https://stackoverflow.com/a/55142359/3787051 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment