network configuration for ubuntu
parent
d6f55bff2e
commit
9aec5310fc
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
ansible_host: "vm5"
|
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
interfaces:
|
||||||
|
enp0s3:
|
||||||
|
ipv4: 10.0.2.9
|
||||||
|
netmaskv4: 24
|
||||||
|
type: static
|
||||||
|
gateway: 10.0.2.1
|
||||||
|
|
||||||
|
ipv4_forwarding: false
|
||||||
|
ipv6_forwarding: false
|
@ -0,0 +1,32 @@
|
|||||||
|
{{ ansible_managed | comment }}
|
||||||
|
|
||||||
|
network:
|
||||||
|
ethernets:
|
||||||
|
{% for item in lookup('dict', interfaces, wantlist=True) %}
|
||||||
|
{% if item.value.type not in ['wireguard', ] %}
|
||||||
|
{{ item.key }}:
|
||||||
|
{% if item.value.type == 'dhcp' %}
|
||||||
|
dhcp4: true
|
||||||
|
{% elif item.value.type == 'static' %}
|
||||||
|
dhcp4: false
|
||||||
|
addresses:
|
||||||
|
- {{ item.value.ipv4 }}/{{ item.value.netmaskv4 }}
|
||||||
|
{% if 'gateway' in item.value %}
|
||||||
|
gateway4: {{ item.value.gateway }}
|
||||||
|
{% endif %}
|
||||||
|
nameservers:
|
||||||
|
addresses:
|
||||||
|
- 1.1.1.1
|
||||||
|
{# the nameservers are hardcoded for now #}
|
||||||
|
{% endif %}{# end (type == *) #}
|
||||||
|
{% if 'routes' in item.value %}{# routes #}
|
||||||
|
routes:
|
||||||
|
{% for route in item.value.routes %}
|
||||||
|
- to: {{ route.subnet }}/{{ route.netmask }}
|
||||||
|
via: {{ route.gateway }}
|
||||||
|
metric: 100
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}{# end routes #}
|
||||||
|
{% endif %}{# end (not in [wireguard, ]) #}
|
||||||
|
{% endfor %}
|
||||||
|
version: 2
|
Loading…
Reference in New Issue