1{ lib }:
2
3with lib;
4{
5 options = {
6
7 interface = mkOption {
8 type = types.str;
9 description = ''
10 Interface for inside_network, bound by vrrp.
11 '';
12 };
13
14 state = mkOption {
15 type = types.enum [
16 "MASTER"
17 "BACKUP"
18 ];
19 default = "BACKUP";
20 description = ''
21 Initial state. As soon as the other machine(s) come up, an election will
22 be held and the machine with the highest "priority" will become MASTER.
23 So the entry here doesn't matter a whole lot.
24 '';
25 };
26
27 virtualRouterId = mkOption {
28 type = types.ints.between 1 255;
29 description = ''
30 Arbitrary unique number 1..255. Used to differentiate multiple instances
31 of vrrpd running on the same NIC (and hence same socket).
32 '';
33 };
34
35 priority = mkOption {
36 type = types.int;
37 default = 100;
38 description = ''
39 For electing MASTER, highest priority wins. To be MASTER, make 50 more
40 than other machines.
41 '';
42 };
43
44 noPreempt = mkOption {
45 type = types.bool;
46 default = false;
47 description = ''
48 VRRP will normally preempt a lower priority machine when a higher
49 priority machine comes online. "nopreempt" allows the lower priority
50 machine to maintain the master role, even when a higher priority machine
51 comes back online. NOTE: For this to work, the initial state of this
52 entry must be BACKUP.
53 '';
54 };
55
56 useVmac = mkOption {
57 type = types.bool;
58 default = false;
59 description = ''
60 Use VRRP Virtual MAC.
61 '';
62 };
63
64 vmacInterface = mkOption {
65 type = types.nullOr types.str;
66 default = null;
67 description = ''
68 Name of the vmac interface to use. keepalived will come up with a name
69 if you don't specify one.
70 '';
71 };
72
73 vmacXmitBase = mkOption {
74 type = types.bool;
75 default = false;
76 description = ''
77 Send/Recv VRRP messages from base interface instead of VMAC interface.
78 '';
79 };
80
81 unicastSrcIp = mkOption {
82 type = types.nullOr types.str;
83 default = null;
84 description = ''
85 Default IP for binding vrrpd is the primary IP on interface. If you
86 want to hide location of vrrpd, use this IP as src_addr for unicast
87 vrrp packets.
88 '';
89 };
90
91 unicastPeers = mkOption {
92 type = types.listOf types.str;
93 default = [ ];
94 description = ''
95 Do not send VRRP adverts over VRRP multicast group. Instead it sends
96 adverts to the following list of ip addresses using unicast design
97 fashion. It can be cool to use VRRP FSM and features in a networking
98 environment where multicast is not supported! IP Addresses specified can
99 IPv4 as well as IPv6.
100 '';
101 };
102
103 virtualIps = mkOption {
104 type = types.listOf (
105 types.submodule (
106 import ./virtual-ip-options.nix {
107 inherit lib;
108 }
109 )
110 );
111 default = [ ];
112 # TODO: example
113 description = "Declarative vhost config";
114 };
115
116 trackScripts = mkOption {
117 type = types.listOf types.str;
118 default = [ ];
119 example = [
120 "chk_cmd1"
121 "chk_cmd2"
122 ];
123 description = "List of script names to invoke for health tracking.";
124 };
125
126 trackInterfaces = mkOption {
127 type = types.listOf types.str;
128 default = [ ];
129 example = [
130 "eth0"
131 "eth1"
132 ];
133 description = "List of network interfaces to monitor for health tracking.";
134 };
135
136 extraConfig = mkOption {
137 type = types.lines;
138 default = "";
139 description = ''
140 Extra lines to be added verbatim to the vrrp_instance section.
141 '';
142 };
143
144 };
145
146}