---
- name: Update /etc/hostname file
  when: is_debian_or_ubuntu
  action: lineinfile dest=/etc/hostname regexp=.* line={{inventory_hostname}} create=yes

- name: Update /etc/sysconfig/network file
  when: is_centos
  action: lineinfile dest=/etc/sysconfig/network regexp=^HOSTNAME= line=HOSTNAME={{inventory_hostname}}

- name: set hostname to current ansible name
  action: command hostname {{inventory_hostname}}
