1{ ... }:
2{
3 name = "consul-template";
4
5 nodes.machine =
6 { ... }:
7 {
8 services.consul-template.instances.example.settings = {
9 template = [
10 {
11 contents = ''
12 {{ key "example" }}
13 '';
14 perms = "0600";
15 destination = "/example";
16 }
17 ];
18 };
19
20 services.consul = {
21 enable = true;
22 extraConfig = {
23 server = true;
24 bootstrap_expect = 1;
25 bind_addr = "127.0.0.1";
26 };
27 };
28 };
29
30 testScript = ''
31 machine.wait_for_unit("consul.service")
32 machine.wait_for_open_port(8500)
33
34 machine.wait_for_unit("consul-template-example.service")
35
36 machine.wait_until_succeeds('consul kv put example example')
37
38 machine.wait_for_file("/example")
39 machine.succeed('grep "example" /example')
40 '';
41}