Ask Your Question
0

unless for class

asked 2014-03-17 13:54:46 -0500

mbaroukh gravatar image

updated 2014-03-17 13:55:05 -0500

Hi.

I'd like to execute a module only if a specific directory does not already exists on the node. How can this be achieved ?

Ideally, it would be perfect to be able to write something like

    class { "appl::install":
            unless => "test -d /data/appl"
    }

but unless isn't possible there.

Maybe I could write a fact that contains true if /data/appl exists and then use "if" but this seems too much work for such a simple need.

Thanks for your help.

Mike

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-03-17 14:52:14 -0500

Stefan gravatar image

updated 2014-03-18 05:01:10 -0500

You cannot do that without a custom fact. The catalog compilation (and the decision to include certain classes) happens on your puppet master. But your puppet master has to idea what directories are present on your agent. The only way to let the master know about the state of the agent is the agent explicitly tells these facts to the master. When the master hands the catalog down to the client, the client will just get a collection of resources and is not aware of any classes.

So while writing a custom fact is really not that complicated in your ... (more)

edit flag offensive delete link more

Comments

Thanks. I thought that facts were overkill for this. strange. But ok, I will do this. In case anybody read this, i think there is a mistake in your sample ...(more)

mbaroukh gravatar imagembaroukh ( 2014-03-18 03:57:35 -0500 )edit

Updated my answer to include your fix. As I said the reason that you want to query the state of the agent in the first place often indicates a design ...(more)

Stefan gravatar imageStefan ( 2014-03-18 05:05:28 -0500 )edit

I need to install an application. The installer is a shell script that have to be executed on the node after having applied a patch. So the only way of ...(more)

mbaroukh gravatar imagembaroukh ( 2014-03-18 05:40:41 -0500 )edit

If you cannot install your software as a package and want to use the install script from your vendor, I always tend to use a custom wrapper script. So in ...(more)

Stefan gravatar imageStefan ( 2014-03-18 06:55:37 -0500 )edit

Yes it's a good idea ! This way, the installation script could check if already installed. My facter is then useless. I have just one objection : as I know, there ...(more)

mbaroukh gravatar imagembaroukh ( 2014-03-18 08:26:00 -0500 )edit

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: 2014-03-17 13:54:46 -0500

Seen: 273 times

Last updated: Mar 18 '14