Skip to content

Instantly share code, notes, and snippets.

@Gabelbombe
Created January 25, 2015 19:22
Show Gist options
  • Save Gabelbombe/29baf50502be1fed9bdb to your computer and use it in GitHub Desktop.
Save Gabelbombe/29baf50502be1fed9bdb to your computer and use it in GitHub Desktop.
Iterate a loop in Puppet
#!/bin/bash
puppet apply --parser future -e '$ip="192.158.1" $vars={
0 => "${ip}.0",
1 => "${ip}.1",
2 => "${ip}.2",
} each($vars) |$id,$gate| { notice "${id} -> ${gate}" }'
## Outputs
#Notice: Scope(Class[main]): 0 -> 192.158.1.0
#Notice: Scope(Class[main]): 1 -> 192.158.1.1
#Notice: Scope(Class[main]): 2 -> 192.158.1.2
#Notice: Compiled catalog for master.gsm1900.org in environment production in 0.32 seconds
#Notice: Finished catalog run in 0.01 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment