2023-07-20 12:32:31 +02:00
|
|
|
###
|
|
|
|
# Metadata for the nodes. You can add custom attributes, they are
|
|
|
|
# accessible through the specialArg meta in the config.
|
|
|
|
|
2023-05-22 15:06:11 +02:00
|
|
|
let
|
2023-07-20 12:32:31 +02:00
|
|
|
###
|
|
|
|
# Transforms data from :
|
|
|
|
# {
|
|
|
|
# zone01 = [ node01 node02 ];
|
|
|
|
# zone02 = [ node03 ];
|
|
|
|
# }
|
|
|
|
# to :
|
|
|
|
# {
|
|
|
|
# node01 = zone01;
|
|
|
|
# node02 = zone01;
|
|
|
|
# node03 = zone02;
|
|
|
|
# }
|
|
|
|
locations = builtins.foldl'
|
|
|
|
(a: loc: a // loc)
|
|
|
|
{ }
|
|
|
|
(builtins.concatLists (builtins.attrValues (builtins.mapAttrs
|
|
|
|
(zone: builtins.map (n: { ${n} = zone; }))
|
|
|
|
infra)));
|
|
|
|
|
|
|
|
###
|
|
|
|
# Add computed data about the nodes :
|
|
|
|
# - zone
|
|
|
|
# - deployment tags
|
|
|
|
# - network information
|
|
|
|
mkNode = node: attrs: attrs // {
|
|
|
|
zone = locations.${node};
|
|
|
|
deployment = let old = attrs.deployment; in old // {
|
|
|
|
tags = (old.tags or [ ]) ++ [ "infra-${locations.${node}}" ];
|
2023-07-20 15:48:01 +02:00
|
|
|
targetHost = old.targetHost or (builtins.head network.${node}.addresses.public);
|
2023-07-20 12:32:31 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
infra = import ./infrastructure.nix;
|
2023-05-22 15:06:11 +02:00
|
|
|
members = import ./members.nix;
|
2023-07-20 12:32:31 +02:00
|
|
|
network = import ./network.nix;
|
|
|
|
|
|
|
|
nodes = builtins.mapAttrs mkNode (import ./nodes.nix);
|
2023-05-22 15:06:11 +02:00
|
|
|
in
|
|
|
|
|
2023-07-20 12:32:31 +02:00
|
|
|
{ inherit infra members network nodes; }
|