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 structured facts #112

Open
bodgit opened this issue Dec 20, 2019 · 3 comments
Open

Overriding structured facts #112

bodgit opened this issue Dec 20, 2019 · 3 comments

Comments

@bodgit
Copy link
Contributor

bodgit commented Dec 20, 2019

#37 covered how to set custom structured facts but this doesn't seem to work when I want to override an existing nested structured fact.

For example, I want to force $facts['os']['selinux']['enabled'] to be true regardless but it's always false because that's what is now set in the shipped facts, (fairly sure it used to be true or unset in previous facterdb releases so it was working by chance).

      let(:facts) do
        facts.merge({
          os: {
            selinux: {
              enabled: true,
            },
          },
        })
      end

I found there is a deep_merge gem pulled in via Puppet so I tried instead:

      let(:facts) do
        DeepMerge.deep_merge!(facts, {
          os: {
            selinux: {
              enabled: true,
            },
          },
        })
      end

But this gem seems to have odd merge behaviour and won't overwrite existing values.

What's the easiest way to do this?

@ekohl
Copy link
Member

ekohl commented Apr 24, 2020

The approach I took was to create an override_facts helper:
voxpupuli/voxpupuli-test@87d851c

@mcanevet Should this be contributed to rspec-puppet-facts?

@bodgit
Copy link
Contributor Author

bodgit commented Apr 24, 2020

Having something as part of this package would be super useful.

@mcanevet
Copy link
Member

@ekohl this cool be cool, indeed.

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

No branches or pull requests

3 participants