add network configuration

This commit is contained in:
Alexander Couzens 2024-02-08 17:30:02 +01:00
parent c306d0002f
commit 4c98b913c2
9 changed files with 79 additions and 0 deletions

View File

@ -5,6 +5,15 @@
roles:
- name: common
- name: authorized_keys
- name: network
net_interface: eth1
net_ips:
- 10.74.0.21/24
- 10.74.0.22/24
- 10.74.0.23/24
- 10.74.0.24/24
net_method: networkd
- name: epc
epc_hss_bind_ip: 10.74.0.21
epc_pcrf_bind_ip: 10.74.0.22

View File

@ -5,6 +5,14 @@
roles:
- name: common
- name: authorized_keys
- name: network
net_interface: enp7s0
net_ips:
- 10.74.0.11/24
- 10.74.0.12/24
- 10.74.0.13/24
net_method: ifupdown
- name: epdg
epdg_ipsec_bind_ip: 213.95.46.81
epdg_swx_hss_ip: 10.74.0.21

View File

@ -13,7 +13,15 @@
- "hss.mnc070.mcc999.3gppnetwork.org 10.74.0.21"
# TODO: add network configuration
roles:
- name: common
- name: authorized_keys
- name: network
net_interface: eth1
net_ips:
- 10.74.0.31/24
- 10.74.0.32/24
- 10.74.0.33/24
net_method: ifupdown
- name: ims
ims_mcc: "901"

View File

@ -0,0 +1,9 @@
---
- name: ifup -a
command: ifup -a
- name: reload networkd
service:
name: systemd-networkd
state: reloaded

View File

@ -0,0 +1,12 @@
---
- name: ensure interfaces.d exists
file:
path: /etc/network/interfaces.d
state: directory
- name: configure network interface
template:
src: ifupdown.j2
dest: /etc/network/interfaces.d/ansible.conf
notify: ifup -a

View File

@ -0,0 +1,9 @@
---
- name: use network configuration ifupdown
ansible.builtin.include_tasks: "ifupdown.yml"
when: net_method == "ifupdown"
- name: use network configuration systemd-networkd
ansible.builtin.include_tasks: "networkd.yml"
when: net_method == "networkd"

View File

@ -0,0 +1,7 @@
---
- name: configure networkd
template:
src: networkd.network.j2
dest: /etc/systemd/network/ansible.network
notify: reload networkd

View File

@ -0,0 +1,8 @@
# {{ ansible_managed }}
{% for ip in net_ips %}
auto {{ net_interface }}:{{ loop.index }}
iface {{ net_interface }}:{{ loop.index }} inet static
address {{ ip }}
{% endfor %}

View File

@ -0,0 +1,9 @@
# {{ ansible_managed }}
[Match]
Name={{ net_interface }}
[Network]
{% for ip in net_ips %}
Address={{ ip }}
{% endfor %}