38 lines
1.0 KiB
YAML
38 lines
1.0 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: Configure networking
|
|
vars:
|
|
configuration_network_task_map:
|
|
alpine: network_alpine.yml
|
|
void: network_void.yml
|
|
ansible.builtin.include_tasks: "{{ configuration_network_task_map[os] | default('network_nm.yml') }}"
|