From d4a96bc04de6d2de6e001bbe853c056bae3d986b Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 3 Oct 2014 16:08:50 -0700 Subject: [PATCH 1/7] Update version for development --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 7018f9f..3104525 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache 2.0' description 'Chef driven Linux Containers' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '2.0.0' +version '2.0.1' suggests 'omnibus_updater' suggests 'bridger' From 4d0c2c2e316dc2ea4df05ce5a7b5866ee79c9ba0 Mon Sep 17 00:00:00 2001 From: Pat Downey Date: Mon, 19 Jan 2015 21:59:54 +0000 Subject: [PATCH 2/7] Update Gemfile * Specify Ruby version as 2.1.5 * Don't use vagrant gem anymore * Use rubygems version of test-kitchen --- Gemfile | 5 +- Gemfile.lock | 150 ++++++++++++++++++++++++--------------------------- 2 files changed, 74 insertions(+), 81 deletions(-) diff --git a/Gemfile b/Gemfile index 29a243a..6774364 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,7 @@ source "https://rubygems.org" +ruby '2.1.5' + gem 'librarian-chef' -gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant', :tag => 'v1.3.4' gem 'kitchen-vagrant' -gem 'test-kitchen', git: 'git://github.com/opscode/test-kitchen.git', branch: 'b934b45db306389a9ed42eae5375a4814aaf4cfe' +gem 'test-kitchen' diff --git a/Gemfile.lock b/Gemfile.lock index e46ec65..975f4f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,105 +1,98 @@ -GIT - remote: git://github.com/mitchellh/vagrant - revision: 0ac2a87388419b989c3c0d0318cc97df3b0ed27d - tag: v1.3.4 - specs: - vagrant (1.3.4) - childprocess (~> 0.3.7) - erubis (~> 2.7.0) - i18n (~> 0.6.0) - log4r (~> 1.1.9) - net-scp (~> 1.1.0) - net-ssh (~> 2.6.6) - -GIT - remote: git://github.com/opscode/test-kitchen.git - revision: b934b45db306389a9ed42eae5375a4814aaf4cfe - branch: b934b45db306389a9ed42eae5375a4814aaf4cfe - specs: - test-kitchen (1.0.0.dev) - celluloid - mixlib-shellout - net-scp - net-ssh - pry - safe_yaml (~> 0.9.5) - thor - GEM remote: https://rubygems.org/ specs: - archive-tar-minitar (0.5.2) - celluloid (0.15.2) - timers (~> 1.1.0) - chef (11.6.2) + chef (12.0.3) + chef-zero (~> 3.2) + diff-lcs (~> 1.2, >= 1.2.4) erubis (~> 2.7) + ffi-yajl (~> 1.2) highline (~> 1.6, >= 1.6.9) - json (>= 1.4.4, <= 1.7.7) mixlib-authentication (~> 1.3) - mixlib-cli (~> 1.3) - mixlib-config (~> 1.1, >= 1.1.2) + mixlib-cli (~> 1.4) + mixlib-config (~> 2.0) mixlib-log (~> 1.3) - mixlib-shellout (~> 1.1) + mixlib-shellout (>= 2.0.0.rc.0, < 3.0) net-ssh (~> 2.6) - net-ssh-multi (~> 1.1.0) - ohai (>= 0.6.0, < 7.0.0) - rest-client (>= 1.0.4, < 1.7.0) - yajl-ruby (~> 1.1) - childprocess (0.3.9) - ffi (~> 1.0, >= 1.0.11) - coderay (1.0.9) + net-ssh-multi (~> 1.1) + ohai (~> 8.0) + plist (~> 3.1.0) + pry (~> 0.9) + chef-zero (3.2.1) + ffi-yajl (~> 1.1) + hashie (~> 2.0) + mixlib-log (~> 1.3) + rack + uuidtools (~> 2.1) + coderay (1.1.0) + diff-lcs (1.2.5) erubis (2.7.0) - ffi (1.9.0) - highline (1.6.19) - i18n (0.6.5) + ffi (1.9.6) + ffi-yajl (1.3.1) + ffi (~> 1.5) + libyajl2 (~> 1.2) + hashie (2.1.2) + highline (1.6.21) ipaddress (0.8.0) - json (1.7.7) - kitchen-vagrant (0.11.1) - test-kitchen (~> 1.0.0.beta.3) - librarian (0.1.1) + kitchen-vagrant (0.15.0) + test-kitchen (~> 1.0) + librarian (0.1.2) highline thor (~> 0.15) - librarian-chef (0.0.2) - archive-tar-minitar (>= 0.5.2) + librarian-chef (0.0.4) chef (>= 0.10) librarian (~> 0.1.0) - log4r (1.1.10) + minitar (>= 0.5.2) + libyajl2 (1.2.0) method_source (0.8.2) - mime-types (1.25) + mime-types (1.25.1) + minitar (0.5.4) mixlib-authentication (1.3.0) mixlib-log - mixlib-cli (1.3.0) - mixlib-config (1.1.2) + mixlib-cli (1.5.0) + mixlib-config (2.1.0) mixlib-log (1.6.0) - mixlib-shellout (1.2.0) - net-scp (1.1.2) + mixlib-shellout (2.0.1) + net-dhcp (1.3.2) + net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (2.6.8) + net-ssh (2.9.2) net-ssh-gateway (1.2.0) net-ssh (>= 2.6.5) - net-ssh-multi (1.1) - net-ssh (>= 2.1.4) - net-ssh-gateway (>= 0.99.0) - ohai (6.18.0) + net-ssh-multi (1.2.0) + net-ssh (>= 2.6.5) + net-ssh-gateway (>= 1.2.0) + ohai (8.0.1) + ffi (~> 1.9) + ffi-yajl (~> 1.1) ipaddress + mime-types (~> 1.16) mixlib-cli - mixlib-config + mixlib-config (~> 2.0) mixlib-log - mixlib-shellout - systemu - yajl-ruby - pry (0.9.12.2) - coderay (~> 1.0.5) - method_source (~> 0.8) + mixlib-shellout (~> 2.0) + net-dhcp + rake (~> 10.1) + systemu (~> 2.6.4) + wmi-lite (~> 1.0) + plist (3.1.0) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) slop (~> 3.4) - rest-client (1.6.7) - mime-types (>= 1.16) - safe_yaml (0.9.7) - slop (3.4.6) - systemu (2.5.2) - thor (0.18.1) - timers (1.1.0) - yajl-ruby (1.1.0) + rack (1.6.0) + rake (10.4.2) + safe_yaml (1.0.4) + slop (3.6.0) + systemu (2.6.4) + test-kitchen (1.3.1) + mixlib-shellout (>= 1.2, < 3.0) + net-scp (~> 1.1) + net-ssh (~> 2.7) + safe_yaml (~> 1.0) + thor (~> 0.18) + thor (0.19.1) + uuidtools (2.1.5) + wmi-lite (1.0.0) PLATFORMS ruby @@ -107,5 +100,4 @@ PLATFORMS DEPENDENCIES kitchen-vagrant librarian-chef - test-kitchen! - vagrant! + test-kitchen From 5c09e9be203b8b138f921b590f2c521b44ae2e33 Mon Sep 17 00:00:00 2001 From: Pat Downey Date: Mon, 19 Jan 2015 22:02:51 +0000 Subject: [PATCH 3/7] Add yum-epel cookbook for redhat testing LXC isn't included in the standard repositories but it is included in EPEL, so we need to refer to it so that we can download the LXC packages --- Cheffile | 3 ++- test/cookbooks/lxc-test/metadata.rb | 1 + test/cookbooks/lxc-test/recipes/default.rb | 10 +++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cheffile b/Cheffile index 1b7af49..8fa36db 100644 --- a/Cheffile +++ b/Cheffile @@ -2,4 +2,5 @@ site 'http://community.opscode.com/api/v1' cookbook 'lxc', path: './' cookbook 'apt' -cookbook 'lxc-test', path: 'test/cookbooks/lxc-test' \ No newline at end of file +cookbook 'yum-epel' +cookbook 'lxc-test', path: 'test/cookbooks/lxc-test' diff --git a/test/cookbooks/lxc-test/metadata.rb b/test/cookbooks/lxc-test/metadata.rb index 28a48ad..0d29333 100644 --- a/test/cookbooks/lxc-test/metadata.rb +++ b/test/cookbooks/lxc-test/metadata.rb @@ -3,4 +3,5 @@ depends 'lxc' depends 'apt' +depends 'yum-epel' depends 'minitest-handler' diff --git a/test/cookbooks/lxc-test/recipes/default.rb b/test/cookbooks/lxc-test/recipes/default.rb index 83fa3b6..da93e18 100644 --- a/test/cookbooks/lxc-test/recipes/default.rb +++ b/test/cookbooks/lxc-test/recipes/default.rb @@ -1,3 +1,11 @@ include_recipe 'minitest-handler' -include_recipe 'apt' + +if(node.platform_family?(:debian)) + include_recipe 'apt' +end + +if(node.platform_family?(:rhel)) + include_recipe 'yum-epel' +end + include_recipe 'lxc' From e16bb42ea9fba4a1d45d0d34f9d87bdf0bf52981 Mon Sep 17 00:00:00 2001 From: Pat Downey Date: Mon, 19 Jan 2015 22:04:45 +0000 Subject: [PATCH 4/7] Add centos-{6.5,6.6} and ubuntu 14.04 targets for test-kitchen Also replaces the hw-ops 12.04 (precise) box with the default 12.04 box from opscode as the hw-ops url no longer works. centos-6.4 doesn't work properly as the version of dnsmasq that comes with it has a bug (https://www.redhat.com/archives/rdo-list/2014-December/msg00068.html) --- .kitchen.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index cb93379..7bcff8e 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,10 +1,13 @@ --- driver_plugin: vagrant platforms: +- name: centos-6.5 +- name: centos-6.6 - name: ubuntu-12.04 - driver_config: - box: precise-64-lxc-preseed - box_url: http://vagrant.hw-ops.com/precise-64-lxc-preseed.box +- name: ubuntu-14.10 +# driver_config: +# box: precise-64-lxc-preseed +# box_url: http://vagrant.hw-ops.com/precise-64-lxc-preseed.box # box: precise-64 # box_url: https://github.com/downloads/chrisroberts/vagrant-boxes/precise-64.box # box: opscode-ubuntu-12.04 From b40d8d4c38e478f0c0b4d33050e22bf4c0b8ad14 Mon Sep 17 00:00:00 2001 From: Pat Downey Date: Mon, 19 Jan 2015 22:11:09 +0000 Subject: [PATCH 5/7] Parameterise the `rhel_bridge` recipe a bit more. Also tries to use consistent references to attributes, no longer use `default_config` --- recipes/rhel_bridge.rb | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/recipes/rhel_bridge.rb b/recipes/rhel_bridge.rb index 6ad3256..cda5656 100644 --- a/recipes/rhel_bridge.rb +++ b/recipes/rhel_bridge.rb @@ -7,29 +7,31 @@ action [:enable, :start] end -execute 'create lxcbr0' do - command 'brctl addbr lxcbr0' - not_if 'brctl showmacs lxcbr0' +bridge_name = node[:lxc][:bridge] + +execute "create #{bridge_name}" do + command "brctl addbr #{bridge_name}" + not_if "brctl showmacs #{bridge_name}" end -file '/etc/sysconfig/network-scripts/ifcfg-lxcbr0' do +file "/etc/sysconfig/network-scripts/ifcfg-#{bridge_name}" do content lazy{ { - :device => 'lxcbr0', + :device => bridge_name, :type => 'Bridge', :bootproto => 'static', - :ipaddr => node[:lxc][:default_config][:lxc_addr], - :netmask => '255.255.255.0' + :ipaddr => node[:lxc][:addr], + :netmask => node[:lxc][:netmask], }.map do |k,v| "#{k.to_s.upcase}=#{v.inspect}" end.join("\n") } mode 0644 - notifies :run, 'execute[enable lxcbr0]', :immediately + notifies :run, "execute[enable #{bridge_name}]", :immediately end -execute 'enable lxcbr0' do - command 'ifup lxcbr0' +execute "enable #{bridge_name}" do + command "ifup #{bridge_name}" action :nothing end @@ -52,7 +54,7 @@ ':PREROUTING ACCEPT [0:0]', ':OUTPUT ACCEPT [0:0]', ':POSTROUTING ACCEPT [0:0]', - "-A POSTROUTING -s #{node[:lxc][:default_config][:lxc_network]} ! -d #{node[:lxc][:default_config][:lxc_network]} -j MASQUERADE", + "-A POSTROUTING -s #{node[:lxc][:network]} ! -d #{node[:lxc][:network]} -j MASQUERADE", 'COMMIT', '' ].join("\n") @@ -94,11 +96,11 @@ file '/etc/dnsmasq.conf' do content lazy{ { - 'listen-address' => node[:lxc][:default_config][:lxc_addr], - 'interface' => 'lxcbr0', + 'listen-address' => node[:lxc][:addr], + 'interface' => bridge_name, 'except-interface' => 'lo', 'bind-interfaces' => true, - 'dhcp-range' => "#{node[:lxc][:default_config][:lxc_dhcp_range]}" + 'dhcp-range' => "#{node[:lxc][:dhcp_range]}" }.map do |k,v| if(v == true) k @@ -118,7 +120,7 @@ file '/etc/lxc/default.conf' do content [ 'lxc.network.type = veth', - 'lxc.network.link = lxcbr0', + "lxc.network.link = #{bridge_name}", 'lxc.network.flags = up', '' ].join("\n") From 8b5bf51ee07619220669ca38a34b3c54e4e7ac2d Mon Sep 17 00:00:00 2001 From: Pat Downey Date: Mon, 19 Jan 2015 22:13:03 +0000 Subject: [PATCH 6/7] Add ability to disable NetworkManager on RHEL/CentOS NetworkManager wasn't playing nicely with the bridge so this commit parameterises the choice and disables it by default --- attributes/default.rb | 1 + recipes/rhel_bridge.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/attributes/default.rb b/attributes/default.rb index 6bc02f3..08a0b14 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -6,6 +6,7 @@ default[:lxc][:addr] = '10.0.4.1' default[:lxc][:netmask] = '255.255.255.0' default[:lxc][:network] = '10.0.4.0/24' +default[:lxc][:nm_managed] = 'no' default[:lxc][:dhcp_range] = '10.0.4.2,10.0.4.254' default[:lxc][:dhcp_max] = '253' default[:lxc][:shutdown_timeout] = 120 diff --git a/recipes/rhel_bridge.rb b/recipes/rhel_bridge.rb index cda5656..16ae234 100644 --- a/recipes/rhel_bridge.rb +++ b/recipes/rhel_bridge.rb @@ -22,6 +22,7 @@ :bootproto => 'static', :ipaddr => node[:lxc][:addr], :netmask => node[:lxc][:netmask], + :nm_managed => node[:lxc][:nm_managed] }.map do |k,v| "#{k.to_s.upcase}=#{v.inspect}" end.join("\n") From 4796b02aaf09b6ac27dfc107eab3eb859138b082 Mon Sep 17 00:00:00 2001 From: Pat Downey Date: Tue, 20 Jan 2015 13:45:23 +0000 Subject: [PATCH 7/7] Use `NM_CONTROLLED` not `NM_MANAGED`. Made a mistake --- attributes/default.rb | 2 +- recipes/rhel_bridge.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 08a0b14..f37ac22 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -6,7 +6,7 @@ default[:lxc][:addr] = '10.0.4.1' default[:lxc][:netmask] = '255.255.255.0' default[:lxc][:network] = '10.0.4.0/24' -default[:lxc][:nm_managed] = 'no' +default[:lxc][:nm_controlled] = 'no' default[:lxc][:dhcp_range] = '10.0.4.2,10.0.4.254' default[:lxc][:dhcp_max] = '253' default[:lxc][:shutdown_timeout] = 120 diff --git a/recipes/rhel_bridge.rb b/recipes/rhel_bridge.rb index 16ae234..77d939c 100644 --- a/recipes/rhel_bridge.rb +++ b/recipes/rhel_bridge.rb @@ -22,7 +22,7 @@ :bootproto => 'static', :ipaddr => node[:lxc][:addr], :netmask => node[:lxc][:netmask], - :nm_managed => node[:lxc][:nm_managed] + :nm_controlled=> node[:lxc][:nm_controlled] }.map do |k,v| "#{k.to_s.upcase}=#{v.inspect}" end.join("\n")