Use of regular expressions

56 views
Skip to first unread message

Antonio Xanxess

unread,
Mar 14, 2012, 1:06:34 PM3/14/12
to puppet...@googlegroups.com
Hello everyone!
I have a problem and would like to help me. I have to control the configuration of an application that has special features. The application itself is an educational portal. These sites are hosted on a single machine and serve different schools. The file where you see that schools have a website on the server is located in /etc/application/centros.conf. The content is similar to this:
ID_CENTRO1
ID_CENTRO2

....
The application itself is hosted in /var/www/APP/ and hosts various portals through the directories named ID_CENTRO1, ID_CENTRO2, etc ...

My goal is to make a single resource file to modify a file in the platform for all schools, for example:

/var/www/APP/ID_CENTRO[X]/config/config.php

This was thinking of a facter extract the file contents and pass it through a custom function, but the problem I am not really know how many centers can have the server (there are several such servers and each has a different number of platforms)

My question is, is there any possibility of a resource file (either within a defined function or your own resource file) using regular expressions?
For example:

{file "/var/www/APP/[0-9]?/config/config.php"
...
}

You have any other ideas how I could do this?

Thank you very much for everything, a greeting!

Denmat

unread,
Mar 14, 2012, 5:01:08 PM3/14/12
to puppet...@googlegroups.com
Hi,

This is the sort of thing I would use hiera for. 

It may not match your workflow but I would create a yaml file with details for the portals like so:
Portals:
  ID_Centro:
    path: /var/.....
    owner: ...

Then you could use create_resource to apply the resource.

$my_list = hiera('portals')
create_resource(file, $my_list)

See the puppet docs for exact details and syntax.

Den
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/3i4sWqirbYQJ.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Reply all
Reply to author
Forward
0 new messages