diff --git a/hieradata/country/au/region/drw1/infra/halb/haproxy.yaml b/hieradata/country/au/region/drw1/infra/halb/haproxy.yaml index 75dcd39..a582f9b 100644 --- a/hieradata/country/au/region/drw1/infra/halb/haproxy.yaml +++ b/hieradata/country/au/region/drw1/infra/halb/haproxy.yaml @@ -1,8 +1,24 @@ --- # mappings -profiles::haproxy::mappings::list: - - 'puppetboard.main.unkin.net be_puppetboard' - - 'puppetdbapi.main.unkin.net be_puppetdbapi' +profiles::haproxy::mappings: + fe_https: + ensure: present + mappings: + - 'puppetboard.main.unkin.net be_puppetboard' + - 'puppetdbapi.main.unkin.net be_puppetdbapi' + +# profiles::haproxy::listeners: +# ls_puppetdbapi_direct: +# collect_exported: false # handled in custom function +# ipaddress: "%{facts.networking.ip}" +# ports: +# - 8081 +# mode: tcp +# options: +# option: +# - tcplog +# - ssl-hello-chk +# balance: roundrobin profiles::haproxy::backends: be_puppetboard: diff --git a/site/profiles/manifests/haproxy/backends.pp b/site/profiles/manifests/haproxy/backends.pp new file mode 100644 index 0000000..a8d1294 --- /dev/null +++ b/site/profiles/manifests/haproxy/backends.pp @@ -0,0 +1,19 @@ +# profiles::haproxy::backends +class profiles::haproxy::backends { + # set location_environment + $location_environment = "${facts['country']}-${facts['region']}-${facts['environment']}" + + # for each backend: + $backends = lookup('profiles::haproxy::backends', Hash, 'deep', {}) + $backends.each |$backend, $data| { + + # create backend + haproxy::backend { $backend: + * => $data, + } + + # collect exported resources + $tag = "${backend}_${location_environment}" + Haproxy::Balancermember <<| tag == $tag |>> + } +} diff --git a/site/profiles/manifests/haproxy/frontends.pp b/site/profiles/manifests/haproxy/frontends.pp new file mode 100644 index 0000000..10721db --- /dev/null +++ b/site/profiles/manifests/haproxy/frontends.pp @@ -0,0 +1,14 @@ +# profiles::haproxy::frontends +class profiles::haproxy::frontends { + + # for each frontend: + $frontends = lookup('profiles::haproxy::frontends', Hash, 'deep', {}) + $frontends.each |$frontend, $data| { + + # create frontends + haproxy::frontend { $frontend: + * => $data, + } + + } +} diff --git a/site/profiles/manifests/haproxy/listeners.pp b/site/profiles/manifests/haproxy/listeners.pp new file mode 100644 index 0000000..3fbe07e --- /dev/null +++ b/site/profiles/manifests/haproxy/listeners.pp @@ -0,0 +1,19 @@ +# profiles::haproxy::listeners +class profiles::haproxy::listeners { + # set location_environment + $location_environment = "${facts['country']}-${facts['region']}-${facts['environment']}" + + # for each listener: + $listeners = lookup('profiles::haproxy::listeners', Hash, 'deep', {}) + $listeners.each |$listen, $data| { + + # create listener + haproxy::listen { $listen: + * => $data, + } + + # collect exported resources + $tag = "${listen}_${location_environment}" + Haproxy::Balancermember <<| tag == $tag |>> + } +} diff --git a/site/profiles/manifests/haproxy/mappings.pp b/site/profiles/manifests/haproxy/mappings.pp index ec8a1e4..df844df 100644 --- a/site/profiles/manifests/haproxy/mappings.pp +++ b/site/profiles/manifests/haproxy/mappings.pp @@ -1,9 +1,13 @@ # profiles::haproxy::mappings -class profiles::haproxy::mappings ( - Array $list = [] -) { - haproxy::mapfile { 'domains-to-backends': - ensure => 'present', - mappings => $list, +class profiles::haproxy::mappings { + + # for each mapping: + $mappings = lookup('profiles::haproxy::mappings') + $mappings.each |$mapping, $data| { + + # create mapping + haproxy::mapfile { $mapping: + * => $data, + } } } diff --git a/site/profiles/manifests/haproxy/server.pp b/site/profiles/manifests/haproxy/server.pp index 1864727..fde8f2f 100644 --- a/site/profiles/manifests/haproxy/server.pp +++ b/site/profiles/manifests/haproxy/server.pp @@ -2,7 +2,6 @@ class profiles::haproxy::server ( Hash $globals = {}, Hash $defaults = {}, - Array $cnames = [], ){ # default global/defaults arrays @@ -52,19 +51,8 @@ class profiles::haproxy::server ( include profiles::haproxy::fe_http # default http frontend include profiles::haproxy::fe_https # default https frontend include profiles::haproxy::dns # manage dns for haproxy + include profiles::haproxy::frontends # create frontends + include profiles::haproxy::backends # create backends + include profiles::haproxy::listeners # create listeners - # for each backend: - $backends = lookup('profiles::haproxy::backends') - $backends.each |$backend, $data| { - - # create backend - haproxy::backend { $backend: - * => $data, - } - - # collect exported resources - $location_environment = "${facts['country']}-${facts['region']}-${facts['environment']}" - $tag = "${backend}_${location_environment}" - Haproxy::Balancermember <<| tag == $tag |>> - } }