36 lines
942 B
YAML
36 lines
942 B
YAML
- name: Install packages
|
|
community.general.pacman:
|
|
name:
|
|
- networkmanager
|
|
|
|
- name: Enable NetworkManager
|
|
service:
|
|
name: NetworkManager
|
|
enabled: yes
|
|
state: started
|
|
|
|
- name: Disable existing eth0 connection
|
|
community.general.nmcli:
|
|
conn_name: eth0
|
|
state: absent
|
|
register: networkmanager_config
|
|
|
|
- name: Set static IP address
|
|
community.general.nmcli:
|
|
dns4: "{{ dns_forward }}"
|
|
dns4_ignore_auto: yes
|
|
ip4: "{{ local_ip }}"
|
|
method4: manual
|
|
state: present
|
|
conn_name: wired
|
|
ifname: "{{ interface }}"
|
|
type: ethernet
|
|
when: networkmanager_config.changed
|
|
|
|
- name: Cronjob to remove externally managed eth0 connection
|
|
cron:
|
|
name: "Ensure eth0 is not externally managed"
|
|
minute: "*/10"
|
|
job: "/usr/bin/nmcli connection down eth0 > /dev/null 2>&1; /usr/bin/nmcli connection down wired > /dev/null 2>&1; /usr/bin/nmcli connection up wired > /dev/null"
|
|
state: present
|