Last active
February 22, 2021 10:19
-
-
Save liger1978/aa83f3b30b74a5acf45199a338933249 to your computer and use it in GitHub Desktop.
Puppet: transform array into hash using reduce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$servers = ['server1.domain1','server2.domain2'] | |
$server_hash = $servers.reduce({}) |Hash $memo, String $server| { | |
$memo + { | |
$server => { | |
name => $server, | |
port => 80, | |
username => 'admin' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment