refactor(configuration): split network.yml into per-init-system dispatch files
This commit is contained in:
25
roles/configuration/tasks/network_void.yml
Normal file
25
roles/configuration/tasks/network_void.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
- name: Write dhcpcd configuration
|
||||
vars:
|
||||
configuration_dns_list: "{{ system_cfg.network.dns.servers | default([]) }}"
|
||||
ansible.builtin.copy:
|
||||
dest: /mnt/etc/dhcpcd.conf
|
||||
mode: "0644"
|
||||
content: |
|
||||
{% for iface in system_cfg.network.interfaces %}
|
||||
{% set inv_name = iface.name | default('') | string %}
|
||||
{% set det_name = configuration_detected_interfaces[loop.index0] | default('eth' ~ loop.index0) %}
|
||||
{% set iface_name = inv_name if inv_name | length > 0 else det_name %}
|
||||
{% set has_static = (iface.ip | default('') | string | length) > 0 %}
|
||||
{% if has_static %}
|
||||
interface {{ iface_name }}
|
||||
static ip_address={{ iface.ip }}/{{ iface.prefix }}
|
||||
{% if iface.gateway | default('') | string | length %}
|
||||
static routers={{ iface.gateway }}
|
||||
{% endif %}
|
||||
{% if loop.index0 == 0 and configuration_dns_list | length > 0 %}
|
||||
static domain_name_servers={{ configuration_dns_list | join(' ') }}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
Reference in New Issue
Block a user