Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm struggling to get this to work and don't understand where I'm going wrong, can someone please guide me on how to correct?

Basically I want to get an array in my nodes.pp, which is then used by my templates file by cycling through it and writing a line of each element:

nodes.pp:

    node test{
        net::addr { 'routing':
          $routes = {
            route1 => {
                address => '172.29.54.70',
                netmask => '255.255.255.0',
                gateway => '172.29.54.65',
                dev     => 'eth0',
            },
            route2 => {
                address => '192.168.1.3',
                netmask => '255.255.255.0',
                gateway => '192.168.1.1',
                dev     => 'eth3',
            },
          }
        }
}

When I run the puppet client i keep getting the following:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not parse for environment production: Syntax error at '='; expected '}' at /etc/puppet/manifests/nodes/ test.pp:3 on node test.myincorp.net

addr.pp

define net::addr (
  $address='',
  $netmask='',
  $gateway='',
  $dev='',
) {

  file { "route-${name}":
    ensure  => 'present',
    mode    => '0644',
    owner   => 'root',
    group   => 'root',
    path    => "/etc/sysconfig/network-scripts/route-${name}",
    content => template('network/addr.erb'),
}
}

Template: addr.erb:

<% routes.each do |route| -%>
  <%= route['address'] %>  <%= route['netmask'] %> <%= route['gateway'] %> <%= route['dev'] %>
<% end -%>
<% end -%>
<% end -%>

Can someone help me with fixing the above please?

Thanks Dan

share|improve this question

1 Answer 1

It looks like you're intending to pass in a array of routes to net::addr in a routes name, but you've defined it as taking the 4 keys of each route rather then the route array. Try the following and see if it works any better.

node test{
    net::addr { 'routing':
        routes => {
            route1 => {
                address => '172.29.54.70',
                netmask => '255.255.255.0',
                gateway => '172.29.54.65',
                dev     => 'eth0',
            },
            route2 => {
                address => '192.168.1.3',
                netmask => '255.255.255.0',
                gateway => '192.168.1.1',
                dev     => 'eth3',
            },
        }
    }
}

and

define net::addr (
  $routes={},
) {
    file { "route-${name}":
        ensure  => 'present',
        mode    => '0644',
        owner   => 'root',
        group   => 'root',
        path    => "/etc/sysconfig/network-scripts/route-${name}",
        content => template('network/addr.erb'),
    }
}

Edit: Fixed typo, padding to get by edit character limit

share|improve this answer
    
Hi,I copied and pasted your suggestions above but I still got: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not parse for environment production: Syntax error at '='; expected '}' at /etc/puppet/manifests/nodes/test.pp:108 on node test.myincorp.net. Any other thoughts, its driving me a bit crazy this problem. Thanks –  Dan Feb 15 '13 at 9:20
    
Just to be clear the line in question that the error is pointing to relates to is "routes = {" –  Dan Feb 15 '13 at 9:29
    
Sorry, typoed the =>. Try with that fixed? –  kormoc Feb 15 '13 at 18:39

Your Answer

 
discard

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.