A line resource?

Is there a “line” resource? I am thinking of something like this
http://automateit.org/documentation/classes/AutomateIt/EditManager/EditSession.html

There's http://augeas.net/ . It can be used for something like this. I
think the puppet people use it, or at least they did a year ago (the
last time I touched puppet). Haven't heard of this with Chef. I would
try to avoid this if at all possible. It's at least very hard to be
idempotent with this sort of editing.

KC

On Sat, Jan 7, 2012 at 3:53 PM, Tim Uckun timuckun@gmail.com wrote:

Is there a "line" resource? I am thinking of something like this
Class: AutomateIt::EditManager::EditSession

On Mon, Jan 9, 2012 at 12:36 AM, KC Braunschweig
kcbraunschweig@gmail.com wrote:

There's http://augeas.net/ . It can be used for something like this. I
think the puppet people use it, or at least they did a year ago (the
last time I touched puppet). Haven't heard of this with Chef. I would
try to avoid this if at all possible. It's at least very hard to be
idempotent with this sort of editing.

KC

KC is pretty spot on. The general rule is to either let chef manage
the whole file or not at all. Anyone who has used Augeus will tell you
that it's more trouble that it's worth in the long run (especially if
you shave the lens yak). If your application supports the concept of a
.d directory, you can let chef manage overrides as fragments there.

Obviously, not everything is perfect though. There are situations and
applications that still only work with a monolithic config file and
you might want to manage a subset. A good example is haproxy. At my
former employer, we wanted to manage haproxy backends based on
services that various instances needed. In that case, we leveraged
haproxy_join (GitHub - joewilliams/haproxy_join: Break up your haproxy configs and join them together) to build
the monolithic file for us. It worked/works awesome.

The point being, it might be worth your while to write a small utility
like that or ultimately an LWRP that builds the final file for you.

You can also use the tried and true sed approach. I do this for things
like cross-platform sshd_config editing to modify PermitRootLogin for
Rackspace Cloud nodes. (disable_ssh_root.rb · GitHub)

The biggest thing to be careful of is that you don't inadvertently
trigger a a service restart.

On Sat, Jan 7, 2012 at 23:53, Tim Uckun timuckun@gmail.com wrote:

Is there a "line" resource? I am thinking of something like this
Class: AutomateIt::EditManager::EditSession

There's Chef::Util::FileEdit ; see noit.rb · GitHub
for an example.
-t

On Mon, Jan 9, 2012 at 11:31 AM, Thom May thom@clearairturbulence.org wrote:

On Sat, Jan 7, 2012 at 23:53, Tim Uckun timuckun@gmail.com wrote:

Is there a "line" resource? I am thinking of something like this
Class: AutomateIt::EditManager::EditSession

There's Chef::Util::FileEdit ; see noit.rb · GitHub
for an example.
-t

I did a LWRP for deal with plain files. Something similar to what we
are talking about here:

Here is a example of how to use it:
https://github.com/gecos-team/cookbook-usermanagement/blob/master/recipes/shares.rb

I had plans for create a second one for INI files. It's almost done,
but I had to stop to finish somethings else. I hope to finish it after
I get done some stuff.

BTW, to get the LWRP working I did change the class Chef::Util::FileEdit

And the change is already proposed to Chef:
http://tickets.opscode.com/browse/CHEF-2740

I hope this help.
Any comments on the LWRP are welcome.

--
Juanje

Awesome thanks guys there is plenty there for me to go on.

On Mon, Jan 9, 2012 at 5:31 AM, Thom May thom@clearairturbulence.org wrote:

On Sat, Jan 7, 2012 at 23:53, Tim Uckun timuckun@gmail.com wrote:

Is there a "line" resource? I am thinking of something like this
Class: AutomateIt::EditManager::EditSession

There's Chef::Util::FileEdit ; see noit.rb · GitHub
for an example.
-t

Wow. I can't believe I've never seen that before. Very handy to have.