Ask Your Question

how to not apply a resource in a module

asked 2017-02-28 22:28:12 -0500

Narahari gravatar image

How do I conditionally apply a resource type in module pp file. ?

For example, if I want to run a package resource based on a availability of a file, not necessarily fail the package resource, How do you do that ?

Same thing with a file resource run it only if the exec resource it is dependent on created a file ?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-03-01 06:43:51 -0500

Eric_Anderson gravatar image

You could create a fact that determines if the file is there. Something like MODULEPATH/MODULE/facts.d/

`/urs/bin/test -f /path/to/file`
if [ $? -eq 0 ]
  has_file = true
  has_file = false

Then in your mainfests you would do something like:

class myclass {

  if ( $has_file == true ) {
    package { 'mypackage':
      ensure => installed,
      #yada yada yada

Below is the information for external facts / in-module facts. Hope this helps.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-02-28 22:28:12 -0500

Seen: 24 times

Last updated: Mar 01