---
- name: Set the hostname in /etc/hostname
  shell: echo {{ vagrant_local.vm.hostname }} > /etc/hostname
  when: vagrant_local.vm.hostname is defined

- name: Set the hostname
  shell: hostname {{ vagrant_local.vm.hostname }}
  when: vagrant_local.vm.hostname is defined

- name: Update /etc/hosts
  lineinfile: dest=/etc/hosts regexp='^127\.0\.0\.1' line='127.0.0.1 localhost {{ vagrant_local.vm.hostname|default('') }}' owner=root group=root mode=0644
  when: vagrant_local.vm.hostname is defined

- include: docker-hosts-container.yml