Kai
Kai

Reputation: 2325

Howto pass ENC parameters to a puppet apply run?

To test my puppet modules I usually just use puppet apply on a virtual machine. In that testing scenario there is no puppet master or ENC available.

Lot's of my modules use parameters. So how do I test the module with different parameters without the need to hardcode them?

Upvotes: 2

Views: 2854

Answers (2)

John Bollinger
John Bollinger

Reputation: 180201

Supposing that you are using at least Puppet 3, your easiest course of action would probably be to set up Hiera in the test environment and rely on automated data binding to assign values to class parameters. Indeed, this is also the best idea for binding data to class parameters on the master, and using the same approach in your test environment would give you the opportunity to test data and manifests together.

Upvotes: 1

Dominic Cleal
Dominic Cleal

Reputation: 3205

You need to include the class with parameters as you would in a manifest, e.g.

class { 'foo':
  param1 => 'value',
}

puppet apply can take a manifest either as an argument to -e, in a file or on stdin, so you could run:

puppet apply -e "class { 'foo': param1 => 'value', param2 => 'value2' }"

or put the class { 'foo': ... } into test.pp and run puppet apply test.pp.

Or lastly, run puppet apply, type/paste the class { 'foo': ... } content into stdin and press Ctrl+D to end input and run it.

Upvotes: 3

Related Questions