Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

order of concat fragment in each loop

$
0
0
Atm I am writing a small module adding new interfaces to /etc/network/interfaces. Therefor a hash is placed in the hiera file which is parsed and concatenated to the file. Each fragment gets a number which is incremented. How can i order the fragments numeric wise? network_custom::interfaces: em4: ipaddress: '175.21.0.15' network: '175.21.0.0' broadcast: '175.21.0.255' dns-search: 'xxx.xxx.de' em5: ipaddress: '175.21.0.131' network: '175.21.0.0' broadcast: '175.21.0.255' dns-search: 'xxx-xxx.yyy.de' class network_custom::debian{ concat { '/etc/network/interfaces': ensure => present, } $interfaceconfigs = hiera_hash(network_custom::interfaces) $interfaceslist = keys($interfaceconfigs) $count = inline_template( '<%= $c = $c || 0; $c = 0 %>' ) each($interfaceslist) |$interfacename|{ $count = inline_template( '<%= $c = $c || 0; $c = $c + 1 %>' ) concat::fragment { $interfacename: target => '/etc/network/interfaces', content => "auto ${interfacename}\niface ${interfacename} inet static\n", order => $count } $interfaceconf = $interfaceconfigs[$interfacename] each($interfaceconf) |String $key, String $value|{ $count = inline_template( '<%= $c = $c || 0; $c = $c + 1 %>' ) concat::fragment { "${interfacename}${key}": target => '/tmp/etc/network/interfaces', content => " ${key} ${value}\n", order => $count } } }

Viewing all articles
Browse latest Browse all 6104

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>