lib/vagabond/cookbooks/vagabond/recipes/default.rb in vagabond-0.2.0 vs lib/vagabond/cookbooks/vagabond/recipes/default.rb in vagabond-0.2.2
- old
+ new
@@ -1,5 +1,39 @@
+
+# TODO: Move this to lxc cookbook proper at some point
+# TODO: Test this on fresh node to ensure start up scripts actuall do
+# what they are expected to
+=begin
+dpkg_autostart 'lxc' do
+ allow false
+end
+
+dpkg_autostart 'lxc-net' do
+ allow false
+end
+=end
+# Start at 0 and increment up if found
+unless(node[:network][:interfaces][:lxcbr0])
+ max = node.network.interfaces.map do |name, val|
+ Array(val[:routes]).map do |route|
+ if(route[:family] == 'inet' && route[:destination].start_with?('10.0'))
+ route[:destination].split('/').first.split('.')[3].to_i
+ end
+ end
+ end.compact.max
+
+ node.default[:vagabond][:lxc_network][:oct] = max ? max + 1 : 0
+
+ # Test for existing bridge. Use different subnet if found
+ l_net = "10.0.#{node[:vagabond][:lxc_network][:oct]}"
+
+ node.set[:lxc][:addr] = "#{l_net}.1"
+ node.set[:lxc][:network] = "#{l_net}.0/24"
+ node.set[:lxc][:dhcp_range] = "#{l_net}.2,#{l_net}.199"
+ node.set[:lxc][:dhcp_max] = '199'
+end
+
include_recipe 'lxc'
ruby_block 'LXC template: lxc-centos' do
block do
dir = %w(/usr/share /usr/lib).map do |prefix|
@@ -55,15 +89,25 @@
'curl -L https://www.opscode.com/chef/install.sh | bash'
]
end
end
+lxc_container 'chef-server' do
+ clone 'ubuntu_1204'
+ initialize_commands [
+
+ ]
+ only_if do
+ node[:vagabond][:server_base]
+ end
+end
+
node[:vagabond][:customs].each do |name, options|
lxc_container name do
- action :clone
- base_container options[:base]
+ action :create
+ clone options[:base]
end
if(options[:memory])
lxc_config name do
cgroup(
@@ -74,7 +118,5 @@
)
)
end
end
end
-
-