---
# - name: Edit grub defaults config
#   lineinfile:
#     path: /etc/default/grub
#     regexp: '^GRUB_CMDLINE_LINUX='
#     line: GRUB_CMDLINE_LINUX="resume=/dev/mapper/lv-swap rd.lvm.lv=lv/root rd.lvm.lv=lv/swap net.ifnames=0 biosdevname=0"

# - name: update grub config
#   shell: grub2-mkconfig -o /boot/grub2/grub.cfg

# - name: Set static IP
#   nmcli:
#     conn_name: eth0
#     ifname: eth0
#     type: ethernet
#     ip4: '{{ ip4_addr }}'
#     gw4: '{{ ip4_gate }}'
#     dns4: '{{ ip4_dns }}'
#     state: present
#     autoconnect: yes

- name: Create /etc/systemd/network dir
  ansible.builtin.file:
    path: /etc/systemd/network
    state: directory
    owner: root
    group: root
    mode: "0755"

- name: Rename NIC to eth0
  ansible.builtin.template:
    src: 70-eth0.link.j2
    dest: /etc/systemd/network/70-eth0.link
    owner: root
    group: root
    mode: "0644"

- name: Set network connection
  community.general.nmcli:
    conn_name: eth0
    ifname: eth0
    type: ethernet
    mac: "{{ ansible_default_ipv4.macaddress }}"
    method4: auto
    method6: disabled
    state: present

# - name: MAC Address
#   debug: msg="{{ ansible_default_ipv4.macaddress }}"
