Skip to content

Instantly share code, notes, and snippets.

@polynomial
Created October 5, 2015 16:50
Show Gist options
  • Save polynomial/7f3ea09e27b422e9aea8 to your computer and use it in GitHub Desktop.
Save polynomial/7f3ea09e27b422e9aea8 to your computer and use it in GitHub Desktop.
Nixops Merge Firewall Ports
{ pkgs
, consulHttpPort ? 8500
, consulDnsPort ? 8600
, consulServerPort ? 8300
, consulSerfLanPort ? 8301
, consulSerfWanPort ? 8302
, consulRpcPort ? 8400
, consulServer ? true
, consulBootstrapExpect ? 1
, consulDomain ? "consul"
, consulWebUiEnable ? false
, consulClientAddress ? "127.0.0.1"
, consulStatsdAddress ? "127.0.0.1:8125"
, consulStartJoinList ? [ "127.0.0.1" ]
, lookout
, ...}:
{
networking.firewall.enable = true;
networking.firewall.allowedTCPPorts = [
consulHttpPort
consulDnsPort
consulServerPort
consulSerfLanPort
consulSerfWanPort
consulRpcPort
];
services.consul.enable = true;
services.consul.webUi = consulWebUiEnable;
services.consul.extraConfig = {
server = consulServer;
bootstrap_expect = consulBootstrapExpect;
statsd_addr = consulStatsdAddress;
encrypt = consulEncryptionKey;
client_addr = consulClientAddress;
start_join = consulStartJoinList;
log_level = consulLogLevel;
datacenter = "${envType}-${envTag}";
domain = "${consulDomain}";
};
}
{ pkgs
, num ? "1"
, ...}:
let
<snip>
in
{
networking.firewall.allowedTCPPorts = [ 3306 ];
services.mysql.enable = true;
services.mysql.package = percona;
services.mysql.replication.role = "master";
services.mysql.replication.serverId = num;
}
{ pkgs
, mkTargetConfig
, subnets
, ...}:
let
consulConf = import ../../node/consul.nix {
inherit pkgs;
consulBootstrapExpect = 0;
consulServer = false;
consulDomain = domain;
consulStartJoinList = [ "consul.${envType}.${domain}" ];
};
mysqlMasterConf = import ../../node/mysql.nix {
inherit pkgs;
};
mysqlNodeCfg =
{ pkgs, lib, resources, num, subnetId, ... }:
let
baseConf = import ../../node/base.nix {
inherit pkgs lookout hostName allowedTcpPorts;
};
finalConf = lib.foldl lib.recursiveUpdate baseConf [mysqlConf consulConf];
in
{
} // finalConf;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment