Puppet resources or plain script?

37 views
Skip to first unread message

zerozer...@gmail.com

unread,
Jan 31, 2014, 5:09:51 AM1/31/14
to puppet...@googlegroups.com
Hi,
I'm going to use Puppet to replace a long manual process which involves lots of steps mostly like installing packages, copying configuration files, and also doing many string replacements with sed and line additions inside those configuration files. All on CentOS.

I was wondering whether trying to fit those config files editing operations into augeas and/or file_line resources is a good idea, or maybe it would be wiser to just collect them in a bash script and exec the script through puppet, as I do not have to deal with different operating systems and such.

What is the best practice in such situations?
It is also important to note that most - maybe all - of these operations have to be performed only once, after provisioning the machine.

Thank you for any suggestions.
Marco

José Luis Ledesma

unread,
Jan 31, 2014, 5:30:53 AM1/31/14
to puppet...@googlegroups.com

Hi,

  Without knowing exactly everything you do to deploy a new server, I would suggest make use of templates to deploy these config files you modify with seds...

Regards

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/9726a03c-c616-45b3-99b9-837017648ef5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

zerozer...@gmail.com

unread,
Jan 31, 2014, 5:49:33 AM1/31/14
to puppet...@googlegroups.com
On Friday, January 31, 2014 11:30:53 AM UTC+1, Jose Luis Ledesma wrote:

  Without knowing exactly everything you do to deploy a new server, I would suggest make use of templates to deploy these config files you modify with seds...

Well, I'm not very skilled with templates yet, but wouldn't this require that I create the _entire_ config files as templates?
Or is there a way to let a template include an external file and then just replace part of it? I would say this is not possible...

I only need to modify small parts of possibly long config files, and having to copy them all inside templates would be impractical.
It would also be hard to manage, meaning that problems can arise if the version of a package changes and the installed default config file changes accordingly, because I would have to change my template too.

Thanks.
Marco

liu.cy

unread,
Jan 31, 2014, 9:08:53 AM1/31/14
to puppet...@googlegroups.com
there are some ways to deal with it.
1. augeas, but it depends on what application are you using. augeas only works when template available. the most common config files are built-in supported like sysctl.conf, iptables, httpd.conf. you have to write your own augeas template if you are using own apps.
2. template, i think erb template is a good idea. copy config file and add variables or ruby codes. as you say, you don't want to use it because you just need modify a few part of a big file. so, consider way 3 and 4.
3. erb template can insert any ruby code you want, so save the static part to a file, and read it at top of erb template can let you include other file. but template is compiled in master, so the static file must in master and may not what you wanted.
4. like sysctl, httpd most apps in linux already have include functions, my suggestion is try to find if your app config can include another config file or not. if not, can you add it?

liu.cy

unread,
Jan 31, 2014, 9:10:16 AM1/31/14
to puppet...@googlegroups.com

liu.cy

unread,
Jan 31, 2014, 9:12:03 AM1/31/14
to puppet...@googlegroups.com

liu.cy

unread,
Jan 31, 2014, 9:12:04 AM1/31/14
to puppet...@googlegroups.com

liu.cy

unread,
Jan 31, 2014, 9:12:04 AM1/31/14
to puppet...@googlegroups.com

liu.cy

unread,
Jan 31, 2014, 9:12:05 AM1/31/14
to puppet...@googlegroups.com

zerozer...@gmail.com

unread,
Jan 31, 2014, 9:18:31 AM1/31/14
to puppet...@googlegroups.com
On Friday, January 31, 2014 3:08:53 PM UTC+1, liu.cy wrote:
 
1. augeas, but it depends on what application are you using. augeas only works when template available. the most common config files are built-in supported like sysctl.conf, iptables, httpd.conf. you have to write your own augeas template if you are using own apps.

Actually, I have to work with custom config files, too. But they use standard .ini and .conf file structure, with [sections] and parameter=value pairs. Does augeas need custom templates to be developed in this case, too? I hoped it could work for any standard configuration file.
 
4. like sysctl, httpd most apps in linux already have include functions, my suggestion is try to find if your app config can include another config file or not. if not, can you add it?

But this would not solve my need for string replacements in existing files. And I have many of them. 

Thanks.
Marco

Ian Mortimer

unread,
Jan 31, 2014, 7:50:02 PM1/31/14
to puppet...@googlegroups.com
On Sat, 1 Feb 2014, zerozer...@gmail.com wrote:

> Actually, I have to work with custom config files, too. But they use
> standard .ini and .conf file structure, with [sections] and parameter=value
> pairs. Does augeas need custom templates to be developed in this case, too?
> I hoped it could work for any standard configuration file.

Augeas has lenses (not templates) for ini files and other
standard types (shellvars and simplevars for example) and
it's not difficult to create your own lenses.

This is exactly what Augeas was designed to do so it should
be ideal for your purpose but it's not to everyone's taste.


--
Ian
Reply all
Reply to author
Forward
0 new messages