On 07/29/2010 04:49 PM, Doug Warner wrote:
> I have a resource I'd like to manage via augeas (/etc/conf.d/net; it's a bash
> variables file) but I"m having problems figuring out how to set the values so
> that all of the values in the array go in.
> 
> I would like it to look like this:
> # cat /etc/conf.d/net
> config_eth4=("192.168.128.2/24")
> config_eth5=("192.168.129.2/24")
> routes_eth5=("192.168.130.0/24 via 192.168.131.1")
> 
> But it ends up looking like this:
> config_eth4=192.168.128.2/24
> config_eth5=192.168.129.2/24
> routes_eth5=192.168.130.0/24
> 
> The goal is to be able to assign multiple values to "ip" or "routes" for an
> interface.
> 
> Is this something I might have to do w/ a custom type?
> 

I'm trying to write a custom type based on the augeas type since I only need
to do a little bit of work, but I'm not used to ruby and don't know exactly
what's going.  I'm trying to extend the augeas type to set the changes when I
pass in IP and routes, but my test type isn't working.  So far I have:

require 'puppet/type/augeas'

Puppet::Type.newtype(:net_interface,
        :parent => Puppet::Type::Augeas,
        :context => "/files/etc/conf.d/net",
        :changes => "set config_eth9/1 192.168.205.2/24"
        ) do
        @doc = "Define a network interface"

        newparam (:name) do
                desc "The name of this task. Used for uniqueness"
                isnamevar
        end

        newparam (:ip) do
                desc "The IP addresses and netblocks for this interface"
                defaultto :false
        end

        newparam (:routes) do
                desc "The routes associated with this interface"
                defaultto :false
        end
end

When I call this with:
net_interface { 'eth4': ip => ["192.168.128.2/24"] }

nothing happens.

What do I need to do here to stick values into the "changes" variable when
'ip' or 'routes' is set and have the augeas type run?

-Doug

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to