Commit bf92d0ec authored by Joe DeVivo's avatar Joe DeVivo Committed by Cole Helbling
Browse files

nixos/ssm-agent: conf files written to /etc

ssm-agent expects files in /etc/amazon/ssm. The pkg substitutes a location in
the nix store for those default files, but if we ever want to adjust this
configuration on NixOS, we'd need the ability to modify that file.

This change to the nixos module writes copies of the default files from the nix
store to /etc/amazon/ssm. Future versions can add config, but right now this
would allow users to at least write out a text value to
environment.etc."amazon/ssm/amazon-ssm-agent.json".text to provide
their own config.
parent 27b4fd19
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -22,8 +22,8 @@ in {
    package = mkOption {
      type = types.path;
      description = "The SSM agent package to use";
      default = pkgs.ssm-agent;
      defaultText = "pkgs.ssm-agent";
      default = pkgs.ssm-agent.override { overrideEtc = false; };
      defaultText = "pkgs.ssm-agent.override { overrideEtc = false; }";
    };
  };

@@ -37,8 +37,10 @@ in {
      serviceConfig = {
        ExecStart = "${cfg.package}/bin/amazon-ssm-agent";
        KillMode = "process";
        Restart = "on-failure";
        RestartSec = "15min";
        # We want this restating pretty frequently. It could be our only means
        # of accessing the instance.
        Restart = "always";
        RestartSec = "1min";
      };
    };

@@ -62,5 +64,10 @@ in {
      isNormalUser = true;
      group = "ssm-user";
    };

    environment.etc."amazon/ssm/seelog.xml".source = "${cfg.package}/seelog.xml.template";

    environment.etc."amazon/ssm/amazon-ssm-agent.json".source =  "${cfg.package}/etc/amazon/ssm/amazon-ssm-agent.json.template";

  };
}
+4 −3
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
, dmidecode
, util-linux
, bashInteractive
, overrideEtc ? true
}:

let
@@ -63,10 +64,10 @@ buildGoPackage rec {
    substituteInPlace agent/session/shell/shell_unix.go \
        --replace '"script"' '"${util-linux}/bin/script"'

    echo "${version}" > VERSION
  '' + lib.optionalString overrideEtc ''
    substituteInPlace agent/appconfig/constants_unix.go \
      --replace '"/etc/amazon/ssm/"' '"${placeholder "out"}/etc/amazon/ssm/"'

    echo "${version}" > VERSION
  '';

  preBuild = ''