Search code examples
testingpuppetno-op

Alter the behaviour when noop runs-noop metaparameter doesn't work?


I have following resource definition

 file { '/usr/lib/oozie/libext/hadoop-lzo-0.5.0.jar':
      ensure  => present,
      group   => 'root', 
      owner   => 'root', 
      source  => '/usr/lib/hadoop/lib/hadoop-lzo-0.5.0.jar',
      mode    => 0755,
      require => [Package['lzo'],Package['lzo-devel'],Package['hadoop-lzo'],Package['hadoop-lzo-native']],
    }

Which essentially copies jar artefact to desired location. The issue here is source definition which point to the location created by installation one of these packages. When running puppet in noop mode this resource definition cause to fail as there is no such source - what is pretty logical.

Is there a way to change this behaviour? I do not want to skip all its dependencies. Or what is the proposed way to do so? I would like to avoid copying the jar to modules file.

I found noop metaparameter, documentation here but seems that doesn't help either. So the resource specification looks like:

file { '/usr/lib/oozie/libext/hadoop-lzo-0.5.0.jar':
      ensure  => present,
      group   => 'root', 
      owner   => 'root', 
      source  => '/usr/lib/hadoop/lib/hadoop-lzo-0.5.0.jar',
      mode    => 0755,
      noop    => false,
      require => [Package['lzo'],Package['lzo-devel'],Package['hadoop-lzo'],Package['hadoop-lzo-native']],
    }

Do I need to switch something on? Or do I misunderstood something? How do I detect that module is run in noop mode? If I would like to to some nasty fix. Something like if noop then skip

thanks


Solution

  • The $clientnoop fact will be true when the client is run in noop mode, and false otherwise.

    I'm not sure if it is the best solution, but you could include a different resource when $clientnoop is true. Your 'noop resource' could be a file resource with the same parameters, except for the source. This way, other resources that depend on this file can still be applied.