On 02/09/2012 05:50 AM, Eric Shamow wrote:
> Sateesh,
> 
> It is better if you don't look at it as a "loop."  A loop is a very
> procedural concept.  You are working with a machine that you are trying
> to get into a fixed state.
> 
> So better to think "I want to have a bunch of similar-looking resources
> that are identified and enumerated in an array."
> 
> This leads you to defined
> types: http://docs.puppetlabs.com/learning/definedtypes.html
> 
> Which is probably the way you should do this.

+1

Be especially aware that you need a "creates" or "onlyif" constraint,
otherwise puppet will perform your exec through each run.

Here's a pointer:

define proxy_ring($sip) {
  exec { "account-for-zone$name":
                command => "swift-ring-builder account.builder add
z$name-$sip:6002/sdb1 100",
                creates => ?????????!
                cwd => "/etc/swift",
                require => Class['swift::proxy-install'],
                path => ["/bin", "/sbin", "/usr/bin", "/usr/sbin"];
        "containter-for-zone$name":
                ...
}

Use this like
proxy_ring {
        "1": $ip1;
        "2": $ip2;
        ...
}

If you prefer arrays - that's harder. You could store the definitions in
a hash and use the create_resources() function.

HTH,
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to