about summary refs log tree commit diff
path: root/nixos/tests/consul-template.nix
blob: cbffa94569e38b1062ed7991cb4ef00ae7255a5a (plain) (blame)
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
import ./make-test-python.nix ({ ... }: {
  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')
  '';
})