vmmgr/usr/lib/python3.6/lxcmgr/templates.py

68 lines
1.4 KiB
Python
Raw Normal View History

2019-09-20 10:10:25 +02:00
# -*- coding: utf-8 -*-
LXC_CONTAINER = '''# Image name
lxc.uts.name = {name}
# Network
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.ipv4.address = {ipv4}/16
lxc.net.0.ipv4.gateway = 172.17.0.1
# Volumes
lxc.rootfs.path = /var/lib/lxc/{name}/rootfs
# Mounts
lxc.mount.entry = shm dev/shm tmpfs rw,nodev,noexec,nosuid,relatime,mode=1777,create=dir 0 0
lxc.mount.entry = /etc/hosts etc/hosts none bind,create=file 0 0
2019-09-24 19:14:16 +02:00
lxc.mount.entry = /etc/resolv.conf etc/resolv.conf none bind,create=file 0 0{mounts}
2019-09-20 10:10:25 +02:00
# Init
lxc.init.uid = {uid}
lxc.init.gid = {gid}
lxc.init.cwd = {cwd}
2019-09-24 19:14:16 +02:00
lxc.init.cmd = {cmd}
2019-09-20 10:10:25 +02:00
# Environment
2019-09-24 19:14:16 +02:00
lxc.environment = PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin{env}
2019-09-20 10:10:25 +02:00
# Halt
lxc.signal.halt = {halt}
# Log
lxc.console.size = 1MB
lxc.console.logfile = /var/log/lxc/{name}.log
# ID map
lxc.idmap = u 0 100000 65536
lxc.idmap = g 0 100000 65536
# Hooks
lxc.hook.pre-start = /usr/bin/lxcmgr container prepare {layers}
lxc.hook.post-stop = /usr/bin/lxcmgr container cleanup
2019-09-20 10:10:25 +02:00
# Other
lxc.arch = linux64
lxc.cap.drop = sys_admin
lxc.include = /usr/share/lxc/config/common.conf
lxc.include = /usr/share/lxc/config/userns.conf
'''
2019-09-24 09:59:45 +02:00
SERVICE = """#!/sbin/openrc-run
description="{container} LXC container"
2019-09-24 09:59:45 +02:00
depend() {{
need cgroups {depends}
}}
start() {{
lxc-start {container}
}}
2019-09-24 19:14:16 +02:00
{start_post}
2019-09-24 09:59:45 +02:00
stop() {{
lxc-stop {container}
}}
"""