From f7490a06faabcf88da04498ea62545f5474b2442 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 9 Nov 2016 01:18:00 +0100 Subject: [PATCH] upstream --- doc/test-environment.md | 7 +++++++ salt-pillar/top.sls | 2 ++ salt/lxc-containers-1/config | 8 +++++--- salt/lxc-containers-1/containers.yaml | 6 ++++++ salt/top.sls | 2 +- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/doc/test-environment.md b/doc/test-environment.md index f0e3c62..3f5a8d3 100644 --- a/doc/test-environment.md +++ b/doc/test-environment.md @@ -8,6 +8,13 @@ kvm -hda salt.hda -m 1024 -smp 2 -net nic,model=e1000 -net user -cdrom Now run the Debian installation. Hostname: `server1` +```shell +brctl addbr br-up1 +ifdown eth0 +brctl addif br-up1 eth0 +dhclient br-up1 +``` + # Bootstrap Configure a recent version, eg. *stretch* diff --git a/salt-pillar/top.sls b/salt-pillar/top.sls index fc18a48..d690657 100644 --- a/salt-pillar/top.sls +++ b/salt-pillar/top.sls @@ -5,3 +5,5 @@ base: - vlans '*gw': - dhcp + 'upstream1': + - upstream.upstream1 diff --git a/salt/lxc-containers-1/config b/salt/lxc-containers-1/config index 19951b4..86db470 100644 --- a/salt/lxc-containers-1/config +++ b/salt/lxc-containers-1/config @@ -13,7 +13,8 @@ lxc.network.flags=up {%- if conf['type'] == 'veth' %} lxc.network.veth.pair={{ id }}-{{ net }} {%- endif %} -{%- set inet_addr = pillar['hosts-inet'][net].get(id) %} +{%- set hosts = pillar['hosts-inet'].get(net) %} +{%- set inet_addr = hosts and hosts.get(id) %} {%- if inet_addr %} {%- set prefix_len = pillar['subnets-inet'][net].split('/')[1] %} lxc.network.ipv4={{ inet_addr }}/{{ prefix_len }} @@ -24,8 +25,9 @@ lxc.network.link=br-{{ net }} lxc.network.link=bond0.{{ pillar['vlans'].get(net) }} {%- endif %} lxc.network.name={{ net }} -{%- if net == 'core' %} -lxc.network.ipv4.gateway=172.20.72.1 +{%- set gw = conf.get('gw') %} +{%- if gw %} +lxc.network.ipv4.gateway={{ pillar['hosts-inet'][net][gw] }} {%- endif %} #lxc.network.ipv6= #lxc.network.ipv6.gateway=fe80::1 diff --git a/salt/lxc-containers-1/containers.yaml b/salt/lxc-containers-1/containers.yaml index 1c140b9..276b6f4 100644 --- a/salt/lxc-containers-1/containers.yaml +++ b/salt/lxc-containers-1/containers.yaml @@ -2,6 +2,7 @@ pub-gw: interfaces: core: type: veth + gw: anon1 pub: type: phys @@ -9,6 +10,7 @@ serv-gw: interfaces: core: type: veth + gw: upstream1 serv: type: veth @@ -16,16 +18,20 @@ priv1-gw: interfaces: core: type: veth + gw: upstream1 priv2-gw: interfaces: core: type: veth + gw: upstream1 upstream1: interfaces: core: type: veth + up1: + type: veth anon1: interfaces: diff --git a/salt/top.sls b/salt/top.sls index eab045d..a45238e 100644 --- a/salt/top.sls +++ b/salt/top.sls @@ -13,9 +13,9 @@ base: - no-ssh - forwarding - ospf + - upstream.dhcp - unbound 'anon*': - no-ssh - forwarding - ospf - - unbound