add the salt playground :)

This commit is contained in:
Astro 2016-11-03 00:26:30 +01:00
parent 1d19508b1d
commit 68e0ed1f4a
8 changed files with 188 additions and 0 deletions

20
doc/test-environment.md Normal file
View File

@ -0,0 +1,20 @@
# Create a Virtual Machine
```shell
dd if=/dev/zero of=salt.hda bs=1M count=1 seek=10239
wget http://cdimage.debian.org/debian-cd/8.6.0/amd64/iso-cd/debian-8.6.0-amd64-netinst.iso
kvm -hda salt.hda -m 1024 -smp 2 -net nic,model=e1000 -net user -cdrom
```
Now run the Debian installation. Hostname: `server1`
# Bootstrap
Configure a recent version, eg. *stretch*
```shell
apt-get install salt-master salt-minion
```
Set `master` to `localhost` in `/etc/salt/minion`, restart the
minion. `salt-key -A` to accept the minion in the master.

View File

@ -0,0 +1,30 @@
lxc.utsname = {{ id }}
# Handled by lxc@.service
lxc.start.auto = 0
lxc.rootfs = /var/lib/lxc/{{ id }}/rootfs
lxc.rootfs.backend = dir
lxc.autodev = 1
lxc.kmsg = 0
{% for interface in container.interfaces %}
lxc.network.type={{ interface['type'] }}
lxc.network.flags=up
{% if interface['type'] == 'veth' %}
lxc.network.veth.pair={{ id }}-{{ interface['type'] }}
{% endif %}
{% if interface.get('v4') %}
lxc.network.ipv4={{ interface['v4'] }}
{% endif %}
{% if interface.get('bridge') %}
lxc.network.link={{ interface['bridge'] }}
{% endif %}
{% if interface.get('name') %}
lxc.network.name={{ interface['name'] }}
{% endif %}
#lxc.network.ipv4.gateway=
#lxc.network.ipv6=
#lxc.network.ipv6.gateway=fe80::1
{% endfor %}
## TODO: limits + caps

View File

@ -0,0 +1,38 @@
public:
interfaces:
- type: veth
bridge: br-core
name: core
v4: 172.20.72.1/26
- type: phys
bridge: bond0.2
name: public
v4: 172.20.76.1/23
servers:
interfaces:
- type: veth
bridge: br-core
name: core
v4: 172.20.72.2/26
priv1:
interfaces:
- type: veth
bridge: br-core
name: core
v4: 172.20.72.3/26
priv2:
interfaces:
- type: veth
bridge: br-core
name: core
v4: 172.20.72.4/26
upstream1:
interfaces:
- type: veth
bridge: br-core
name: core
v4: 172.20.72.5/26

View File

@ -0,0 +1,35 @@
{%- import_yaml "lxc-containers-1/containers.yaml" as containers -%}
lxc:
pkg.installed: []
{% for id, container in containers.items() %}
/var/lib/lxc/{{ id }}:
cmd.run:
- name: lxc-create -n {{ id }} -B dir -t download -- -d debian -r jessie -a amd64 -- --packages salt-minion
- require:
- pkg: lxc
- creates: /var/lib/lxc/{{ id }}
/var/lib/lxc/{{ id }}/config:
file.managed:
- source: salt://lxc-containers-1/config
- template: 'jinja'
- context:
id: {{ id }}
container: {{ container }}
autostart-{{ id }}:
service.enabled:
- name: lxc@{{ id }}
require_in:
file: /var/lib/lxc/{{ id }}/config
start-{{ id }}:
service.running:
- name: lxc@{{ id }}
require:
- service: autostart-{{ id }}
{% endfor %}

2
salt/lxc.sls Normal file
View File

@ -0,0 +1,2 @@
lxc:
pkg.installed: []

6
salt/salt-master.sls Normal file
View File

@ -0,0 +1,6 @@
salt-master:
pkg.installed: []
service.running:
- require:
- pkg: salt-master

52
salt/server1-network.sls Normal file
View File

@ -0,0 +1,52 @@
{% set bond_slaves = ['eth1', 'eth2'] %}
{% for slave in bond_slaves %}
{{ slave }}:
network.managed:
- enabled: True
type: slave
master: bond0
{% endfor %}
bond0:
network.managed:
- name: bond0
proto: manual
type: bond
mode: 802.3ad
slaves: {{ ' '.join(bond_slaves) }}
miimon: 100
{% for vlan in range(1, 15) %}
bond0.{{ vlan }}:
network.managed:
- type: vlan
use:
- network: bond0
require:
- network: bond0
{% endfor %}
br-core:
network.managed:
- type: bridge
ports: bond0.1
proto: manual
bypassfirewall: True
use:
- network: bond0.1
require:
- network: bond0.1
br-public:
network.managed:
- type: bridge
ports: bond0.2
proto: manual
bypassfirewall: True
use:
- network: bond0.2
require:
- network: bond0.2

5
salt/top.sls Normal file
View File

@ -0,0 +1,5 @@
base:
'server1':
- salt-master
- server1-network
- lxc-containers-1