From 09e19a53a88dfb26c9912e9c5766da846a2c95fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20K=C3=A1rolyi?= Date: Sun, 1 Sep 2019 17:12:05 +0200 Subject: [PATCH] Adding jail precreation chroot tools --- tasks/chroot/preinstall_reset.yml | 11 +++++++++++ tasks/chroot/preinstall_set.yml | 28 ++++++++++++++++++++++++++++ tasks/jail/create.yml | 1 + tasks/jail/main.yml | 5 ++++- tasks/jail/teardown.yml | 1 + tasks/jail/update_etc_hosts.yml | 1 + 6 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tasks/chroot/preinstall_reset.yml create mode 100644 tasks/chroot/preinstall_set.yml diff --git a/tasks/chroot/preinstall_reset.yml b/tasks/chroot/preinstall_reset.yml new file mode 100644 index 0000000..a2d00b3 --- /dev/null +++ b/tasks/chroot/preinstall_reset.yml @@ -0,0 +1,11 @@ +- name: Unmounting devFS from chroot + mount: + path: '{{ vars["jail_" + jail_name + "_new_path"] }}/dev' + state: unmounted + +- name: Create resolv.conf for live usage in jail + copy: + dest: '{{ vars["jail_" + jail_name + "_new_path"] }}/etc/resolv.conf' + content: | + nameserver {{ vars["jail_" + jail_name + "_new_ip4"] }} + diff --git a/tasks/chroot/preinstall_set.yml b/tasks/chroot/preinstall_set.yml new file mode 100644 index 0000000..7da6dec --- /dev/null +++ b/tasks/chroot/preinstall_set.yml @@ -0,0 +1,28 @@ +- name: Create local repo config dir + file: + path: '{{ vars["jail_" + jail_name + "_new_path"] }}/usr/local/etc/pkg/repos' + state: directory + +- name: Copy FreeBSD repo config in place + copy: + src: FreeBSD.conf + dest: '{{ vars["jail_" + jail_name + "_new_path"] }}/usr/local/etc/pkg/repos/FreeBSD.conf' + +- name: Create resolv.conf for install usage in jail + copy: + dest: '{{ vars["jail_" + jail_name + "_new_path"] }}/etc/resolv.conf' + content: | + nameserver 127.0.0.1 + +- name: Mounting devFS into chroot for pkg + mount: + src: devfs + path: '{{ vars["jail_" + jail_name + "_new_path"] }}/dev' + fstype: devfs + state: mounted + +- name: Restarting syslog + service: + name: syslogd + state: restarted + diff --git a/tasks/jail/create.yml b/tasks/jail/create.yml index d514c50..7e005da 100644 --- a/tasks/jail/create.yml +++ b/tasks/jail/create.yml @@ -104,3 +104,4 @@ ip6_addr = {{ jail_THIS_with_ip6 }} when: 'jail_THIS_with_ip6 != False' +# vim: sw=2 diff --git a/tasks/jail/main.yml b/tasks/jail/main.yml index cc69138..7ac0f02 100644 --- a/tasks/jail/main.yml +++ b/tasks/jail/main.yml @@ -83,6 +83,9 @@ loop_control: loop_var: jail_id + - name: Reload PF + command: /sbin/pfctl -f /etc/pf.conf + - name: Starting jail when IPv6 present command: jail -c @@ -102,4 +105,4 @@ loop_control: loop_var: jail_id - +# vim: sw=2 diff --git a/tasks/jail/teardown.yml b/tasks/jail/teardown.yml index f3e72ed..9b3207a 100644 --- a/tasks/jail/teardown.yml +++ b/tasks/jail/teardown.yml @@ -71,3 +71,4 @@ {{ dynamic_jails_path }}/{{ jail_id }} state: absent +# vim: sw=2 diff --git a/tasks/jail/update_etc_hosts.yml b/tasks/jail/update_etc_hosts.yml index 1902424..08cb6d0 100644 --- a/tasks/jail/update_etc_hosts.yml +++ b/tasks/jail/update_etc_hosts.yml @@ -51,3 +51,4 @@ name: syslogd state: restarted +# vim: sw=2