Merge pull request 'neoloc/haproxy_puppetdbapi' (#151) from neoloc/haproxy_puppetdbapi into develop
Reviewed-on: unkinben/puppet-prod#151
This commit is contained in:
commit
258cedb566
@ -126,7 +126,6 @@ profiles::base::hosts::additional_hosts:
|
|||||||
hostname: prodinf01n04.main.unkin.net
|
hostname: prodinf01n04.main.unkin.net
|
||||||
aliases:
|
aliases:
|
||||||
- prodinf01n04
|
- prodinf01n04
|
||||||
- puppetdb
|
|
||||||
- ip: 198.18.17.5
|
- ip: 198.18.17.5
|
||||||
hostname: prodinf01n05.main.unkin.net
|
hostname: prodinf01n05.main.unkin.net
|
||||||
aliases:
|
aliases:
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
# mappings
|
# mappings
|
||||||
profiles::haproxy::mappings::list:
|
profiles::haproxy::mappings::list:
|
||||||
- 'puppetboard.main.unkin.net be_puppetboard'
|
- 'puppetboard.main.unkin.net be_puppetboard'
|
||||||
|
- 'puppetdbapi.main.unkin.net be_puppetdbapi'
|
||||||
|
|
||||||
profiles::haproxy::backends:
|
profiles::haproxy::backends:
|
||||||
be_puppetboard:
|
be_puppetboard:
|
||||||
@ -17,6 +18,19 @@ profiles::haproxy::backends:
|
|||||||
- set-header X-Forwarded-Port %[dst_port]
|
- set-header X-Forwarded-Port %[dst_port]
|
||||||
- add-header X-Forwarded-Proto https if { dst_port 443 }
|
- add-header X-Forwarded-Proto https if { dst_port 443 }
|
||||||
redirect: 'scheme https if !{ ssl_fc }'
|
redirect: 'scheme https if !{ ssl_fc }'
|
||||||
|
be_puppetdbapi:
|
||||||
|
description: Backend for the PuppetDB API
|
||||||
|
collect_exported: false # handled in custom function
|
||||||
|
options:
|
||||||
|
balance: roundrobin
|
||||||
|
option:
|
||||||
|
- httpchk GET /
|
||||||
|
- forwardfor
|
||||||
|
cookie: SRVNAME insert
|
||||||
|
http-request:
|
||||||
|
- set-header X-Forwarded-Port %[dst_port]
|
||||||
|
- add-header X-Forwarded-Proto https if { dst_port 443 }
|
||||||
|
redirect: 'scheme https if !{ ssl_fc }'
|
||||||
be_letsencrypt:
|
be_letsencrypt:
|
||||||
description: Backend for LetsEncrypt Verifications
|
description: Backend for LetsEncrypt Verifications
|
||||||
collect_exported: true
|
collect_exported: true
|
||||||
@ -67,3 +81,9 @@ profiles::haproxy::certlist::certificates:
|
|||||||
# additional altnames
|
# additional altnames
|
||||||
profiles::pki::vault::alt_names:
|
profiles::pki::vault::alt_names:
|
||||||
- puppetboard.main.unkin.net
|
- puppetboard.main.unkin.net
|
||||||
|
- puppetdbapi.main.unkin.net
|
||||||
|
|
||||||
|
# additional cnames
|
||||||
|
profiles::haproxy::dns::cnames:
|
||||||
|
- puppetboard.main.unkin.net
|
||||||
|
- puppetdbapi.main.unkin.net
|
||||||
|
|||||||
27
site/profiles/manifests/haproxy/dns.pp
Normal file
27
site/profiles/manifests/haproxy/dns.pp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# profiles::haproxy::dns
|
||||||
|
class profiles::haproxy::dns (
|
||||||
|
Array[Stdlib::Fqdn] $cnames = [],
|
||||||
|
Integer $order = 10,
|
||||||
|
){
|
||||||
|
|
||||||
|
# create an A record for each load balancer in a region
|
||||||
|
$location_environment = "${facts['country']}-${facts['region']}-${facts['environment']}"
|
||||||
|
profiles::dns::record { "${facts['networking']['fqdn']}_${location_environment}-halb_A":
|
||||||
|
value => $::facts['networking']['ip'],
|
||||||
|
type => 'A',
|
||||||
|
record => "${location_environment}-halb",
|
||||||
|
zone => $::facts['networking']['domain'],
|
||||||
|
order => $order,
|
||||||
|
}
|
||||||
|
|
||||||
|
# export cnames for haproxy applications
|
||||||
|
$cnames.each |$cname| {
|
||||||
|
profiles::dns::record { "${::facts['networking']['fqdn']}_${cname}_CNAME":
|
||||||
|
value => "${location_environment}-halb",
|
||||||
|
type => 'CNAME',
|
||||||
|
record => "${cname}.",
|
||||||
|
zone => $::facts['networking']['domain'],
|
||||||
|
order => $order,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@
|
|||||||
class profiles::haproxy::server (
|
class profiles::haproxy::server (
|
||||||
Hash $globals = {},
|
Hash $globals = {},
|
||||||
Hash $defaults = {},
|
Hash $defaults = {},
|
||||||
|
Array $cnames = [],
|
||||||
){
|
){
|
||||||
|
|
||||||
# default global/defaults arrays
|
# default global/defaults arrays
|
||||||
@ -50,6 +51,7 @@ class profiles::haproxy::server (
|
|||||||
include profiles::haproxy::ls_stats # default status listener
|
include profiles::haproxy::ls_stats # default status listener
|
||||||
include profiles::haproxy::fe_http # default http frontend
|
include profiles::haproxy::fe_http # default http frontend
|
||||||
include profiles::haproxy::fe_https # default https frontend
|
include profiles::haproxy::fe_https # default https frontend
|
||||||
|
include profiles::haproxy::dns # manage dns for haproxy
|
||||||
|
|
||||||
# for each backend:
|
# for each backend:
|
||||||
$backends = lookup('profiles::haproxy::backends')
|
$backends = lookup('profiles::haproxy::backends')
|
||||||
|
|||||||
@ -18,4 +18,16 @@ class profiles::puppet::puppetdb_api (
|
|||||||
export_scrape_job => true,
|
export_scrape_job => true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# export haproxy balancemember
|
||||||
|
profiles::haproxy::balancemember { "${facts['networking']['fqdn']}_8080":
|
||||||
|
service => 'be_puppetdbapi',
|
||||||
|
ports => [8080],
|
||||||
|
options => [
|
||||||
|
"cookie ${facts['networking']['hostname']}",
|
||||||
|
'check',
|
||||||
|
'inter 2s',
|
||||||
|
'rise 3',
|
||||||
|
'fall 2',
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,8 +23,8 @@ def build_query(node=None, fact_name=None, match=None, show_role=False):
|
|||||||
return json.dumps(["and"] + query_filters)
|
return json.dumps(["and"] + query_filters)
|
||||||
|
|
||||||
def query_puppetdb(query):
|
def query_puppetdb(query):
|
||||||
url = 'http://puppetdb:8080/pdb/query/v4/facts'
|
url = 'https://puppetdbapi.main.unkin.net/pdb/query/v4/facts'
|
||||||
response = requests.get(url, params={'query': query})
|
response = requests.get(url, params={'query': query}, verify='/etc/pki/tls/cert.pem')
|
||||||
process_response(response)
|
process_response(response)
|
||||||
|
|
||||||
def process_response(response):
|
def process_response(response):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user