the following simplified manifest running:
package {'ruby2.4': ensure => installed } exec { "gem2.4_install_bundler": command => "/usr/bin/gem2.4 install bundler", require => package['ruby2.4'] }
puppet apply runs manifest correctly i.e
installs ruby2.4 package (which includes gem2.4)
installs bundler using gem2.4
however, puppet apply --noop fails because puppet cannot find executable '/usr/bin/gem2.4' because ruby2.4 not installed --noop.
my question if there standard way test scenario puppet apply --noop? validate puppet manifest executing correctly?
it occurs me may have parse output , validate order of executions. if case, there standard way/tool this?
a last resort basic check puppet @ least runs, can determined --detailed-exitcodes option. (a code different 1).
thank in advance
rspec-puppet standard tool level of verification. can build catalog manifest (e.g. class, defined type, or host) , can write tests verify contents.
in case verify package
resource exists, exec
resource exists, , verify ordering between them. effective running agent --noop
mode , parsing output - easier , cheaper run.
rspec-puppet works best modules, assuming follow setup module website (adding rspec-puppet
gemfile
, running rspec-puppet-init
), , let's in class called ruby24
, simple spec in spec/classes/ruby24_spec.rb
be:
require 'spec_helper' describe 'ruby24' { is_expected.to compile.with_all_deps } { is_expected.to contain_package('ruby2.4').with_ensure('installed') } { is_expected.to contain_exec('gem2.4_install_bundler').with_command('/usr/bin/gem2.4 install bundler') } { is_expected.to contain_exec('gem2.4_install_bundler').that_requires('package[ruby2.4]') } end
Comments
Post a Comment