aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/project/create_jail.yaml
diff options
context:
space:
mode:
authorPanu Oksiala <panu@oksiala.fi>2024-01-22 00:24:37 +0200
committerPanu Oksiala <panu@oksiala.fi>2024-01-22 00:24:37 +0200
commit73c1115e6fba24b86eca1e5cad5f5086d6bd2ba6 (patch)
treedaedbc44f41c91a13cb7fc26edd325ab14996217 /ansible/project/create_jail.yaml
Initial commit
Diffstat (limited to 'ansible/project/create_jail.yaml')
-rw-r--r--ansible/project/create_jail.yaml52
1 files changed, 52 insertions, 0 deletions
diff --git a/ansible/project/create_jail.yaml b/ansible/project/create_jail.yaml
new file mode 100644
index 0000000..77db9a8
--- /dev/null
+++ b/ansible/project/create_jail.yaml
@@ -0,0 +1,52 @@
+- hosts: "bsd_servers"
+ tasks:
+ - name: init jail
+ become: true
+ when: inventory_hostname == jail_host
+ block:
+ - name: wipe jail directory
+ ansible.builtin.file:
+ path: "{{ containers_path }}/{{ jail_name }}"
+ state: absent
+
+ - name: Create directory for jail
+ ansible.builtin.file:
+ path: "{{ containers_path }}/{{ jail_name }}"
+ state: directory
+ owner: root
+ group: wheel
+ mode: 0750
+
+ - name: extract base files to jail
+ ansible.builtin.unarchive:
+ src: "{{ media_path }}/14.0-RELEASE-base.txz"
+ dest: "{{ containers_path }}/{{ jail_name }}/"
+ remote_src: yes
+ extra_opts:
+ - "--unlink"
+
+ - name: copy resolv.conf to jail
+ ansible.builtin.copy:
+ remote_src: yes
+ src: /etc/resolv.conf
+ dest: "{{ containers_path }}/{{ jail_name }}/etc/resolv.conf"
+
+ - name: copy localtime to jail
+ ansible.builtin.copy:
+ remote_src: yes
+ src: /etc/localtime
+ dest: "{{ containers_path }}/{{ jail_name }}/etc/localtime"
+
+ - name: update to latest patch version
+ ansible.builtin.shell: freebsd-update -b {{ containers_path }}/{{ jail_name }}/ fetch install
+
+ - name: Create config file for jail
+ ansible.builtin.template:
+ src: templates/jail.conf.j2
+ dest: "/etc/jail.conf.d/{{ jail_name }}.conf"
+ owner: root
+ group: wheel
+ mode: 0644
+
+ - name: start jail
+ ansible.builtin.shell: service jail start {{ jail_name }}