Skip to content

Instantly share code, notes, and snippets.

@liger1978
Last active February 22, 2021 10:19
Show Gist options
  • Save liger1978/aa83f3b30b74a5acf45199a338933249 to your computer and use it in GitHub Desktop.
Save liger1978/aa83f3b30b74a5acf45199a338933249 to your computer and use it in GitHub Desktop.
Puppet: transform array into hash using reduce
$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