[interfaces] Configure switch interface

certbot_on_virtu
_benjamin 2020-04-21 16:50:16 +02:00 committed by Bombar Maxime
parent bc8430b1e5
commit 9027b42b33
3 changed files with 46 additions and 1 deletions

View File

@ -15,6 +15,9 @@
- shell: grep borne /sys/class/net/*/ifalias | sed "s|/sys/class/net/||" | sed "s|/ifalias:.*||"
register: borne_iface
check_mode: no
- shell: grep switch /sys/class/net/*/ifalias | sed "s|/sys/class/net/||" | sed "s|/ifalias:.*||"
register: switch_iface
check_mode: no
- shell: grep fil /sys/class/net/*/ifalias | sed "s|/sys/class/net/||" | sed "s|/ifalias:.*||"
register: fil_iface
check_mode: no
@ -29,7 +32,8 @@
- ens_gateway: 138.231.136.254
- ens_dns: 138.231.136.152 138.231.136.4
- adm_dns: 10.231.136.152 10.231.136.4
- borne_dns: 10.231.148.4
- borne_dns: 10.231.148.52 10.231.148.4
- switch_dns: 10.231.100.152 10.231.100.4
- fil_gateway: 10.54.0.254
- fil_dns: 10.54.0.152 10.54.0.4
- adh_gateway: 185.230.78.254

View File

@ -33,6 +33,13 @@
mode: 0644
when: borne_iface.stdout
- name: Deploy switch interface config
template:
src: network/interfaces.d/04-switch.j2
dest: /etc/network/interfaces.d/04-switch
mode: 0644
when: switch_iface.stdout
- name: Deploy fil interface config
template:
src: network/interfaces.d/21-fil.j2

View File

@ -0,0 +1,34 @@
{{ ansible_header | comment }}
{% set switch = hostvars[inventory_hostname]['ansible_' + switch_iface.stdout] %}
allow-hotplug {{ switch_iface.stdout }}
iface {{ switch_iface.stdout }} inet static
address {{ switch.ipv4.address }}
network {{ switch.ipv4.network }}
netmask {{ switch.ipv4.netmask }}
broadcast {{ switch.ipv4.broadcast }}
mtu 1496
dns-nameservers {{ switch_dns }}
dns-search switch.crans.org
up /sbin/ip link set $IFACE alias switch
{% if 'interfaces' in ansible_local %}
{% if 'sup_if_4' in ansible_local.interfaces %}
{% if switch_iface.stdout in ansible_local.interfaces.sup_if_4 %}
{% for line in ansible_local.interfaces.sup_if_4[switch_iface.stdout] %}
{{ line }}
{% endfor %}
{% endif %}
{% endif %}
{% endif %}
iface {{ switch_iface.stdout }} inet6 static
address {{ switch.ipv6[0].address }}/{{ switch.ipv6[0].prefix }}
{% if 'interfaces' in ansible_local %}
{% if 'sup_if_6' in ansible_local.interfaces %}
{% if switch_iface.stdout in ansible_local.interfaces.sup_if_6 %}
{% for line in ansible_local.interfaces.sup_if_6[switch_iface.stdout] %}
{{ line }}
{% endfor %}
{% endif %}
{% endif %}
{% endif %}