add local.conf for each lxc-container

This commit is contained in:
Jörg Thalheim 2015-01-30 09:56:58 +00:00
parent 51aff603ff
commit b89cb8bba3
4 changed files with 18 additions and 5 deletions

View File

@ -1,7 +1,7 @@
{ {
"zone": { "zone": {
"soa": "ns1.higgsboson.tk.", "soa": "ns1.higgsboson.tk.",
"serial": 116, "serial": 124,
"refresh": "1H", "refresh": "1H",
"hostmaster": "hostmaster.higgsboson.tk", "hostmaster": "hostmaster.higgsboson.tk",
"domain": "eve.higgsboson.tk", "domain": "eve.higgsboson.tk",
@ -325,7 +325,9 @@
"ipv6": "2a01:4f8:210:31fd:1::20/128", "ipv6": "2a01:4f8:210:31fd:1::20/128",
"group": "php", "group": "php",
"vars": { "vars": {
"php_extensions": [] "php_extensions": [
]
} }
}, },
"phonefinder": { "phonefinder": {
@ -333,8 +335,10 @@
"ipv6": "2a01:4f8:210:31fd:1::21/128", "ipv6": "2a01:4f8:210:31fd:1::21/128",
"group": "php", "group": "php",
"vars": { "vars": {
"php_extensions": [] "php_extensions": [
]
} }
} }
} }
} }

View File

@ -1,6 +1,7 @@
require "erb" require "erb"
require "netaddr" require "netaddr"
require "pathname" require "pathname"
require "fileutils"
module Lxc module Lxc
class Container class Container
@ -55,6 +56,13 @@ module Lxc
c["dn42_ipv6"] = NetAddr::CIDR.create(@dn42_ipv6).to_s(Short: true) c["dn42_ipv6"] = NetAddr::CIDR.create(@dn42_ipv6).to_s(Short: true)
end end
config_dir = File.dirname(config_path)
local_conf = File.join(config_dir, "local.conf")
unless File.exists?(local_conf)
FileUtils.touch(local_conf)
end
opts[:local_conf] = local_conf
templ = Template.new(CONFIG_ROOT.join("templates", "config.erb")) templ = Template.new(CONFIG_ROOT.join("templates", "config.erb"))
templ.write(config_path, opts) templ.write(config_path, opts)
end end

View File

@ -1,4 +1,5 @@
lxc.include = /etc/lxc/default.conf lxc.include = /etc/lxc/default.conf
lxc.include = <%= local_conf %>
lxc.utsname = <%= name %> lxc.utsname = <%= name %>
lxc.rootfs = <%= rootfs %> lxc.rootfs = <%= rootfs %>
lxc.network.ipv4 = <%= ipv4 %> lxc.network.ipv4 = <%= ipv4 %>

View File

@ -21,6 +21,6 @@
<% end -%> <% end -%>
<% end -%> <% end -%>
<% pointers do |addr, name| -%> <% zone.pointers do |name, addr| -%>
<%= addr %> PTR <%= name %>.<%= data["zone"]["domain"] %>. <%= addr %> PTR <%= name %>.<%= data["zone"]["domain"] %>.
<% end -%> <% end -%>