Ask Your Question
1

Syntax error with "$x.each ..."

asked 2015-07-06 04:27:52 -0500

Benedikt Bock gravatar image

Hi,

I have the code below:

define keepalived::vrrp_instance(
  $state,
  $interface,
  $virtual_addresses,
  $virtual_router_id,
  $priority      = $::keepalived::params::priority,
  $advert_int    = $::keepalived::params::advert_int,
  $password      = $::keepalived::params::password,
  $notify_master = $::keepalived::params::notify_master,
  $notify_backup = $::keepalived::params::notify_backup,
  $notify_fault  = $::keepalived::params::notify_fault,
  $notify_all    = $::keepalived::params::notify_all,
  $smtp_alert    = $::keepalived::params::smtp_alert,
) {
  ...
  $virtual_addresses.each |$address| {
    $splitted_address = split($address,' ')
    if  !is_ip_address($splitted_address[0]) {
      fail("Error virtual_address Value: \"${address}\" not an ip address!")
    }
  }
  ...
}

$virtual_addresses is something like ['127.0.0.1 dev eth0','fd00::1 dev eth0']

Running the code I get the following error:

Syntax error at '.'; expected '}' at /etc/puppet/environments/ip6_dev/modules_custom/keepalived/manifests/vrrp_instance.pp:136 on node

Line 136 is '$virtual_addresses.each |$address| {'

I am using Puppet 3.3.2

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-07-07 03:00:59 -0500

sinned gravatar image

updated 2015-07-07 03:03:05 -0500

Each is available in Puppet only in versions 4.0.0 and later.

See https://docs.puppetlabs.com/reference...

It's at the very end of the paragraph.

As a workaround, you could use "old style iteration", see here for more info: https://docs.puppetlabs.com/puppet/4....

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-07-06 04:23:00 -0500

Seen: 971 times

Last updated: Jul 07 '15