39 lines
1.1 KiB
YAML
39 lines
1.1 KiB
YAML
---
|
|
- name: Read network interfaces
|
|
ansible.builtin.command:
|
|
argv:
|
|
- ip
|
|
- -o
|
|
- link
|
|
- show
|
|
register: configuration_ip_link
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Detect available network interface names
|
|
vars:
|
|
configuration_detected_interfaces: >-
|
|
{{
|
|
configuration_ip_link.stdout
|
|
| default('')
|
|
| regex_findall('^[0-9]+: ([^:]+):', multiline=True)
|
|
| reject('equalto', 'lo')
|
|
| list
|
|
}}
|
|
ansible.builtin.set_fact:
|
|
configuration_detected_interfaces: "{{ configuration_detected_interfaces }}"
|
|
|
|
- name: Validate at least one network interface detected
|
|
ansible.builtin.assert:
|
|
that:
|
|
- configuration_detected_interfaces | length > 0
|
|
fail_msg: Failed to detect any network interfaces.
|
|
|
|
- name: Set DNS configuration facts
|
|
ansible.builtin.set_fact:
|
|
configuration_dns_list: "{{ system_cfg.network.dns.servers }}"
|
|
configuration_dns_search: "{{ system_cfg.network.dns.search }}"
|
|
|
|
- name: Configure networking
|
|
ansible.builtin.include_tasks: "{{ configuration_network_task_map[os] | default('network_nm.yml') }}"
|