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

Unknown variable: '::ipa_enrolled' (testing a role with PDK) #63

Closed
bittner opened this issue Oct 26, 2017 · 3 comments
Closed

Unknown variable: '::ipa_enrolled' (testing a role with PDK) #63

bittner opened this issue Oct 26, 2017 · 3 comments

Comments

@bittner
Copy link
Contributor

bittner commented Oct 26, 2017

I'm testing the roles of our control repo, and with profiles that include ipaclient I get an Evaluation Error: Unknown variable: for all $::ipa_* variables.

Clearly, they are not defined (e.g. in params.pp), as this happens via facter/ipa_facts.pp.

$ pdk test unit
[] Preparing to run the unit tests.
[] Running unit tests.
  Evaluated 4 tests in 3.685280097 seconds: 1 failures, 0 pending.
[] Cleaning up after running unit tests.
failed: rspec: ./spec/classes/role_workstation_backoffice_spec.rb:10: error during compilation: Evaluation Error: Unknown variable: '::ipa_enrolled'. at /home/peter.bittner/Development/repos/puppet-control/spec/fixtures/modules/ipaclient/manifests/init.pp:120:16 on node peter-pc.comsolit.local
  role::workstation::backoffice on ubuntu-16.04-x86_64 should compile into a catalogue without dependency cycles
  Failure/Error:
        end
  
        it { is_expected.to compile.with_all_deps }
      end
    end

... which comes from init.pp, line 117.

Do I have to configure the tests via .fixtures.yml in some way, or is there some other way to make facter (and ipa_facts.rb) initialize those values when running the test suite?

@bittner
Copy link
Contributor Author

bittner commented Oct 26, 2017

Looks like there is a STRICT_VARIABLES environment variable that can be set to make the tests pass, according to the puppetlabs_spec_helper README:

$ STRICT_VARIABLES=no pdk test unit

Any better solution suggested?

@binford2k
Copy link

@bittner That's a custom fact that the PDK doesn't know about. See

Facter.add("ipa_enrolled") do

You'll have to add it in to your spec test just like you would $osfamily or the like. Don't disable variable validation :)

@bittner
Copy link
Contributor Author

bittner commented Oct 27, 2017

@binford2k Thanks for the hint! This makes sense. I'll go with the rspec-puppet-facts docs on adding custom facts.

Now comes the tricky part: Figuring out which values to pick. 😏

@bittner bittner closed this as completed Oct 27, 2017
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

2 participants