aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/jails_single.yml
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-10-06 11:54:41 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-10-06 11:54:41 +0300
commit3f9b16b010aef1201e6ac8fa8174ccbecc7de51c (patch)
tree8788f8002a4f6776c1c15614e12c7ee0c28d36dc /tasks/jails_single.yml
parent5adcc04e4c3441de8258b29216411bb53a709c0f (diff)
Refactor to use tags
Diffstat (limited to 'tasks/jails_single.yml')
-rw-r--r--tasks/jails_single.yml22
1 files changed, 22 insertions, 0 deletions
diff --git a/tasks/jails_single.yml b/tasks/jails_single.yml
new file mode 100644
index 0000000..9d539d0
--- /dev/null
+++ b/tasks/jails_single.yml
@@ -0,0 +1,22 @@
+- 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: "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