---

- name: set_hostname modify /etc/hostname from datadir
  become: true
  tags: set_hostname
  copy:
    dest: /etc/hostname
    content: "{{ inventory_hostname }}\n"

- name: set_hostname modify /etc/hosts
  become: true
  tags: set_hostname
  replace:
    path: "/etc/hosts"
    regexp: '^127\.0\.1\.1\s+.+$'
    replace: "127.0.1.1\t{{ inventory_hostname }}.perfact.de\t{{ inventory_hostname }}"
    backup: true
