Merge branch 'interfaces' into 'newinfra'
Interfaces See merge request nounous/ansible!73certbot_on_virtu
commit
59f73fed52
|
@ -1,2 +1,6 @@
|
||||||
|
interfaces:
|
||||||
|
adm: ens18
|
||||||
|
srv_nat: ens19
|
||||||
|
|
||||||
loc_framadate:
|
loc_framadate:
|
||||||
path: /var/www/framadate
|
path: /var/www/framadate
|
||||||
|
|
|
@ -1,69 +1,35 @@
|
||||||
#!/usr/bin/env ansible-playbook
|
#!/usr/bin/env ansible-playbook
|
||||||
---
|
---
|
||||||
# Get ifname of configured vlan for all servers
|
- hosts: voyager.adm.crans.org
|
||||||
- hosts: server
|
|
||||||
tasks:
|
|
||||||
- shell: "grep {{ item }} /sys/class/net/*/ifalias | sed \"s|/sys/class/net/||\" | sed \"s|/ifalias:.*||\""
|
|
||||||
check_mode: false
|
|
||||||
register: ifaces
|
|
||||||
loop:
|
|
||||||
- srv
|
|
||||||
- ens
|
|
||||||
- adm
|
|
||||||
- borne
|
|
||||||
- switch
|
|
||||||
- fil
|
|
||||||
|
|
||||||
- hosts: boeing.adm.crans.org,cochon.adm.crans.org,tracker.adm.crans.org,voyager.adm.crans.org,lutim.adm.crans.org,gateau.adm.crans.org,owncloud-srv.adm.crans.org,charybde.adm.crans.org,cas-srv.adm.crans.org,fyre.adm.crans.org,silice.adm.crans.org,frontdaur.adm.crans.org,bakdaur.adm.crans.org,ethercalc-srv.adm.crans.org,alice.adm.crans.org,mailman.adm.crans.org
|
|
||||||
vars:
|
vars:
|
||||||
vlan:
|
vlan:
|
||||||
- name: srv
|
- name: srv
|
||||||
id: 0
|
|
||||||
metric: 100
|
|
||||||
gateway: 185.230.79.254
|
|
||||||
dns: 185.230.79.152 185.230.79.4
|
|
||||||
dns_search: crans.org
|
|
||||||
ifnames: "{{ ifaces | json_query('results[?item==`srv`].stdout') }}"
|
|
||||||
|
|
||||||
- name: ens
|
|
||||||
id: 1
|
|
||||||
metric: 300
|
|
||||||
gateway: 138.231.136.254
|
|
||||||
dns: 138.231.136.152 138.231.136.4
|
|
||||||
dns_search: crans.org
|
|
||||||
ifnames: "{{ ifaces | json_query('results[?item==`ens`].stdout') }}"
|
|
||||||
|
|
||||||
- name: adm
|
|
||||||
id: 2
|
id: 2
|
||||||
dns: 10.231.136.152 10.231.136.4
|
gateway: 185.230.79.99
|
||||||
dns_search: adm.crans.org
|
dns: 185.230.79.99
|
||||||
ifnames: "{{ ifaces | json_query('results[?item==`adm`].stdout') }}"
|
gateway_v6: 2a0c:700:2::ff:fe00:9902
|
||||||
|
- name: srv_nat
|
||||||
- name: borne
|
|
||||||
id: 3
|
id: 3
|
||||||
dns: 10.231.148.52 10.231.148.4
|
gateway: 172.16.3.99
|
||||||
dns_search: borne.crans.org
|
dns: 172.16.3.99
|
||||||
ifnames: "{{ ifaces | json_query('results[?item==`borne`].stdout') }}"
|
gateway_v6: 2a0c:700:3::ff:fe00:9903
|
||||||
|
- name: san
|
||||||
- name: switch
|
|
||||||
id: 4
|
id: 4
|
||||||
dns: 10.231.100.152 10.231.100.4
|
- name: adm
|
||||||
dns_search: switch.crans.org
|
id: 10
|
||||||
ifnames: "{{ ifaces | json_query('results[?item==`switch`].stdout') }}"
|
dns: 172.16.10.101 172.16.10.102
|
||||||
|
- name: infra
|
||||||
- name: fil
|
id: 11
|
||||||
id: 21
|
dns: 172.16.32.99
|
||||||
metric: 400
|
|
||||||
gateway: 10.54.0.254
|
|
||||||
dns: 10.54.0.152 10.54.0.4
|
|
||||||
dns_search: fil.crans.org
|
|
||||||
ifnames: "{{ ifaces | json_query('results[?item==`fil`].stdout') }}"
|
|
||||||
|
|
||||||
- name: adh
|
- name: adh
|
||||||
id: 23
|
id: 12
|
||||||
metric: 200
|
gateway: 185.230.78.99
|
||||||
gateway: 185.230.78.254
|
dns: 185.230.78.99
|
||||||
dns: 185.230.78.152 185.230.78.4
|
gateway_v6: 2a0c:700:12::ff:fe00:9912
|
||||||
dns_search: crans.org
|
- name: adh_nat
|
||||||
ifnames: "{{ ifaces | json_query('results[?item==`adh`].stdout') }}"
|
id: 13
|
||||||
roles: ["interfaces"]
|
gateway: 100.64.0.99
|
||||||
|
dns: 100.64.0.99
|
||||||
|
gateway_v6: 2a0c:700:13::ff:fe00:9913
|
||||||
|
roles:
|
||||||
|
- interfaces
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
- name: Deploy interfaces config
|
- name: Deploy interfaces config
|
||||||
template:
|
template:
|
||||||
src: "network/interfaces.d/ifalias.j2"
|
src: "network/interfaces.d/ifalias.j2"
|
||||||
dest: "/etc/network/interfaces.d/{{ '%02d' | format(item.id) }}-{{ item.name }}"
|
dest: "/etc/network/interfaces.d/{{ '%02d' | format(item.id) }}-{{ item.name | replace('_', '-') }}"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
when: (item.ifnames | length > 0) and item.ifnames[0] != ''
|
when: item.name in interfaces
|
||||||
loop: "{{ vlan }}"
|
loop: "{{ vlan }}"
|
||||||
|
|
|
@ -1,36 +1,49 @@
|
||||||
{{ ansible_header | comment }}
|
{{ ansible_header | comment }}
|
||||||
|
|
||||||
{% set ifconfig = hostvars[inventory_hostname]['ansible_' + item.ifnames[0]] %}
|
{% set vlan_name = (item.name | replace('_', '-')) %}
|
||||||
auto {{ item.ifnames[0] }}
|
{% set subnet = query('ldap', 'network', vlan_name) %}
|
||||||
iface {{ item.ifnames[0] }} inet static
|
{% set ips = query('ldap', 'ip', ansible_hostname, vlan_name) %}
|
||||||
address {{ ifconfig.ipv4.address }}
|
{% if (ips | ipv4 | length) > 0 %}
|
||||||
network {{ ifconfig.ipv4.network }}
|
auto {{ interfaces[item.name] }}
|
||||||
netmask {{ ifconfig.ipv4.netmask }}
|
iface {{ interfaces[item.name] }} inet static
|
||||||
broadcast {{ ifconfig.ipv4.broadcast }}
|
{% for ip in (ips | ipv4) %}
|
||||||
|
address {{ ip }}
|
||||||
|
{% endfor %}
|
||||||
|
network {{ subnet.network }}
|
||||||
|
netmask {{ subnet.netmask }}
|
||||||
{% if item.gateway is defined %}
|
{% if item.gateway is defined %}
|
||||||
gateway {{ item.gateway }}
|
gateway {{ item.gateway }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.metric is defined %}
|
{% if item.metric is defined %}
|
||||||
metric {{ item.metric }}
|
metric {{ item.metric }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
mtu 1496
|
{% if item.dns is defined %}
|
||||||
dns-nameservers {{ item.dns }}
|
dns-nameservers {{ item.dns }}
|
||||||
dns-search {{ item.dns_search }}
|
{% endif %}
|
||||||
up /sbin/ip link set $IFACE alias {{ item.name }}
|
dns-search {{ vlan_name }}.crans.org
|
||||||
|
up /sbin/ip link set $IFACE alias {{ vlan_name }}
|
||||||
{% if ansible_local.interfaces.sup_if_4 is defined %}
|
{% if ansible_local.interfaces.sup_if_4 is defined %}
|
||||||
{% if item.ifnames[0] in ansible_local.interfaces.sup_if_4 %}
|
{% if interfaces[item.name] in ansible_local.interfaces.sup_if_4 %}
|
||||||
{% for line in ansible_local.interfaces.sup_if_4[item.ifnames[0]] %}
|
{% for line in ansible_local.interfaces.sup_if_4[interfaces[item.name]] %}
|
||||||
{{ line }}
|
{{ line }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
iface {{ item.ifnames[0] }} inet6 static
|
{% if (ips | ipv6 | length) > 0 %}
|
||||||
address {{ ifconfig.ipv6[0].address }}/{{ ifconfig.ipv6[0].prefix }}
|
iface {{ interfaces[item.name] }} inet6 static
|
||||||
|
{% for ip in (ips | ipv6) %}
|
||||||
|
address {{ ip }}/64
|
||||||
|
{% endfor %}
|
||||||
|
{% if item.gateway_v6 is defined %}
|
||||||
|
gateway {{ item.gateway_v6 }}
|
||||||
|
{% endif %}
|
||||||
{% if ansible_local.interfaces.sup_if_6 is defined %}
|
{% if ansible_local.interfaces.sup_if_6 is defined %}
|
||||||
{% if item.ifnames[0] in ansible_local.interfaces.sup_if_6 %}
|
{% if interfaces[item.name] in ansible_local.interfaces.sup_if_6 %}
|
||||||
{% for line in ansible_local.interfaces.sup_if_6[item.ifnames[0]] %}
|
{% for line in ansible_local.interfaces.sup_if_6[interfaces[item.name]] %}
|
||||||
{{ line }}
|
{{ line }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue