- name: Set the hostname hostname: name: "{{ inventory_hostname_short }}" use: debian - name: Populating hosts file with hostname lineinfile: path: /etc/hosts regexp: '^127\.0\.1\.1' line: '127.0.1.1 {{ hostname_fqdn }} {{ inventory_hostname_short }}'