Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I did not find any elegant way to add several lines to an existing file.

I noticed the Simple Text Patterns wiki page, but I have to add a block into /etc/network/interfaces.

Any clue?

share|improve this question
augeas is the normal way – Sirex Jan 17 '13 at 8:05
thx. I will give it a try – Mike Aski Jan 17 '13 at 8:24
As a note, the question has been flaged to be closed by two people already. You might want to rephrase it. – ℝaphink Jan 17 '13 at 10:50
up vote 3 down vote accepted

I agree that augeas is by far the best answer to what you are trying.

I would also recommend the file_line resource from the stdlib puppet library. It tends to be much more lightweight than augeas.

You would have to define one resource for each line, and if the order is important you can add dependencies between the invocations.

Sample usage:

        file_line { "no_ipv6_networking":
            path  => "/etc/sysconfig/network",
            line  => "NETWORKING_IPV6=no",
            match => "^NETWORKING_IPV6=",
share|improve this answer

You coud use the augeas type for this, but the ideal solution would be to use netcf since you want to manage network interfaces.

Some time ago, I have started a Puppet Netcf provider. It is still not ready for production, but if you have some Ruby skills, it's probably the best solution for your need (and PRs are most definitely welcome, too).

The Netcf provider takes an XML interface definition as input, for example:

netcf_if {"eth1":
  ensure     => up,
  definition => '
<interface type="ethernet" name="eth1">
  <start mode="onboot"/>
  <protocol family="ipv4">
    <ip address="" prefix="24"/>
    <route gateway=""/>

You can find more examples of XML definitions in the Netcf repository.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.