2017-03-14 22:43:13 +01:00
|
|
|
|
2018-10-03 19:00:29 +02:00
|
|
|
# IMPORTANT: after the IP that is 2 TABULATOR characters !
|
|
|
|
- name: Getting matching /etc/hosts files (IPv4)
|
2017-03-14 22:43:13 +01:00
|
|
|
command: >-
|
|
|
|
/bin/sh -c "/usr/bin/grep -lE
|
2019-01-08 19:09:11 +01:00
|
|
|
'^[0-9]+.[0-9]+.[0-9]+.[0-9]+ jail-{{ jail_name }}'
|
2018-10-03 19:00:29 +02:00
|
|
|
/etc/hosts {{ static_jails_path }}/*/etc/hosts {{ dynamic_jails_path }}/*/etc/hosts"
|
2017-03-14 22:43:13 +01:00
|
|
|
ignore_errors: yes
|
|
|
|
failed_when: false
|
2018-10-03 19:00:29 +02:00
|
|
|
register: matching_hosts_files_v4
|
2017-03-14 22:43:13 +01:00
|
|
|
|
2018-10-03 19:00:29 +02:00
|
|
|
- name: Replacing appropriate jail names with new IP addresses in /etc/hosts files (IPv4)
|
2017-03-14 22:43:13 +01:00
|
|
|
lineinfile:
|
|
|
|
dest: '{{ filename }}'
|
2019-01-08 19:09:11 +01:00
|
|
|
regexp: '^\d+\.\d+\.\d+\.\d+ jail-{{ jail_name }}'
|
|
|
|
line: '{{ vars["jail_" + jail_name + "_new_ip4"] }} jail-{{ jail_name }}'
|
2017-03-14 22:43:13 +01:00
|
|
|
state: present
|
2018-10-03 19:00:29 +02:00
|
|
|
with_items: '{{ matching_hosts_files_v4.stdout_lines }}'
|
2017-03-14 22:43:13 +01:00
|
|
|
loop_control:
|
|
|
|
loop_var: filename
|
2017-03-15 02:51:58 +01:00
|
|
|
|
2018-10-03 19:00:29 +02:00
|
|
|
- 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
|
2019-01-08 19:09:11 +01:00
|
|
|
'^[0-9a-f:]+ jail-{{ jail_name }}'
|
2018-10-03 19:00:29 +02:00
|
|
|
/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 }}'
|
2019-01-08 19:09:11 +01:00
|
|
|
regexp: '^[0-9a-f:]+ jail-{{ jail_name }}'
|
|
|
|
line: '{{ jail_THIS_with_ip6 }} jail-{{ jail_name }}'
|
2018-10-03 19:00:29 +02:00
|
|
|
state: present
|
|
|
|
with_items: '{{ matching_hosts_files_v6.stdout_lines }}'
|
|
|
|
loop_control:
|
|
|
|
loop_var: filename
|
|
|
|
when: 'jail_THIS_with_ip6 != False'
|
|
|
|
|
2017-04-22 14:27:37 +02:00
|
|
|
- name: Sending HUP to any any crucial processes to reload their /etc/hosts
|
2017-03-15 02:51:58 +01:00
|
|
|
command:
|
2017-05-14 16:20:03 +02:00
|
|
|
/usr/bin/killall -HUP dnsmasq syslogd nginx
|
2017-03-15 02:51:58 +01:00
|
|
|
failed_when: false
|