aboutsummaryrefslogtreecommitdiffstats
path: root/roles/jail/templates/jail_conf.j2
blob: d8e06679a7e5f1b40bec889ca2238c45b1005329 (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
42
43
44
45
46
47
48
49
50
{{ jail.name }} {
  vnet;
  exec.clean;
  allow.raw_sockets;

  mount.devfs;      # Mount /dev according to devfs_ruleset
  devfs_ruleset = {{ jail.devfs_ruleset }};

  enforce_statfs = 1; # Let jail see own mounts
{% for opt in jail.options %}
  {{ opt }};
{% endfor %}

  host.hostname = "${name}";
  path = "/usr/local/jails/containers/${name}";

  exec.start = "/bin/sh /etc/rc";
  exec.stop  = "/bin/sh /etc/rc.shutdown";

  # Networking
  exec.prestart  += "jail_net prestart  ${name} {{ jail.num }} {{ jail.ip }}";
  exec.poststart += "jail_net poststart ${name} {{ jail.num }} {{ jail.ip }}";
  exec.prestop   += "jail_net prestop   ${name} {{ jail.num }} {{ jail.ip }}";
  exec.poststop  += "jail_net poststop  ${name} {{ jail.num }} {{ jail.ip }}";

  # Custom hooks
{% for cmd in jail.exec_prestart %}
  exec.prestart  += "{{ cmd }}";
{% endfor %}
{% for cmd in jail.exec_start %}
  exec.start     += "{{ cmd }}";
{% endfor %}
{% for cmd in jail.exec_poststart %}
  exec.poststart += "{{ cmd }}";
{% endfor %}
{% for cmd in jail.exec_prestop %}
  exec.prestop   += "{{ cmd }}";
{% endfor %}
{% for cmd in jail.exec_stop %}
  exec.stop      += "{{ cmd }}";
{% endfor %}
{% for cmd in jail.exec_poststop %}
  exec.poststop  += "{{ cmd }}";
{% endfor %}

  # nullfs mounts
{% for mount in jail.nullfs %}
  mount += "{{ mount.src }}  ${path}{{ mount.dst }}  nullfs  {{ mount.mode | default('rw') }}  0  0";
{% endfor %}
}