1
0
Fork 0

add resolvers to haproxy

This commit is contained in:
ibizaman 2023-01-22 00:15:33 -08:00
parent ef526699b4
commit 6cbf1fc694

View file

@ -102,6 +102,7 @@ let
, check ? null , check ? null
, httpcheck ? null , httpcheck ? null
, forwardfor ? true , forwardfor ? true
, resolvers ? null
}: }:
[ [
"mode http" "mode http"
@ -112,7 +113,11 @@ let
"server" "server"
name name
address address
(optionals (check != null) (mapAttrsToList (k: v: "${k} ${v}") check)) (optionals (check != null) (if
isBool check
then (if check then ["check"] else [])
else mapAttrsToList (k: v: "${k} ${v}") check))
(optional (resolvers != null) "resolvers ${resolvers}")
]) ])
]; ];
@ -210,8 +215,25 @@ let
]; ];
} }
{ {
match = k: parent: v: k == "frontend"; match = k: parent: v: k == "resolvers";
order = 3; order = 3;
rules = [
{
match = k: parent: v: true;
header = k: "resolvers " + k;
indent = " ";
rules = [
{
match = k: parent: v: k == "nameservers";
rule = k: parent: v: mapAttrsToList (k1: v1: "nameserver ${k1} ${v1}") v;
}
];
}
];
}
{
match = k: parent: v: k == "frontend";
order = 4;
rules = [ rules = [
{ {
match = k: parent: v: true; match = k: parent: v: true;
@ -260,7 +282,7 @@ let
} }
{ {
match = k: parent: v: k == "backend"; match = k: parent: v: k == "backend";
order = 4; order = 5;
rules = [ rules = [
{ {
match = k: parent: v: true; match = k: parent: v: true;
@ -326,6 +348,7 @@ in
, sites ? {} , sites ? {}
, globals ? {} , globals ? {}
, defaults ? {} , defaults ? {}
, resolvers ? {}
}: { }: {
global = { global = {
# Silence a warning issued by haproxy. Using 2048 # Silence a warning issued by haproxy. Using 2048
@ -450,6 +473,8 @@ in
assert assertMsg (hasAttr "backend" config) "no backend defined in config for site ${name}, found attr names: ${toString (attrNames config)}"; assert assertMsg (hasAttr "backend" config) "no backend defined in config for site ${name}, found attr names: ${toString (attrNames config)}";
nameValuePair name config.backend) nameValuePair name config.backend)
sites; sites;
inherit resolvers;
}; };
render = config: render = config: