-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathkvm@.service
27 lines (26 loc) · 920 Bytes
/
kvm@.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[Unit]
Description=QEMU - VM%i
After=docker.service
[Service]
EnvironmentFile=/etc/environment
Environment=INSTANCE=%i
Environment=HOSTNAME=%H
ExecStartPre=-/usr/bin/docker kill kvm-%i
ExecStartPre=-/usr/bin/docker rm kvm-%i
ExecStartPre=-/usr/sbin/modprobe kvm
ExecStartPre=-/usr/sbin/modprobe tun
ExecStartPre=-/usr/bin/etcdctl mk /kvm/${INSTANCE}/host ${HOSTNAME}
ExecStartPre=/usr/bin/etcdctl set --swap-with-value ${HOSTNAME} /kvm/${INSTANCE}/host ${HOSTNAME}
ExecStart=/usr/bin/docker run --rm --privileged --net=host --pid=host --ipc=host --name kvm-%i \
-e BRIDGE_IF=public \
-e INSTANCE=${INSTANCE} \
-e HOSTNAME=${HOSTNAME} \
-v /etc/ceph:/etc/ceph \
ulexus/qemu
ExecStopPost=-/usr/bin/docker stop kvm-%i
ExecStopPost=-/usr/bin/docker rm kvm-%i
ExecStopPost=-/usr/bin/etcdctl rm --with-value ${HOSTNAME} /kvm/${INSTANCE}/host
Restart=always
RestartSec=10s
TimeoutStartSec=120
TimeoutStopSec=15