[interfaces] Configure fil interface
parent
2667c3d696
commit
81de24e5bd
|
@ -3,22 +3,27 @@
|
|||
# Set variable adm_iface for all servers
|
||||
- hosts: server
|
||||
tasks:
|
||||
- shell: grep adm /sys/class/net/*/ifalias | sed "s|/sys/class/net/||" | sed "s|/ifalias:.*||"
|
||||
register: adm_iface
|
||||
check_mode: no
|
||||
- shell: grep srv /sys/class/net/*/ifalias | sed "s|/sys/class/net/||" | sed "s|/ifalias:.*||"
|
||||
register: srv_iface
|
||||
check_mode: no
|
||||
- shell: grep ens /sys/class/net/*/ifalias | sed "s|/sys/class/net/||" | sed "s|/ifalias:.*||"
|
||||
register: ens_iface
|
||||
check_mode: no
|
||||
- shell: grep adm /sys/class/net/*/ifalias | sed "s|/sys/class/net/||" | sed "s|/ifalias:.*||"
|
||||
register: adm_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
|
||||
|
||||
- hosts: boeing.adm.crans.org
|
||||
- hosts: boeing.adm.crans.org,cochon.adm.crans.org
|
||||
vars:
|
||||
- adm_dns: 10.231.136.152 10.231.136.4
|
||||
- srv_gateway: 185.230.79.254
|
||||
- srv_dns: 185.230.79.152 185.230.79.4
|
||||
- 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
|
||||
- fil_gateway: 10.54.0.254
|
||||
- fil_dns: 10.54.0.152 10.54.0.4
|
||||
roles:
|
||||
- interfaces
|
||||
|
|
|
@ -25,3 +25,10 @@
|
|||
dest: /etc/network/interfaces.d/02-adm
|
||||
mode: 0644
|
||||
when: adm_iface.stdout
|
||||
|
||||
- name: Deploy fil interface config
|
||||
template:
|
||||
src: network/interfaces.d/21-fil.j2
|
||||
dest: /etc/network/interfaces.d/21-fil
|
||||
mode: 0644
|
||||
when: fil_iface.stdout
|
||||
|
|
|
@ -15,7 +15,7 @@ iface {{ srv_iface.stdout }} inet static
|
|||
{% if srv_iface.stdout in ansible_local.interfaces %}
|
||||
{% if 'sup_if_4' in ansible_local.interfaces[srv_iface.stdout] %}
|
||||
{% for line in ansible_local.interfaces[srv_iface.stdout].sup_if_4 %}
|
||||
{{ line }}
|
||||
{{ line }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
{{ ansible_header | comment }}
|
||||
|
||||
allow-hotplug {{ fil_iface.stdout }}
|
||||
iface {{ fil_iface.stdout }} inet static
|
||||
address {{ hostvars[inventory_hostname]['ansible_' + fil_iface.stdout].ipv4.address }}
|
||||
network {{ hostvars[inventory_hostname]['ansible_' + fil_iface.stdout].ipv4.network }}
|
||||
netmask {{ hostvars[inventory_hostname]['ansible_' + fil_iface.stdout].ipv4.netmask }}
|
||||
broadcast {{ hostvars[inventory_hostname]['ansible_' + fil_iface.stdout].ipv4.broadcast }}
|
||||
gateway {{ fil_gateway }}
|
||||
mtu 1496
|
||||
dns-nameservers {{ fil_dns }}
|
||||
dns-search fil.crans.org
|
||||
up /sbin/ip link set $IFACE alias fil
|
||||
{% if 'interfaces' in ansible_local %}
|
||||
{% if fil_iface.stdout in ansible_local.interfaces %}
|
||||
{% if 'sup_if_4' in ansible_local.interfaces[fil_iface.stdout] %}
|
||||
{% for line in ansible_local.interfaces[fil_iface.stdout].sup_if_4 %}
|
||||
{{ line }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
iface {{ fil_iface.stdout }} inet6 static
|
||||
address {{ hostvars[inventory_hostname]['ansible_' + fil_iface.stdout].ipv6[0].address }}/{{ hostvars[inventory_hostname]['ansible_' + fil_iface.stdout].ipv6[0].prefix }}
|
||||
{% if 'interfaces' in ansible_local %}
|
||||
{% if fil_iface.stdout in ansible_local.interfaces %}
|
||||
{% if 'sup_if_6' in ansible_local.interfaces[fil_iface.stdout] %}
|
||||
{% for line in ansible_local.interfaces[fil_iface.stdout].sup_if_6 %}
|
||||
{{ line }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
Loading…
Reference in New Issue