Is there a smart way to tweak configurations file in chef? (or puppet, cfengine, or otherwise?)


#1

I have this scenario where I have a my.cnf ini file, and I want to
make sure it has a certain value in a certain section. (Can’t just
append to the end of the file.)

I solved this using the perl file, attached. Obviously this isn’t a
perfect solution though. If the value is already set, but set wrong,
it won’t work.

The right way to do this would be to parse the ini file and do something smart.

I am just wondering if this kind of tweak is a solved problem, in
chef, puppet, cfengine, or anywhere else.

Thanks in advance for any advice!


Thomas Hartman

Darcs hosting: patch-tag.com
Build a webapp with haskell: happstack.com


#2

Hiya,

There are a few camps of thought for this - ex-users of cfengine often
look for such behavior.

We have a lightweight file editing Mixin in production, and I have
been evaluating Augeas on supported platforms for similar tasks.

On 31/07/2009, at 11:42 AM, Thomas Hartman wrote:

I have this scenario where I have a my.cnf ini file, and I want to
make sure it has a certain value in a certain section. (Can’t just
append to the end of the file.)

I solved this using the perl file, attached. Obviously this isn’t a
perfect solution though. If the value is already set, but set wrong,
it won’t work.

The right way to do this would be to parse the ini file and do
something smart.

You could possibly try the parseconfig Gem, and do so in-template-
parse-and-re-render magic, but down this path surely lies madness.

Most times this can be solved by a ‘smart’ template for my.cnf which
reads in snippets from another directory, or programatically builds up
the entire configuration file. This is the other main camp of thought

  • everything you are managing on your system should be managed (entire
    files) instead of a line in a file, which has the potential to
    conflict or be broken by earlier configuration (in that same file)

I am just wondering if this kind of tweak is a solved problem, in
chef, puppet, cfengine, or anywhere else.

Thanks in advance for any advice!


Thomas Hartman

Darcs hosting: patch-tag.com
Build a webapp with haskell: happstack.com
<insert_after_line.pl>


AJ Christensen, Software Engineer
Opscode, Inc.
E: aj@opscode.com


#3

Is this something Augeas (http://augeas.net/index.html) either with Chef or
Puppet would help with? I know the Puppet guys have at least some Augeas
support.

On Thu, Jul 30, 2009 at 8:24 PM, Arjuna Christensen aj@opscode.com wrote:

Hiya,
There are a few camps of thought for this - ex-users of cfengine often look
for such behavior.

We have a lightweight file editing Mixin in production, and I have been
evaluating Augeas on supported platforms for similar tasks.

On 31/07/2009, at 11:42 AM, Thomas Hartman wrote:

I have this scenario where I have a my.cnf ini file, and I want to
make sure it has a certain value in a certain section. (Can’t just
append to the end of the file.)

I solved this using the perl file, attached. Obviously this isn’t a
perfect solution though. If the value is already set, but set wrong,
it won’t work.

The right way to do this would be to parse the ini file and do something
smart.

You could possibly try the parseconfig Gem, and do so
in-template-parse-and-re-render magic, but down this path surely lies
madness.

Most times this can be solved by a ‘smart’ template for my.cnf which reads
in snippets from another directory, or programatically builds up the entire
configuration file. This is the other main camp of thought - everything you
are managing on your system should be managed (entire files) instead of a
line in a file, which has the potential to conflict or be broken by earlier
configuration (in that same file)

I am just wondering if this kind of tweak is a solved problem, in
chef, puppet, cfengine, or anywhere else.

Thanks in advance for any advice!


Thomas Hartman

Darcs hosting: patch-tag.com
Build a webapp with haskell: happstack.com
<insert_after_line.pl>


AJ Christensen, Software Engineer
Opscode, Inc.
E: aj@opscode.com adam@opscode.com


#4

On 31/07/2009, at 3:57 PM, Jeffrey Hulten jhulten@gmail.com wrote:

Is this something Augeas (http://augeas.net/index.html) either with
Chef or Puppet would help with? I know the Puppet guys have at least
some Augeas support.

That’s what I said; see below.

I have a number of concerns with Augeas, mostly around it’s lack of
cross platform support, unique ‘lenses’ to describe syntax and the
requirement of an external non-native-Ruby (gem) library.

The lightweight file editing mixin should be able to accomplish most
of these tasks in most common formats, aside from some of the more
advanced functionality of Augeas.

On Thu, Jul 30, 2009 at 8:24 PM, Arjuna Christensen aj@opscode.com
wrote:
Hiya,

There are a few camps of thought for this - ex-users of cfengine
often look for such behavior.

We have a lightweight file editing Mixin in production, and I have
been evaluating Augeas on supported platforms for similar tasks.

On 31/07/2009, at 11:42 AM, Thomas Hartman wrote:

I have this scenario where I have a my.cnf ini file, and I want to
make sure it has a certain value in a certain section. (Can’t just
append to the end of the file.)

I solved this using the perl file, attached. Obviously this isn’t a
perfect solution though. If the value is already set, but set wrong,
it won’t work.

The right way to do this would be to parse the ini file and do
something smart.

You could possibly try the parseconfig Gem, and do so in-template-
parse-and-re-render magic, but down this path surely lies madness.

Most times this can be solved by a ‘smart’ template for my.cnf which
reads in snippets from another directory, or programatically builds
up the entire configuration file. This is the other main camp of
thought - everything you are managing on your system should be
managed (entire files) instead of a line in a file, which has the
potential to conflict or be broken by earlier configuration (in that
same file)

I am just wondering if this kind of tweak is a solved problem, in
chef, puppet, cfengine, or anywhere else.

Thanks in advance for any advice!


Thomas Hartman

Darcs hosting: patch-tag.com
Build a webapp with haskell: happstack.com
<insert_after_line.pl>


AJ Christensen, Software Engineer
Opscode, Inc.
E: aj@opscode.com


#5

On Thu, Jul 30, 2009 at 4:42 PM, Thomas
Hartmanthomashartman1@googlemail.com wrote:

I have this scenario where I have a my.cnf ini file, and I want to
make sure it has a certain value in a certain section. (Can’t just
append to the end of the file.)

I solved this using the perl file, attached. Obviously this isn’t a
perfect solution though. If the value is already set, but set wrong,
it won’t work.

The right way to do this would be to parse the ini file and do something smart.

I am just wondering if this kind of tweak is a solved problem, in
chef, puppet, cfengine, or anywhere else.

Thanks in advance for any advice!

Like AJ pointed out, there are multiple ways to attack this. The
preferred method with Chef is to make a template of the file, and then
render the correct values. We let you be very clever to accomplish
this - for example, resources can be re-opened later, and more
variables added to the context the template is rendered in.

t = resources(:template => “my.cnf”)
t.variables[:some_value] = 15

Is one example. This means you could iteratively build things up as you go.

Adam


Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-7449 E: adam@opscode.com