2017-03-14 22:43:13 +01:00
|
|
|
|
|
|
|
# IMPORTANT: after the IP that is 2 TABULATOR character
|
|
|
|
- name: Getting matching /etc/hosts files
|
|
|
|
command: >-
|
|
|
|
/bin/sh -c "/usr/bin/grep -lE
|
|
|
|
'^[0-9]+.[0-9]+.[0-9]+.[0-9]+ jail_{{ jail_name }}'
|
|
|
|
/usr/jails/*/etc/hosts {{ dynamic_jails_path }}/*/etc/hosts"
|
|
|
|
ignore_errors: yes
|
|
|
|
failed_when: false
|
|
|
|
register: matching_hosts_files
|
|
|
|
|
|
|
|
- name: Replacing appropriate jail names with new IP addresses in /etc/hosts files
|
|
|
|
lineinfile:
|
|
|
|
dest: '{{ filename }}'
|
|
|
|
regexp: '^\d+\.\d+\.\d+\.\d+ jail_{{ jail_name }}'
|
|
|
|
line: '{{ vars["jail_" + jail_name + "_new_ip"] }} jail_{{ jail_name }}'
|
|
|
|
state: present
|
|
|
|
with_items: '{{ matching_hosts_files.stdout_lines }}'
|
|
|
|
loop_control:
|
|
|
|
loop_var: filename
|
2017-03-15 02:51:58 +01:00
|
|
|
|
|
|
|
- name: Sending HUP to any dnsmasq process to reload their /etc/hosts
|
|
|
|
command:
|
|
|
|
/usr/bin/killall -HUP dnsmasq
|
|
|
|
failed_when: false
|