- name: Add the hostname lineinfile: path: /etc/hosts insertafter: '^# Ansible' regexp: "{{ etc_hosts_name }}$" line: "{{ etc_hosts_ip }} {{ etc_hosts_name }}" become: true notify: known_hosts changed_when: true delegate_to: localhost