---
# tasks file for common
- name: set nameserver
  lineinfile:
    path: /etc/resolv.conf
    line: "nameserver {{ item.name }}"
  with_items:
    - "{{ common_nameservers }}"
  when:
    - common_nameservers is defined
    - ansible_virtualization_type != "docker" or common_ignore_docker
  notify:
    - gather facts

- name: flush handlers
  meta: flush_handlers

- name: set hostname
  hostname:
    name: "{{ inventory_hostname }}"
  when:
    - ansible_virtualization_type != "docker" or common_ignore_docker
  register: set_hostname

- name: reboot for hostname
  include_role:
    name: robertdebock.reboot
  when:
    - set_hostname.changed
    - common_reboot
  tags:
    - skip_ansible_lint

- name: fill /etc/hosts
  template:
    src: hosts.j2
    dest: /etc/hosts
  when:
    - ansible_virtualization_type != "docker" or common_ignore_docker
