Ask Your Question

Virtual resource for a file

asked 2015-01-30 20:26:41 -0500

RobertII gravatar image

I have a module which defines a resource type that takes a number of parameters. I am using that module, with different parameter values, to set up several differently-configured instances of an application on a number of servers. Each application on each server has its own directory structure, cron jobs and the like. Fine.

That application has now been extended to rely on a new, system-wide file. If there is any instance of the application on the server, this file must be in place. I have added the file to the module, but I cannot get puppet to copy it into place.

If I just declare a "file" resource as part of the module, every instance of the module attempts to create the same file and so puppet cannot apply the catalog.

So, following the example here, I have tried declaring a virtual resource for the file....

        @file{ '/global/file/name':   
           source => "puppet:///modules/myModule/contentsOfFile",
           mode => '0544' }

which I then realize within my module

       define myapp (
            realize File[ "/global/file/name" ]

But this just fails: on a node with three instances of myapp, puppet apply produces this less-than-helpful error message:

    Error: Failed to realize virtual resources File[/global/file/name], File[/global/file/name], File[/global/file/name] on node

So, there are three identical resources that puppet cannot realize, but with no information about why that is.

Is this the right way to go about doing this? Can anyone see what is wrong?

Thanks in advance.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-01-31 00:03:15 -0500

lavaman gravatar image

Instead of realizing a virtual resource, just put it in a subclass and include it where necessary. Includes can happen as many times as you want.

edit flag offensive delete link more


That's worked. Thanks. Though I'd still like to understand the "Failed to realize virtual resources" message.

RobertII gravatar imageRobertII ( 2015-01-31 03:54:03 -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


Asked: 2015-01-30 20:26:41 -0500

Seen: 403 times

Last updated: Jan 31 '15