Ask Your Question
0

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 ?

-N

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

puser gravatar image

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

#!/bin/bash
`/urs/bin/test -f /path/to/file`
if [ $? -eq 0 ]
then
  has_file = true
else
  has_file = false
fi

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.

https://docs.puppet.com/facter/3.6/cu...

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

Stats

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

Seen: 28 times

Last updated: Mar 01