(Un)Mounting chroot mounts, hosts manipulation update

This commit is contained in:
László Károlyi 2019-09-12 14:17:45 +02:00
parent 09e19a53a8
commit b2744a96cf
Signed by: karolyi
GPG Key ID: 2DCAF25E55735BFE
3 changed files with 18 additions and 26 deletions

View File

@ -1,3 +1,11 @@
- name: Unmounting directories
command:
/sbin/umount
-a -F
{{ dynamic_jails_path }}/configs/{{ vars["jail_" + jail_name + "_newest_id"] }}/fstab
args:
warn: no
- name: Unmounting devFS from chroot
mount:
path: '{{ vars["jail_" + jail_name + "_new_path"] }}/dev'

View File

@ -26,3 +26,11 @@
name: syslogd
state: restarted
- name: Mounting directories
command:
/sbin/mount
-a -F
{{ dynamic_jails_path }}/configs/{{ vars["jail_" + jail_name + "_newest_id"] }}/fstab
args:
warn: no

View File

@ -1,44 +1,20 @@
# IMPORTANT: after the IP that is 2 TABULATOR characters !
- name: Getting matching /etc/hosts files (IPv4)
command: >-
/bin/sh -c "/usr/bin/grep -lE
'^[0-9]+.[0-9]+.[0-9]+.[0-9]+ jail-{{ jail_name.replace("_", "-") }}'
/etc/hosts {{ static_jails_path }}/*/etc/hosts {{ dynamic_jails_path }}/*/etc/hosts"
ignore_errors: yes
failed_when: false
register: matching_hosts_files_v4
- name: Replacing appropriate jail names with new IP addresses in /etc/hosts files (IPv4)
lineinfile:
dest: '{{ filename }}'
dest: /etc/hosts
regexp: '^\d+\.\d+\.\d+\.\d+ jail-{{ jail_name.replace("_", "-") }}'
line: '{{ vars["jail_" + jail_name + "_new_ip4"] }} jail-{{ jail_name.replace("_", "-") }}'
state: present
with_items: '{{ matching_hosts_files_v4.stdout_lines }}'
loop_control:
loop_var: filename
- block:
# IMPORTANT: after the IP that is 2 TABULATOR characters !
- name: Getting matching /etc/hosts files (IPv6)
command: >-
/bin/sh -c "/usr/bin/grep -lE
'^[0-9a-f:]+ jail-{{ jail_name.replace("_", "-") }}'
/etc/hosts {{ static_jails_path }}/*/etc/hosts {{ dynamic_jails_path }}/*/etc/hosts"
ignore_errors: yes
failed_when: false
register: matching_hosts_files_v6
- name: Replacing appropriate jail names with new IP addresses in /etc/hosts files (IPv6)
lineinfile:
dest: '{{ filename }}'
dest: /etc/hosts
regexp: '^[0-9a-f:]+ jail-{{ jail_name.replace("_", "-") }}'
line: '{{ jail_THIS_with_ip6 }} jail-{{ jail_name.replace("_", "-") }}'
state: present
with_items: '{{ matching_hosts_files_v6.stdout_lines }}'
loop_control:
loop_var: filename
when: 'jail_THIS_with_ip6 != False'
- name: Sending HUP to any any crucial processes to reload their configuration