-
-
Save SimonHoenscheid/659b746666830eb11c27db8eea40bd07 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# hiera | |
uptream: | |
'abc_core': | |
'ips': | |
- '1.2.3.4' | |
- '1.2.3.5' | |
'port': 8080 | |
'abc_cp_core': | |
'ips': | |
- '1.2.3.4' | |
- '1.2.3.5' | |
'port': 8081 | |
'def_core': | |
'ips': | |
- '1.2.3.6' | |
- '1.2.3.7' | |
'port': 8080 | |
'def_cp_core': | |
'ips': | |
- '1.2.3.6' | |
- '1.2.3.7' | |
port: 8081 | |
# Puppet class | |
class config ( | |
$upstream | |
){ | |
$upstream.each |$key, $value| { | |
concat::fragment { $key: | |
target => '/etc/config', | |
content => template('config/upstream.erb'), | |
} | |
} | |
# Puppet template | |
upstream portal<%= @key %> { | |
<%- @value['ips'].each do |ip| -%> | |
server <%= ip %>:<%= @value['port'] %> weight=1 max_fails=2 fail_timeout=5s; | |
<%- end -%> | |
} | |
# declaration | |
class { 'config': | |
upstream => { | |
'abc_core' => { | |
'ips' => [ '1.2.3.4', '1.2.3.5'], | |
'port' => 8080 | |
}, | |
'abc_cp_core' => { | |
'ips' => [ '1.2.3.4', '1.2.3.5'], | |
'port' => 8081 | |
}, | |
'def_core' => { | |
'ips' => [ '1.2.3.6', '1.2.3.7'], | |
'port' => 8080 | |
}, | |
'def_cp_core' => { | |
'ips' => [ '1.2.3.6', '1.2.3.7'], | |
port => 8081 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment