Adrian van Dongen
2011-Dec-02 12:29 UTC
[Puppet Users] Using array''s in Puppet (in combination with Augeas).
Hi,
I have been struggling with arrays in puppet in combination with
Augeas. I have written a define to configure network interfaces on
Debian based distributions using Augeas. One of the requirements is
the possibility to use the up/down mechanism.
This where I run into a snag. Everything works fine until I try to
setup more than than one up rule. First some code examples of the
define:
-- Node Configuration --
networking::managed_interface { ''eth1'':
int => ''eth1'',
ipaddr => ''192.168.1.123'',
netmask => ''255.255.255.0'',
up => ''route add -net 172.16.1.0/24 gw
192.168.1.1''
}
-- networking::managed_interface (only the up segment) --
if $up != '''' {
augeas{ "up-${device}" :
context => ''/files/etc/network/interfaces'',
changes => [
"set iface[. = ''${device}'']/up[. =
''${up}'' ] \"${up}
\"",
],
}
}
So this works fine but I would like to be able to add multiple up
rules. I was thinking about passing multiple rules as an array:
up => [''route add -net 172.16.1.0/24 gw
192.168.3.1'', ''route
add -net 192.168.12.0/24 gw 192.168.3.1'']
And use some kind of for/while loop in Puppet to iterate over the
array but to my surprise Puppet has no way of doing this... I searched
the documentation, google and the google-group but there seems to be
no way of iterating over an array or even get the size of an array.
So now I am kind of stuck. I could write a separate define for the up
rules but I would rather have this within the define for interfaces.
I am probably not the first to have run into this and I am curious as
how others have solved this "problem"
Regards,
Adrian.
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
Felix Frank
2011-Dec-08 20:55 UTC
Re: [Puppet Users] Using array''s in Puppet (in combination with Augeas).
On 12/02/11 13:29, Adrian van Dongen wrote:> So now I am kind of stuck. I could write a separate define for the up > rules but I would rather have this within the define for interfaces.No, that''s how you generally do it. Make a defined type that does the required augeas to add an ''up'' rule, then have your interfaces define make one of those ''up'' resources per array element. Sorry For The Inconvenience ;-) Cheers, Felix -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Reasonably Related Threads
- puppet 2.7.5 and augeas break grub.conf on RHEL5
- Puppet and augeas - onlyif conditions; overwriting default values
- err: Could not run Puppet configuration client: Could not find a default provider for augeas
- hiera puppet augeas and hash keys ?
- Converting augeas snippet to puppet augeas resource