Puppet definitions and hashes/arrays syntax problem.

114 views
Skip to first unread message

Rocky

unread,
Apr 13, 2012, 11:17:07 AM4/13/12
to puppet...@googlegroups.com
Hi, I have this definiton for keepalived. And i need to feed the template this array that i will loop trough.

site.pp definition snippet: 
 
 keepalived::vrrp_virtual_server { 
 
               real_servers = { realserver1 => { ip => '192.168.33.10',                                        
                                       port => '80',
                                       weight => '100' 
                                       checktype => 'TCP_CHECK', 
                                       connect_timeout => '5',
                                       connect_port => '80'
                                       }                        
               realserver2 => { ip => '192.168.33.20',
                                       port => '80',                                        
                                       weight => '100'
                                       checktype => 'TCP_CHECK',
                                       connect_timeout => '5',
                                       connect_port => '80'                                        
                                     }                        
}

keepalived manifest snippet:

define keepalived::vrrp_virtual_server(
                  $real_servers

 Template snippet:

<% real_servers.each do |key,value| -%>    
     real_server <%= value['ip'] %> <%= value['port'] %>      
        weight <%= value['weight'] %>
        <%= value['checktype'] %> 
                connect_timeout <%= value['connect_timeout'] %>
                connect_port <%= value['connect_port'] %>


I keep getting:

Could not parse for environment production: Syntax error at '='; expected '}' at /etc/puppet/manifests/site.pp:53

What is the right syntax for an array in a definition in site.pp?


Walter Heck

unread,
Apr 13, 2012, 9:48:45 PM4/13/12
to puppet...@googlegroups.com
Am I missing soemthing or is one of your two array declarations using
a '=' and the other an '=>' ? Seems simple to me if this is a real
quote of your actual code..

> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/eDzTXglLGksJ.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

--
Walter Heck

--
follow @walterheck on twitter to see what I'm up to!
--
Check out my new startup: Server Monitoring as a Service @ http://tribily.com
Follow @tribily on Twitter and/or 'Like' our Facebook page at
http://www.facebook.com/tribily

jcbollinger

unread,
Apr 16, 2012, 9:57:50 AM4/16/12
to Puppet Users


On Apr 13, 10:17 am, Rocky <rosco...@gmail.com> wrote:
> Hi, I have this definiton for keepalived. And i need to feed the template
> this array that i will loop trough.
>
> site.pp definition snippet:
>
> >  keepalived::vrrp_virtual_server {
>
>                real_servers = { realserver1 => { ip => '192.168.33.10',


Variables in Puppet manifests are designated by an initial '$' sigil:

$real_servers = ...

(The sigil is left off when you refer to local Puppet variables in
templates, however.)


John

jcbollinger

unread,
Apr 16, 2012, 10:56:49 AM4/16/12
to Puppet Users


On Apr 13, 10:17 am, Rocky <rosco...@gmail.com> wrote:
>                                        weight => '100'

Also, you're missing a comma after each appearance of that entry.


John
Reply all
Reply to author
Forward
0 new messages