# this (hosts.yml) WAS invoked by roles/network/tasks/main.yml up until 2019-12-10

#TODO: Use vars instead of hardcoded values
- name: Remove FQDN with 172.18.96.1 in /etc/hosts without LAN (if iiab_lan_iface == "none" and not installing)
  lineinfile:
    path: /etc/hosts
    regexp: '^172\.18\.96\.1'
    state: absent
  when: iiab_lan_iface == "none" and not installing

- name: Configure FQDN with 172.18.96.1 in /etc/hosts with LAN (if iiab_lan_iface != "none" and not installing)
  lineinfile:
    path: /etc/hosts
    regexp: '^172\.18\.96\.1'
    line: '172.18.96.1     {{ iiab_hostname }}.{{ iiab_domain }} {{ iiab_hostname }} box box.lan'
    state: present
  when: not (iiab_lan_iface == "none") and not installing

# roles/0-init/tasks/hostname.yml ALSO does this:
- name: 'Put FQDN & hostnames in /etc/hosts: "127.0.0.1 {{ iiab_hostname }}.{{ iiab_domain }} localhost.localdomain localhost {{ iiab_hostname }} box box.lan" (if iiab_lan_iface == "none" and not installing, appliance mode?)'
  lineinfile:
    path: /etc/hosts
    regexp: '^127\.0\.0\.1'
    line: '127.0.0.1     {{ iiab_hostname }}.{{ iiab_domain }} localhost.localdomain localhost {{ iiab_hostname }} box box.lan'
    owner: root
    group: root
    mode: 0644
  when: iiab_lan_iface == "none" and not installing
