# IMPORTANT: after the IP that is 2 TABULATOR characters ! - name: Replacing appropriate jail names with new IP addresses in /etc/hosts files (IPv4) lineinfile: 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 - block: # IMPORTANT: after the IP that is 2 TABULATOR characters ! - name: Replacing appropriate jail names with new IP addresses in /etc/hosts files (IPv6) lineinfile: dest: /etc/hosts regexp: '^[0-9a-f:]+ jail-{{ jail_name.replace("_", "-") }}' line: '{{ jail_THIS_with_ip6 }} jail-{{ jail_name.replace("_", "-") }}' state: present when: 'jail_THIS_with_ip6 != False' - name: Sending HUP to any any crucial processes to reload their configuration ansible.builtin.command: /usr/bin/killall -HUP dnsmasq failed_when: false - name: Restarting syslog to put its log socket into the new jail service: name: syslogd state: restarted # vim: sw=2