summaryrefslogtreecommitdiffstats
path: root/nixos/tests/consul-template.nix
blob: 6720cd44e62929f83400ad3b55b5af0906925024 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{ ... }:
{
  name = "consul-template";

  nodes.machine =
    { ... }:
    {
      services.consul-template.instances.example.settings = {
        template = [
          {
            contents = ''
              {{ key "example" }}
            '';
            perms = "0600";
            destination = "/example";
          }
        ];
      };

      services.consul = {
        enable = true;
        extraConfig = {
          server = true;
          bootstrap_expect = 1;
          bind_addr = "127.0.0.1";
        };
      };
    };

  testScript = ''
    machine.wait_for_unit("consul.service")
    machine.wait_for_open_port(8500)

    machine.wait_for_unit("consul-template-example.service")

    machine.wait_until_succeeds('consul kv put example example')

    machine.wait_for_file("/example")
    machine.succeed('grep "example" /example')
  '';
}