aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/jails_single.yml
blob: 043086d043932f937c1ca3b556df528bcae7c0a5 (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
- name: "Check if jail directory for {{ jail.name }} exists"
  shell: zfs list -o name | grep -Fxq "zroot/jails/containers/{{ jail.name }}"
  failed_when: false
  changed_when: false
  register: check_jail_directory

- name: "ZFS clone snapshot to jail directory for {{ jail.name }}"
  shell: zfs clone zroot/jails/templates/{{ jail_userland_version }}@base "zroot/jails/containers/{{ jail.name }}"
  when: check_jail_directory.rc != 0

- name: Make resolv.conf immutable
  shell: chflags schg /usr/local/jails/containers/{{ jail.name }}/etc/resolv.conf

- name: Configure jail.conf.d/{{ jail.name }}.conf
  template:
    src: etc_jail.conf.d_[jailname].conf.j2
    dest: /etc/jail.conf.d/{{ jail.name }}.conf
    owner: root
    group: wheel
    mode: "0644"

- name: "Check if jail {{ jail.name }} is running"
  shell: jls -j "{{ jail.name }}"
  failed_when: false
  changed_when: false
  register: check_jail_active

- name: "(Re)start jail {{ jail.name }}"
  shell: service jail restart "{{ jail.name }}"
  when: check_jail_active.rc != 0