diff --git a/ansible/roles/hypervisor_qcow/templates/bond.netdev.j2 b/ansible/playbooks/templates/bond.netdev.j2 similarity index 100% rename from ansible/roles/hypervisor_qcow/templates/bond.netdev.j2 rename to ansible/playbooks/templates/bond.netdev.j2 diff --git a/ansible/roles/hypervisor_qcow/templates/bond.network.j2 b/ansible/playbooks/templates/bond.network.j2 similarity index 100% rename from ansible/roles/hypervisor_qcow/templates/bond.network.j2 rename to ansible/playbooks/templates/bond.network.j2 diff --git a/ansible/roles/hypervisor_qcow/templates/bridge.netdev.j2 b/ansible/playbooks/templates/bridge.netdev.j2 similarity index 59% rename from ansible/roles/hypervisor_qcow/templates/bridge.netdev.j2 rename to ansible/playbooks/templates/bridge.netdev.j2 index 72a8c15..96eb835 100644 --- a/ansible/roles/hypervisor_qcow/templates/bridge.netdev.j2 +++ b/ansible/playbooks/templates/bridge.netdev.j2 @@ -1,5 +1,5 @@ [NetDev] -Name=br0 +Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.netdev', '') }} Kind=bridge [Bridge] diff --git a/ansible/playbooks/templates/bridge.network.j2 b/ansible/playbooks/templates/bridge.network.j2 new file mode 100644 index 0000000..43718a5 --- /dev/null +++ b/ansible/playbooks/templates/bridge.network.j2 @@ -0,0 +1,11 @@ +[Match] +Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.netdev', '') }} + +[Link] +ARP={{ item.arp | default(false) }} + +[Network] +DHCP={{ item.dhcp | default(false) }} +LinkLocalAddressing=false +LLDP=true +VLAN={{ item.vlan }} \ No newline at end of file diff --git a/ansible/roles/hypervisor_qcow/templates/ethernet.link.j2 b/ansible/playbooks/templates/ethernet.link.j2 similarity index 99% rename from ansible/roles/hypervisor_qcow/templates/ethernet.link.j2 rename to ansible/playbooks/templates/ethernet.link.j2 index 8ad8415..898c099 100644 --- a/ansible/roles/hypervisor_qcow/templates/ethernet.link.j2 +++ b/ansible/playbooks/templates/ethernet.link.j2 @@ -1,6 +1,8 @@ [Match] PermanentMACAddress={{ item.mac_address }} + [Link] +Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.link', '') }} MACAddressPolicy=permanent MACAddress={{ item.mac_address }} -Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.link', '') }} + diff --git a/ansible/playbooks/templates/ethernet.network.j2 b/ansible/playbooks/templates/ethernet.network.j2 new file mode 100644 index 0000000..6132c8c --- /dev/null +++ b/ansible/playbooks/templates/ethernet.network.j2 @@ -0,0 +1,19 @@ +[Match] +MACAddress={{ item.mac_address }} + +[Link] +ARP={{ item.arp }} + +[Network] +DHCP={{ item.dhcp | default(true) }} +{% if item.bond %} +Bond={{ item.bond }} +{% endif %} +{% if item.bridge %} +Bridge={{ item.bridge }} +{% endif %} +{% if item.vlans %} +{% for vlan in item.vlans %} +VLAN={{ vlan }} +{% endfor %} +{% endif %} diff --git a/ansible/playbooks/templates/vlan.netdev.j2 b/ansible/playbooks/templates/vlan.netdev.j2 new file mode 100644 index 0000000..2688ade --- /dev/null +++ b/ansible/playbooks/templates/vlan.netdev.j2 @@ -0,0 +1,7 @@ +[NetDev] +Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.netdev', '') }} +Kind=vlan + +[VLAN] +Id={{ item.vlan_id }} +Protocol=802.1q diff --git a/ansible/playbooks/templates/vlan.network.j2 b/ansible/playbooks/templates/vlan.network.j2 new file mode 100644 index 0000000..b71dac4 --- /dev/null +++ b/ansible/playbooks/templates/vlan.network.j2 @@ -0,0 +1,44 @@ +[Match] +Name={{ item.name | regex_replace('^[0-9]*-', '') | regex_replace('\.netdev', '') }} + +[Link] +ARP={{ item.arp }} + +[Network] +{% if item.nameserver.ipv4 is defined %} +{% for nameserver in item.nameserver.ipv4 %} +DNS={{ nameserver }} +{% endfor %} +{% endif %} +{% if item.nameserver.ipv6 is defined %} +{% for nameserver in item.nameserver.ipv6 %} +DNS={{ nameserver }} +{% endfor %} +{% endif %} + +{% if item.address.ipv4 is defined %} +[Address] +Address={{ item.address.ipv4 }} +{% endif %} + +{% if item.address.ipv6 is defined %} +[Address] +Address={{ item.address.ipv6 }} +{% endif %} + +{% if item.gateway.ipv4 is defined %} +[Route] +Destination=0.0.0.0/0 +Gateway={{ item.gateway.ipv4 }} +Scope=global +Protocol=static +Type=unicast +{% endif %} + +{% if item.gateway.ipv6 is defined %} +[Route] +Destination=::/0 +Gateway={{ item.gateway.ipv4 }} +Protocol=static +Type=unicast +{% endif %} \ No newline at end of file diff --git a/ansible/roles/hypervisor_qcow/templates/bridge.network.j2 b/ansible/roles/hypervisor_qcow/templates/bridge.network.j2 deleted file mode 100644 index e69de29..0000000 diff --git a/ansible/roles/hypervisor_qcow/templates/ethernet.network.j2 b/ansible/roles/hypervisor_qcow/templates/ethernet.network.j2 deleted file mode 100644 index 4bad9ba..0000000 --- a/ansible/roles/hypervisor_qcow/templates/ethernet.network.j2 +++ /dev/null @@ -1,12 +0,0 @@ -[Match] -MACAddress={{ item.mac_address }} - -[Link] -ARP={{ item.arp }} - -[Network] -DHCP=no -if item.bond - Bond={{ item.bond }} -if item.bridge - Bridge={{ item.bridge }} diff --git a/ansible/roles/hypervisor_qcow/templates/vlan.netdev.j2 b/ansible/roles/hypervisor_qcow/templates/vlan.netdev.j2 deleted file mode 100644 index e69de29..0000000 diff --git a/ansible/roles/hypervisor_qcow/templates/vlan.network.j2 b/ansible/roles/hypervisor_qcow/templates/vlan.network.j2 deleted file mode 100644 index e69de29..0000000