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

Overriding facts fails when using Hiera #776

Open
ju5t opened this issue Nov 30, 2019 · 1 comment
Open

Overriding facts fails when using Hiera #776

ju5t opened this issue Nov 30, 2019 · 1 comment

Comments

@ju5t
Copy link

ju5t commented Nov 30, 2019

I am having some problems overriding facts that affect Hiera. This only happens when I upgrade to 2.7.0. As I am working on Puppet 6.11 support for this repo, I assume I have no other choice. On Puppet 5 and 2.4.0 all of our tests pass.

Our facts are loaded with:

require 'spec_helper'
require_relative '../facts.rb'

describe 'profiles::baseline' do
  context 'supported operating systems' do
    on_supported_os.each do |os, facts|
      context "on #{os}" do
        let(:facts) do
          facts.merge(Facts.override_facts)
        end

We would then have a default context and one override. For example:

context 'with default values for all parameters' do
  it { is_expected.to contain_class('profiles::baseline') }
end

context 'running on physical' do
  before do
    facts.merge!(
      virtual: 'physical'
    )
  end

  # it is expected to have some physical resource available here
end

The 'running on physical' always fails.

I have tried to switch our implementation over to use the default_facts configuration setting but this didn't work. None of the facts seemed to be coming through.

It seems to be a problem with data coming from Hiera. It might be the order in which facts are loaded. The facts that we merge often affect where to get data from. The virtual fact points to a specific yaml file. We were still using Hiera 3, but converting this to 5 makes no difference. It fails on data that is definitely available in Hiera, works in production and passes tests on Puppet 5 and pre-2.7 versions of rspec-puppet.

Does this sound familiar? Any suggestions I could look at?

@rodjek
Copy link
Owner

rodjek commented Jan 7, 2020

Hi @ju5t, can you create a simple example repository that replicates the problem?

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

2 participants