Skip to content

Commit

Permalink
Add smash role, deployed for FF.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbgi authored and johnalotoski committed Jul 1, 2020
1 parent b3e2e6b commit e55d86f
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
15 changes: 15 additions & 0 deletions clusters/cardano.nix
Expand Up @@ -136,6 +136,21 @@ let
org = "IOHK";
};
} def;
})// (lib.optionalAttrs globals.withSmash {
smash = let def = (topology.smash or {}); in mkNode {
deployment.ec2 = {
region = "eu-central-1";
};
imports = [
medium
cardano-ops.roles.smash
];
node = {
roles.isExplorer = true;
nodeId = def.nodeId or 100;
org = "IOHK";
};
} def;
});

nodes = cardanoNodes // otherNodes;
Expand Down
1 change: 1 addition & 0 deletions globals-defaults.nix
Expand Up @@ -32,6 +32,7 @@ in {
withCardanoDBExtended = true;
withFaucet = false;
withFaucetOptions = {};
withSmash = false;

initialPythonExplorerDBSyncDone = false;

Expand Down
1 change: 1 addition & 0 deletions globals-ff.nix
Expand Up @@ -7,6 +7,7 @@ pkgs: {
withExplorer = false;
withLegacyExplorer = false;
withHighLoadRelays = true;
withSmash = true;

withFaucet = true;
faucetHostname = "faucet";
Expand Down
12 changes: 12 additions & 0 deletions nix/sources.json
Expand Up @@ -178,5 +178,17 @@
"type": "tarball",
"url": "https://github.com/input-output-hk/ops-lib/archive/a13920e3ddc442f7bfed7d000d22b11e8e2cde18.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"smash": {
"branch": "ksaric/CAD-779",
"description": "Stakepool Metadata Aggregation Server",
"homepage": null,
"owner": "input-output-hk",
"repo": "smash",
"rev": "4b7ed5337e5cee2dad11df7e3d8278b409c53922",
"sha256": "0jhsklcvyax629zc42mji48bd03lwxmv6pyxbs1nl7l66brgnjbs",
"type": "tarball",
"url": "https://github.com/input-output-hk/smash/archive/4b7ed5337e5cee2dad11df7e3d8278b409c53922.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
92 changes: 92 additions & 0 deletions roles/smash.nix
@@ -0,0 +1,92 @@
pkgs: with pkgs; { nodes, name, config, ... }:
let
nodeCfg = config.services.cardano-node;
dbSyncCfg = config.services.cardano-db-sync;
hostAddr = getListenIp nodes.${name};
in {
environment = {
systemPackages = [
bat fd lsof netcat ncdu ripgrep tree vim cardano-cli
cardano-db-sync-pkgs.haskellPackages.cardano-db.components.exes.cardano-db-tool
];
variables = {
PGPASSFILE = config.services.cardano-db-sync.pgpass;
};
};
imports = [
cardano-ops.modules.base-service
cardano-ops.modules.cardano-postgres
(sourcePaths.cardano-db-sync + "/nix/nixos")
(sourcePaths.smash+ "/nix/nixos")
];
services.cardano-node.producers = [ globals.relaysNew ];
services.cardano-db-sync = {
enable = true;
cluster = globals.environmentName;
environment = globals.environmentConfig;
socketPath = nodeCfg.socketPath;
logConfig = iohkNix.cardanoLib.defaultExplorerLogConfig // { hasPrometheus = [ hostAddr 12698 ]; };
extended = globals.withCardanoDBExtended;
package = if globals.withCardanoDBExtended
then cardano-db-sync-pkgs.cardano-db-sync-extended
else cardano-db-sync-pkgs.cardano-db-sync;
};
services.smash.enable = true;
services.cardano-postgres.enable = true;
services.postgresql = {
ensureDatabases = [ "${dbSyncCfg.user}" ];
ensureUsers = [
{
name = "${dbSyncCfg.user}";
ensurePermissions = {
"DATABASE ${dbSyncCfg.user}" = "ALL PRIVILEGES";
};
}
];
identMap = ''
cdbsync-users root ${dbSyncCfg.user}
cdbsync-users smash ${dbSyncCfg.user}
cdbsync-users ${dbSyncCfg.user} ${dbSyncCfg.user}
cdbsync-users postgres postgres
'';
authentication = ''
local all all ident map=cdbsync-users
'';
};
security.acme = lib.mkIf (config.deployment.targetEnv != "libvirtd") {
email = "devops@iohk.io";
acceptTerms = true; # https://letsencrypt.org/repository/
};
networking.firewall.allowedTCPPorts = [ 80 443 ];
services.nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
commonHttpConfig = ''
log_format x-fwd '$remote_addr - $remote_user [$time_local] '
'"$request" "$http_accept_language" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
access_log syslog:server=unix:/dev/log x-fwd;
'';
virtualHosts = {
"smash.${globals.domain}" = {
enableACME = true;
forceSSL = globals.explorerForceSSL;
locations = {
"/api" = {
proxyPass = "http://127.0.0.1:3100/api";
};
};
};
"smash-ip" = {
locations = {
"/metrics2/exporter" = {
proxyPass = "http://127.0.0.1:8080/";
};
};
};
};
};
}

0 comments on commit e55d86f

Please sign in to comment.