Skip to content
Snippets Groups Projects
Commit 8583bac5 authored by alexandr.benzonan's avatar alexandr.benzonan
Browse files

using clean vars

parent 31897513
No related branches found
No related tags found
No related merge requests found
[routers] [routers]
R1 ip="1.0.0.1" ip2="2.0.0.1" gateway="2.0.0.2" R1
R2 ip="3.0.0.2" ip2="2.0.0.2" gateway="2.0.0.1" R2
# R[1:2]
[hosts] [hosts]
H1 ip="1.0.0.3" gateway="1.0.0.1" H1
H2 ip="3.0.0.3" gateway="3.0.0.2" H2
# H[1:2] \ No newline at end of file
[all:vars]
netmask="255.255.255.0"
[hosts:vars]
ifname="eth0"
type="host"
[routers:vars]
ifname="eth1"
ifname2="eth0"
type="router"
auto {{ifname}} auto {{all[group_names[0]].ifname}}
iface {{ifname}} inet static iface {{all[group_names[0]].ifname}} inet static
address {{ip}} address {{all[inventory_hostname].ip}}
netmask {{netmask}} netmask {{all.netmask}}
{% if type == "host" %} {% if group_names[0] == "hosts" %}
post-up ip route add default via {{gateway}} post-up ip route add default via {{all[inventory_hostname].gateway}}
{% endif %} {% endif %}
{% if type == "router" %} {% if group_names[0] == "routers" %}
auto {{ifname2}} auto {{all['routers'].ifname2}}
iface {{ifname2}} inet static iface {{all['routers'].ifname2}} inet static
address {{ip2}} address {{all[inventory_hostname].ip2}}
netmask {{netmask}} netmask {{all.netmask}}
{% if inventory_hostname == "R1" %} {% if inventory_hostname == "R1" %}
post-up ip route add 3.0.0.0/24 nexthop via {{gateway}} post-up ip route add 3.0.0.0/24 nexthop via {{all[inventory_hostname].gateway}}
{% else %} {% else %}
post-up ip route add 1.0.0.0/24 nexthop via {{gateway}} post-up ip route add 1.0.0.0/24 nexthop via {{all[inventory_hostname].gateway}}
{% endif %} {% endif %}
{% endif %} {% endif %}
vars.yml 0 → 100644
all:
netmask: 255.255.255.0
hosts:
ifname: eth0
routers:
ifname: eth1
ifname2: eth0
H1:
ip: 1.0.0.3
gateway: 1.0.0.1
H2:
ip: 3.0.0.3
gateway: 3.0.0.2
R1:
ip: 1.0.0.1
ip2: 2.0.0.1
gateway: 2.0.0.2
R2:
ip: 3.0.0.2
ip2: 2.0.0.2
gateway: 2.0.0.1
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment