vagrant-lxc 0.8.0 → 1.0.0.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/BOXES.md +13 -21
- data/CHANGELOG.md +49 -0
- data/CONTRIBUTING.md +5 -2
- data/Gemfile +12 -13
- data/Gemfile.lock +66 -51
- data/README.md +39 -25
- data/development/Vagrantfile +0 -2
- data/lib/vagrant-backports/README.md +12 -0
- data/lib/vagrant-backports/action/handle_box.rb +1 -0
- data/lib/vagrant-backports/action/is_state.rb +34 -0
- data/lib/vagrant-backports/action/message.rb +20 -0
- data/lib/{vagrant-lxc → vagrant-backports}/action/wait_for_communicator.rb +6 -5
- data/lib/vagrant-backports/ui.rb +12 -0
- data/lib/vagrant-backports/utils.rb +27 -0
- data/lib/vagrant-lxc.rb +8 -0
- data/lib/vagrant-lxc/action.rb +81 -48
- data/lib/vagrant-lxc/action/boot.rb +2 -1
- data/lib/vagrant-lxc/action/fetch_ip_from_dnsmasq_leases.rb +1 -0
- data/lib/vagrant-lxc/action/handle_box_metadata.rb +36 -14
- data/lib/vagrant-lxc/action/message.rb +0 -23
- data/lib/vagrant-lxc/action/prepare_nfs_settings.rb +64 -0
- data/lib/vagrant-lxc/action/prepare_nfs_valid_ids.rb +19 -0
- data/lib/vagrant-lxc/action/setup_package_files.rb +6 -2
- data/lib/vagrant-lxc/{action → backports/action}/share_folders.rb +0 -0
- data/lib/vagrant-lxc/command/root.rb +58 -0
- data/lib/vagrant-lxc/command/sudoers.rb +87 -0
- data/lib/vagrant-lxc/driver.rb +21 -11
- data/lib/vagrant-lxc/plugin.rb +23 -5
- data/lib/vagrant-lxc/provider/cap/public_address.rb +17 -0
- data/lib/vagrant-lxc/synced_folder.rb +42 -0
- data/lib/vagrant-lxc/version.rb +1 -1
- data/locales/en.yml +6 -5
- data/scripts/lxc-template +165 -0
- data/spec/spec_helper.rb +9 -13
- data/spec/unit/action/clear_forwarded_ports_spec.rb +3 -3
- data/spec/unit/action/compress_rootfs_spec.rb +7 -5
- data/spec/unit/action/forward_ports_spec.rb +8 -8
- data/spec/unit/action/handle_box_metadata_spec.rb +71 -15
- data/spec/unit/action/setup_package_files_spec.rb +32 -8
- data/spec/unit/driver/cli_spec.rb +31 -30
- data/spec/unit/driver_spec.rb +35 -27
- data/spec/unit/support/unit_example_group.rb +6 -6
- data/spec/unit_helper.rb +4 -2
- data/tasks/spec.rake +18 -11
- data/vagrant-lxc.gemspec +7 -0
- data/vagrant-spec.config.rb +24 -0
- metadata +24 -36
- data/boxes/build-all.sh +0 -22
- data/boxes/build-debian-box.sh +0 -167
- data/boxes/build-openmandriva-box.sh +0 -159
- data/boxes/build-ubuntu-box.sh +0 -151
- data/boxes/common/cleanup +0 -7
- data/boxes/common/install-babushka +0 -16
- data/boxes/common/install-chef +0 -15
- data/boxes/common/install-puppet +0 -13
- data/boxes/common/install-salt +0 -12
- data/boxes/common/install-salt-debian +0 -28
- data/boxes/common/lxc-template +0 -226
- data/boxes/common/lxc-template-openmandriva +0 -225
- data/boxes/common/lxc.conf +0 -49
- data/boxes/common/metadata.json +0 -5
- data/lib/vagrant-lxc/action/check_created.rb +0 -21
- data/lib/vagrant-lxc/action/check_running.rb +0 -21
- data/lib/vagrant-lxc/action/created.rb +0 -20
- data/lib/vagrant-lxc/action/disconnect.rb +0 -18
- data/lib/vagrant-lxc/action/is_running.rb +0 -19
- data/spec/acceptance/sanity_check_spec.rb +0 -111
- data/spec/acceptance/support/acceptance_example_group.rb +0 -76
- data/spec/acceptance/support/machine_ext.rb +0 -12
- data/spec/acceptance/support/test_ui.rb +0 -22
- data/spec/acceptance_helper.rb +0 -21
data/spec/unit_helper.rb
CHANGED
@@ -7,9 +7,11 @@ if defined? SimpleCov
|
|
7
7
|
end
|
8
8
|
|
9
9
|
RSpec.configure do |config|
|
10
|
-
config.include RSpec::Fire
|
11
|
-
|
12
10
|
config.include UnitExampleGroup, :type => :unit, :example_group => {
|
13
11
|
:file_path => /\bspec\/unit\//
|
14
12
|
}
|
13
|
+
|
14
|
+
config.mock_with :rspec do |c|
|
15
|
+
c.yield_receiver_to_any_instance_implementation_blocks = true
|
16
|
+
end
|
15
17
|
end
|
data/tasks/spec.rake
CHANGED
@@ -3,7 +3,7 @@ begin
|
|
3
3
|
require 'coveralls/rake/task'
|
4
4
|
|
5
5
|
desc 'Run all specs'
|
6
|
-
task :spec => ['spec:unit', 'spec:acceptance']
|
6
|
+
task :spec => ['spec:set_coverage', 'spec:unit', 'spec:acceptance']
|
7
7
|
|
8
8
|
desc 'Default task which runs all specs with code coverage enabled'
|
9
9
|
task :default => ['spec:set_coverage', 'spec:unit']
|
@@ -17,17 +17,24 @@ namespace :spec do
|
|
17
17
|
ENV['COVERAGE'] = 'true'
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
desc 'Run acceptance specs using vagrant-spec'
|
21
|
+
task :acceptance do
|
22
|
+
components = %w(
|
23
|
+
basic
|
24
|
+
network/forwarded_port
|
25
|
+
synced_folder
|
26
|
+
synced_folder/nfs
|
27
|
+
synced_folder/rsync
|
28
|
+
provisioner/shell
|
29
|
+
provisioner/puppet
|
30
|
+
provisioner/chef-solo
|
31
|
+
package
|
32
|
+
).map{|s| "provider/lxc/#{s}" }
|
33
|
+
sh "export ACCEPTANCE=true && bundle exec vagrant-spec test --components=#{components.join(' ')}"
|
23
34
|
end
|
24
|
-
types.each do |type, dir|
|
25
|
-
desc "Run the code examples in #{dir}"
|
26
|
-
RSpec::Core::RakeTask.new(type) do |t|
|
27
|
-
# Tells rspec-fire to verify if constants used really exist
|
28
|
-
ENV['VERIFY_CONSTANT_NAMES'] = '1'
|
29
35
|
|
30
|
-
|
31
|
-
|
36
|
+
desc "Run unit specs with rspec"
|
37
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
38
|
+
t.pattern = "./unit/**/*_spec.rb"
|
32
39
|
end
|
33
40
|
end
|
data/vagrant-lxc.gemspec
CHANGED
@@ -17,4 +17,11 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.post_install_message = %Q{
|
22
|
+
Thanks for giving vagrant-lxc #{Vagrant::LXC::VERSION} a try!
|
23
|
+
This version introduces many changes and includes some deprecations,
|
24
|
+
please see the project's CHANGELOG:
|
25
|
+
https://github.com/fgrehm/vagrant-lxc/blob/master/CHANGELOG.md
|
26
|
+
}
|
20
27
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# FIXME: Figure out why this doesn't work
|
2
|
+
if ENV['COVERAGE'] == 'true'
|
3
|
+
require 'simplecov'
|
4
|
+
require 'coveralls'
|
5
|
+
|
6
|
+
SimpleCov.start { add_filter '/spec/' }
|
7
|
+
SimpleCov.command_name 'acceptance'
|
8
|
+
end
|
9
|
+
|
10
|
+
if ENV['BOX_PATH'] == nil
|
11
|
+
latest = ENV.fetch('LATEST_BOXES','2014-03-21')
|
12
|
+
release = ENV.fetch('RELEASE', 'acceptance')
|
13
|
+
local_path ="#{File.expand_path("../", __FILE__)}/boxes/output/#{latest}/vagrant-lxc-#{release}-amd64.box"
|
14
|
+
if File.exists?(local_path)
|
15
|
+
ENV['BOX_PATH'] = local_path
|
16
|
+
else
|
17
|
+
raise 'Set $BOX_PATH to the latest released boxes'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Vagrant::Spec::Acceptance.configure do |c|
|
22
|
+
c.component_paths << "spec/acceptance"
|
23
|
+
c.provider 'lxc', box: ENV['BOX_PATH'], features: ['!suspend']
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-lxc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Rehm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Linux Containers provider for Vagrant
|
14
14
|
email:
|
@@ -30,20 +30,6 @@ files:
|
|
30
30
|
- LICENSE.txt
|
31
31
|
- README.md
|
32
32
|
- Rakefile
|
33
|
-
- boxes/build-all.sh
|
34
|
-
- boxes/build-debian-box.sh
|
35
|
-
- boxes/build-openmandriva-box.sh
|
36
|
-
- boxes/build-ubuntu-box.sh
|
37
|
-
- boxes/common/cleanup
|
38
|
-
- boxes/common/install-babushka
|
39
|
-
- boxes/common/install-chef
|
40
|
-
- boxes/common/install-puppet
|
41
|
-
- boxes/common/install-salt
|
42
|
-
- boxes/common/install-salt-debian
|
43
|
-
- boxes/common/lxc-template
|
44
|
-
- boxes/common/lxc-template-openmandriva
|
45
|
-
- boxes/common/lxc.conf
|
46
|
-
- boxes/common/metadata.json
|
47
33
|
- development/Vagrantfile
|
48
34
|
- development/lxc-configs/lxc-dev-box
|
49
35
|
- development/lxc-configs/sid
|
@@ -51,45 +37,48 @@ files:
|
|
51
37
|
- development/lxc-configs/vbox
|
52
38
|
- development/lxc-configs/wheezy
|
53
39
|
- development/site.pp
|
40
|
+
- lib/vagrant-backports/README.md
|
41
|
+
- lib/vagrant-backports/action/handle_box.rb
|
42
|
+
- lib/vagrant-backports/action/is_state.rb
|
43
|
+
- lib/vagrant-backports/action/message.rb
|
44
|
+
- lib/vagrant-backports/action/wait_for_communicator.rb
|
45
|
+
- lib/vagrant-backports/ui.rb
|
46
|
+
- lib/vagrant-backports/utils.rb
|
54
47
|
- lib/vagrant-lxc.rb
|
55
48
|
- lib/vagrant-lxc/action.rb
|
56
49
|
- lib/vagrant-lxc/action/boot.rb
|
57
|
-
- lib/vagrant-lxc/action/check_created.rb
|
58
|
-
- lib/vagrant-lxc/action/check_running.rb
|
59
50
|
- lib/vagrant-lxc/action/clear_forwarded_ports.rb
|
60
51
|
- lib/vagrant-lxc/action/compress_rootfs.rb
|
61
52
|
- lib/vagrant-lxc/action/create.rb
|
62
|
-
- lib/vagrant-lxc/action/created.rb
|
63
53
|
- lib/vagrant-lxc/action/destroy.rb
|
64
54
|
- lib/vagrant-lxc/action/destroy_confirm.rb
|
65
|
-
- lib/vagrant-lxc/action/disconnect.rb
|
66
55
|
- lib/vagrant-lxc/action/fetch_ip_from_dnsmasq_leases.rb
|
67
56
|
- lib/vagrant-lxc/action/fetch_ip_with_lxc_attach.rb
|
68
57
|
- lib/vagrant-lxc/action/forced_halt.rb
|
69
58
|
- lib/vagrant-lxc/action/forward_ports.rb
|
70
59
|
- lib/vagrant-lxc/action/handle_box_metadata.rb
|
71
|
-
- lib/vagrant-lxc/action/is_running.rb
|
72
60
|
- lib/vagrant-lxc/action/message.rb
|
61
|
+
- lib/vagrant-lxc/action/prepare_nfs_settings.rb
|
62
|
+
- lib/vagrant-lxc/action/prepare_nfs_valid_ids.rb
|
73
63
|
- lib/vagrant-lxc/action/remove_temporary_files.rb
|
74
64
|
- lib/vagrant-lxc/action/setup_package_files.rb
|
75
|
-
- lib/vagrant-lxc/action/share_folders.rb
|
76
|
-
- lib/vagrant-lxc/action/wait_for_communicator.rb
|
77
65
|
- lib/vagrant-lxc/action/warn_networks.rb
|
66
|
+
- lib/vagrant-lxc/backports/action/share_folders.rb
|
67
|
+
- lib/vagrant-lxc/command/root.rb
|
68
|
+
- lib/vagrant-lxc/command/sudoers.rb
|
78
69
|
- lib/vagrant-lxc/config.rb
|
79
70
|
- lib/vagrant-lxc/driver.rb
|
80
71
|
- lib/vagrant-lxc/driver/cli.rb
|
81
72
|
- lib/vagrant-lxc/errors.rb
|
82
73
|
- lib/vagrant-lxc/plugin.rb
|
83
74
|
- lib/vagrant-lxc/provider.rb
|
75
|
+
- lib/vagrant-lxc/provider/cap/public_address.rb
|
84
76
|
- lib/vagrant-lxc/sudo_wrapper.rb
|
77
|
+
- lib/vagrant-lxc/synced_folder.rb
|
85
78
|
- lib/vagrant-lxc/version.rb
|
86
79
|
- locales/en.yml
|
80
|
+
- scripts/lxc-template
|
87
81
|
- spec/Vagrantfile
|
88
|
-
- spec/acceptance/sanity_check_spec.rb
|
89
|
-
- spec/acceptance/support/acceptance_example_group.rb
|
90
|
-
- spec/acceptance/support/machine_ext.rb
|
91
|
-
- spec/acceptance/support/test_ui.rb
|
92
|
-
- spec/acceptance_helper.rb
|
93
82
|
- spec/fixtures/sample-ip-addr-output
|
94
83
|
- spec/spec_helper.rb
|
95
84
|
- spec/support/.gitkeep
|
@@ -104,11 +93,15 @@ files:
|
|
104
93
|
- spec/unit_helper.rb
|
105
94
|
- tasks/spec.rake
|
106
95
|
- vagrant-lxc.gemspec
|
96
|
+
- vagrant-spec.config.rb
|
107
97
|
homepage: https://github.com/fgrehm/vagrant-lxc
|
108
98
|
licenses:
|
109
99
|
- MIT
|
110
100
|
metadata: {}
|
111
|
-
post_install_message:
|
101
|
+
post_install_message: "\n Thanks for giving vagrant-lxc 1.0.0.alpha.1 a try!\n This
|
102
|
+
version introduces many changes and includes some deprecations,\n please see the
|
103
|
+
project's CHANGELOG:\n https://github.com/fgrehm/vagrant-lxc/blob/master/CHANGELOG.md\n
|
104
|
+
\ "
|
112
105
|
rdoc_options: []
|
113
106
|
require_paths:
|
114
107
|
- lib
|
@@ -119,9 +112,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
112
|
version: '0'
|
120
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
114
|
requirements:
|
122
|
-
- - "
|
115
|
+
- - ">"
|
123
116
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
117
|
+
version: 1.3.1
|
125
118
|
requirements: []
|
126
119
|
rubyforge_project:
|
127
120
|
rubygems_version: 2.2.2
|
@@ -130,11 +123,6 @@ specification_version: 4
|
|
130
123
|
summary: Linux Containers provider for Vagrant
|
131
124
|
test_files:
|
132
125
|
- spec/Vagrantfile
|
133
|
-
- spec/acceptance/sanity_check_spec.rb
|
134
|
-
- spec/acceptance/support/acceptance_example_group.rb
|
135
|
-
- spec/acceptance/support/machine_ext.rb
|
136
|
-
- spec/acceptance/support/test_ui.rb
|
137
|
-
- spec/acceptance_helper.rb
|
138
126
|
- spec/fixtures/sample-ip-addr-output
|
139
127
|
- spec/spec_helper.rb
|
140
128
|
- spec/support/.gitkeep
|
data/boxes/build-all.sh
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# set -x
|
4
|
-
set -e
|
5
|
-
|
6
|
-
# Convenience script used for building all of the base boxes available
|
7
|
-
|
8
|
-
# Ubuntu boxes
|
9
|
-
sudo -E ./build-ubuntu-box.sh precise
|
10
|
-
sudo -E ./build-ubuntu-box.sh quantal
|
11
|
-
sudo -E ./build-ubuntu-box.sh raring
|
12
|
-
sudo -E ./build-ubuntu-box.sh saucy
|
13
|
-
|
14
|
-
# Debian boxes
|
15
|
-
sudo -E ./build-debian-box.sh squeeze
|
16
|
-
sudo -E ./build-debian-box.sh wheezy
|
17
|
-
sudo -E ./build-debian-box.sh sid
|
18
|
-
|
19
|
-
for box in precise raring quantal saucy squeeze wheezy sid; do
|
20
|
-
box="vagrant-lxc-${box}-amd64-`date +%Y-%m-%d`.box"
|
21
|
-
~/bin/dropbox_uploader.sh upload output/${box} Public/
|
22
|
-
done
|
data/boxes/build-debian-box.sh
DELETED
@@ -1,167 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# set -x
|
4
|
-
set -e
|
5
|
-
|
6
|
-
# Script used to build Debian base vagrant-lxc containers, currently limited to
|
7
|
-
# host's arch
|
8
|
-
#
|
9
|
-
# USAGE:
|
10
|
-
# $ cd boxes && sudo ./build-debian-box.sh DEBIAN_RELEASE
|
11
|
-
#
|
12
|
-
# To enable Chef or any other configuration management tool pass '1' to the
|
13
|
-
# corresponding env var:
|
14
|
-
# $ CHEF=1 sudo -E ./build-debian-box.sh DEBIAN_RELEASE
|
15
|
-
# $ PUPPET=1 sudo -E ./build-debian-box.sh DEBIAN_RELEASE
|
16
|
-
# $ SALT=1 sudo -E ./build-debian-box.sh DEBIAN_RELEASE
|
17
|
-
# $ BABUSHKA=1 sudo -E ./build-debian-box.sh DEBIAN_RELEASE
|
18
|
-
|
19
|
-
##################################################################################
|
20
|
-
# 0 - Initial setup and sanity checks
|
21
|
-
|
22
|
-
TODAY=$(date -u +"%Y-%m-%d")
|
23
|
-
NOW=$(date -u)
|
24
|
-
RELEASE=${1:-"wheezy"}
|
25
|
-
ARCH=$(dpkg --print-architecture) # This is what the Debian template will use under the hood
|
26
|
-
PKG=vagrant-lxc-${RELEASE}-${ARCH}-${TODAY}.box
|
27
|
-
WORKING_DIR=/tmp/vagrant-lxc-${RELEASE}
|
28
|
-
VAGRANT_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
|
29
|
-
ROOTFS=/var/lib/lxc/${RELEASE}-base/rootfs
|
30
|
-
|
31
|
-
# Providing '1' will enable these tools
|
32
|
-
CHEF=${CHEF:-0}
|
33
|
-
PUPPET=${PUPPET:-0}
|
34
|
-
SALT=${SALT:-0}
|
35
|
-
BABUSHKA=${BABUSHKA:-0}
|
36
|
-
|
37
|
-
# Path to files bundled with the box
|
38
|
-
CWD=`readlink -f .`
|
39
|
-
LXC_TEMPLATE=${CWD}/common/lxc-template
|
40
|
-
LXC_CONF=${CWD}/common/lxc.conf
|
41
|
-
METATADA_JSON=${CWD}/common/metadata.json
|
42
|
-
|
43
|
-
# Set up a working dir
|
44
|
-
mkdir -p $WORKING_DIR
|
45
|
-
|
46
|
-
if [ -f "${WORKING_DIR}/${PKG}" ]; then
|
47
|
-
echo "Found a box on ${WORKING_DIR}/${PKG} already!"
|
48
|
-
exit 1
|
49
|
-
fi
|
50
|
-
|
51
|
-
##################################################################################
|
52
|
-
# 1 - Create the base container
|
53
|
-
|
54
|
-
if $(lxc-ls | grep -q "${RELEASE}-base"); then
|
55
|
-
echo "Base container already exists, please remove it with \`lxc-destroy -n ${RELEASE}-base\`!"
|
56
|
-
exit 1
|
57
|
-
else
|
58
|
-
export SUITE=$RELEASE
|
59
|
-
lxc-create -n ${RELEASE}-base -t debian
|
60
|
-
fi
|
61
|
-
|
62
|
-
|
63
|
-
######################################
|
64
|
-
# 2 - Fix some known issues
|
65
|
-
|
66
|
-
# Fixes some networking issues
|
67
|
-
# See https://github.com/fgrehm/vagrant-lxc/issues/91 for more info
|
68
|
-
sed -i -e "s/\(127.0.0.1\s\+localhost\)/\1\n127.0.1.1\t${RELEASE}-base\n/g" ${ROOTFS}/etc/hosts
|
69
|
-
|
70
|
-
# Ensures that `/tmp` does not get cleared on halt
|
71
|
-
# See https://github.com/fgrehm/vagrant-lxc/issues/68 for more info
|
72
|
-
chroot $ROOTFS /usr/sbin/update-rc.d -f checkroot-bootclean.sh remove
|
73
|
-
chroot $ROOTFS /usr/sbin/update-rc.d -f mountall-bootclean.sh remove
|
74
|
-
chroot $ROOTFS /usr/sbin/update-rc.d -f mountnfs-bootclean.sh remove
|
75
|
-
|
76
|
-
# Ensure locales are properly set, based on http://linux.livejournal.com/1880366.html
|
77
|
-
sed -i "s/^# en_US/en_US/" ${ROOTFS}/etc/locale.gen
|
78
|
-
chroot $ROOTFS /usr/sbin/locale-gen
|
79
|
-
chroot $ROOTFS update-locale LANG=en_US.UTF-8
|
80
|
-
|
81
|
-
|
82
|
-
##################################################################################
|
83
|
-
# 3 - Prepare vagrant user
|
84
|
-
sudo chroot ${ROOTFS} useradd --create-home -s /bin/bash vagrant
|
85
|
-
|
86
|
-
echo -n 'vagrant:vagrant' | chroot ${ROOTFS} chpasswd
|
87
|
-
|
88
|
-
|
89
|
-
##################################################################################
|
90
|
-
# 4 - Setup SSH access and passwordless sudo
|
91
|
-
|
92
|
-
# Configure SSH access
|
93
|
-
mkdir -p ${ROOTFS}/home/vagrant/.ssh
|
94
|
-
echo $VAGRANT_KEY > ${ROOTFS}/home/vagrant/.ssh/authorized_keys
|
95
|
-
chroot ${ROOTFS} chown -R vagrant: /home/vagrant/.ssh
|
96
|
-
|
97
|
-
chroot ${ROOTFS} apt-get install sudo -y --force-yes
|
98
|
-
chroot ${ROOTFS} adduser vagrant sudo
|
99
|
-
|
100
|
-
# Enable passwordless sudo for users under the "sudo" group
|
101
|
-
cp ${ROOTFS}/etc/sudoers{,.orig}
|
102
|
-
sed -i -e \
|
103
|
-
's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' \
|
104
|
-
${ROOTFS}/etc/sudoers
|
105
|
-
|
106
|
-
|
107
|
-
##################################################################################
|
108
|
-
# 5 - Add some goodies and update packages
|
109
|
-
|
110
|
-
PACKAGES=(vim curl wget man-db bash-completion ca-certificates)
|
111
|
-
chroot ${ROOTFS} apt-get install ${PACKAGES[*]} -y --force-yes
|
112
|
-
chroot ${ROOTFS} apt-get upgrade -y --force-yes
|
113
|
-
|
114
|
-
|
115
|
-
##################################################################################
|
116
|
-
# 6 - Configuration management tools
|
117
|
-
|
118
|
-
if [ $CHEF = 1 ]; then
|
119
|
-
./common/install-chef $ROOTFS
|
120
|
-
fi
|
121
|
-
|
122
|
-
if [ $PUPPET = 1 ]; then
|
123
|
-
./common/install-puppet $ROOTFS
|
124
|
-
fi
|
125
|
-
|
126
|
-
if [ $SALT = 1 ]; then
|
127
|
-
./common/install-salt-debian $ROOTFS
|
128
|
-
fi
|
129
|
-
|
130
|
-
if [ $BABUSHKA = 1 ]; then
|
131
|
-
./common/install-babushka $ROOTFS
|
132
|
-
fi
|
133
|
-
|
134
|
-
|
135
|
-
##################################################################################
|
136
|
-
# 7 - Free up some disk space
|
137
|
-
|
138
|
-
rm -rf ${ROOTFS}/tmp/*
|
139
|
-
chroot ${ROOTFS} apt-get clean
|
140
|
-
|
141
|
-
|
142
|
-
##################################################################################
|
143
|
-
# 8 - Build box package
|
144
|
-
|
145
|
-
# Compress container's rootfs
|
146
|
-
cd $(dirname $ROOTFS)
|
147
|
-
tar --numeric-owner -czf /tmp/vagrant-lxc-${RELEASE}/rootfs.tar.gz ./rootfs/*
|
148
|
-
|
149
|
-
# Prepare package contents
|
150
|
-
cd $WORKING_DIR
|
151
|
-
cp $LXC_TEMPLATE .
|
152
|
-
cp $LXC_CONF .
|
153
|
-
cp $METATADA_JSON .
|
154
|
-
chmod +x lxc-template
|
155
|
-
sed -i "s/<TODAY>/${NOW}/" metadata.json
|
156
|
-
|
157
|
-
# Vagrant box!
|
158
|
-
tar -czf $PKG ./*
|
159
|
-
|
160
|
-
chmod +rw ${WORKING_DIR}/${PKG}
|
161
|
-
mkdir -p ${CWD}/output
|
162
|
-
mv ${WORKING_DIR}/${PKG} ${CWD}/output
|
163
|
-
|
164
|
-
# Clean up after ourselves
|
165
|
-
rm -rf ${WORKING_DIR}
|
166
|
-
|
167
|
-
echo "The base box was built successfully to ${CWD}/output/${PKG}"
|
@@ -1,159 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# set -x
|
4
|
-
set -e
|
5
|
-
|
6
|
-
# Script used to build OpenMandriva base vagrant-lxc containers, currently limited to
|
7
|
-
# host's arch
|
8
|
-
#
|
9
|
-
# USAGE:
|
10
|
-
# $ cd boxes && sudo ./build-openmandriva-box.sh OPENMANDRIVA_RELEASE BOX_ARCH
|
11
|
-
#
|
12
|
-
# TODO: scripts for install CHEF, PUPPET, SALT, BABUSHKA
|
13
|
-
# To enable Chef or any other configuration management tool pass '1' to the
|
14
|
-
# corresponding env var:
|
15
|
-
# $ CHEF=1 sudo -E ./build-openmandriva-box.sh OPENMANDRIVA_RELEASE BOX_ARCH
|
16
|
-
# $ PUPPET=1 sudo -E ./build-openmandriva-box.sh OPENMANDRIVA_RELEASE BOX_ARCH
|
17
|
-
# $ SALT=1 sudo -E ./build-openmandriva-box.sh OPENMANDRIVA_RELEASE BOX_ARCH
|
18
|
-
# $ BABUSHKA=1 sudo -E ./build-openmandriva-box.sh OPENMANDRIVA_RELEASE BOX_ARCH
|
19
|
-
|
20
|
-
##################################################################################
|
21
|
-
# 0 - Initial setup and sanity checks
|
22
|
-
|
23
|
-
TODAY=$(date -u +"%Y-%m-%d")
|
24
|
-
NOW=$(date -u)
|
25
|
-
RELEASE=${1:-"openmandriva2013.0"}
|
26
|
-
ARCH=${2:-"x86_64"}
|
27
|
-
PKG=vagrant-lxc-${RELEASE}-${ARCH}-${TODAY}.box
|
28
|
-
WORKING_DIR=/tmp/vagrant-lxc-${RELEASE}
|
29
|
-
VAGRANT_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
|
30
|
-
ROOTFS=/var/lib/lxc/${RELEASE}-base/${RELEASE}-base/rootfs
|
31
|
-
|
32
|
-
# Providing '1' will enable these tools
|
33
|
-
CHEF=${CHEF:-0}
|
34
|
-
PUPPET=${PUPPET:-0}
|
35
|
-
SALT=${SALT:-0}
|
36
|
-
BABUSHKA=${BABUSHKA:-0}
|
37
|
-
|
38
|
-
# Path to files bundled with the box
|
39
|
-
CWD=`readlink -f .`
|
40
|
-
LXC_TEMPLATE=${CWD}/common/lxc-template-openmandriva
|
41
|
-
LXC_CONF=${CWD}/common/lxc.conf
|
42
|
-
METATADA_JSON=${CWD}/common/metadata.json
|
43
|
-
|
44
|
-
# Set up a working dir
|
45
|
-
mkdir -p $WORKING_DIR
|
46
|
-
|
47
|
-
if [ -f "${WORKING_DIR}/${PKG}" ]; then
|
48
|
-
echo "Found a box on ${WORKING_DIR}/${PKG} already!"
|
49
|
-
exit 1
|
50
|
-
fi
|
51
|
-
|
52
|
-
##################################################################################
|
53
|
-
# 1 - Create the base container
|
54
|
-
|
55
|
-
if $(lxc-ls | grep -q "${RELEASE}-base"); then
|
56
|
-
echo "Base container already exists, please remove it with \`lxc-destroy -n ${RELEASE}-base\`!"
|
57
|
-
exit 1
|
58
|
-
else
|
59
|
-
export SUITE=$RELEASE
|
60
|
-
lxc-create -n ${RELEASE}-base -t openmandriva -- -R ${RELEASE} --arch ${ARCH}
|
61
|
-
fi
|
62
|
-
|
63
|
-
|
64
|
-
######################################
|
65
|
-
# 2 - Fix some known issues
|
66
|
-
|
67
|
-
# Fixes some networking issues
|
68
|
-
cat /etc/resolv.conf > ${ROOTFS}/etc/resolv.conf
|
69
|
-
|
70
|
-
##################################################################################
|
71
|
-
# 3 - Prepare vagrant user
|
72
|
-
chroot ${ROOTFS} su -c 'useradd --create-home -s /bin/bash vagrant'
|
73
|
-
|
74
|
-
# echo -n 'vagrant:vagrant' | chroot ${ROOTFS} chpasswd
|
75
|
-
chroot ${ROOTFS} su -c "echo -n 'vagrant:vagrant' | chpasswd"
|
76
|
-
|
77
|
-
|
78
|
-
##################################################################################
|
79
|
-
# 4 - Setup SSH access and passwordless sudo
|
80
|
-
|
81
|
-
# Configure SSH access
|
82
|
-
mkdir -p ${ROOTFS}/home/vagrant/.ssh
|
83
|
-
echo $VAGRANT_KEY > ${ROOTFS}/home/vagrant/.ssh/authorized_keys
|
84
|
-
chroot ${ROOTFS} chown -R vagrant: /home/vagrant/.ssh
|
85
|
-
|
86
|
-
chroot ${ROOTFS} urpmi sudo --auto
|
87
|
-
chroot ${ROOTFS} usermod -a -G wheel vagrant
|
88
|
-
|
89
|
-
# Enable passwordless sudo for users under the "sudo" group
|
90
|
-
cp ${ROOTFS}/etc/sudoers{,.orig}
|
91
|
-
sed -i 's/Defaults requiretty/\# Defaults requiretty/' ${ROOTFS}/etc/sudoers
|
92
|
-
sed -i 's/\#%wheel/\%wheel/' ${ROOTFS}/etc/sudoers
|
93
|
-
sed -i 's/\# %wheel/\%wheel/' ${ROOTFS}/etc/sudoers
|
94
|
-
# sed -i -e \
|
95
|
-
# 's/%sudo\s\+ALL=(ALL\(:ALL\)\?)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' \
|
96
|
-
# ${ROOTFS}/etc/sudoers
|
97
|
-
|
98
|
-
|
99
|
-
##################################################################################
|
100
|
-
# 5 - Add some goodies and update packages
|
101
|
-
|
102
|
-
PACKAGES=(vim curl wget man bash-completion openssh-server openssh-clients tar)
|
103
|
-
chroot ${ROOTFS} urpmi ${PACKAGES[*]} --auto
|
104
|
-
chroot ${ROOTFS} urpmi.update -a
|
105
|
-
|
106
|
-
|
107
|
-
##################################################################################
|
108
|
-
# 6 - Configuration management tools
|
109
|
-
|
110
|
-
if [ $CHEF = 1 ]; then
|
111
|
-
./common/install-chef $ROOTFS
|
112
|
-
fi
|
113
|
-
|
114
|
-
if [ $PUPPET = 1 ]; then
|
115
|
-
./common/install-puppet $ROOTFS
|
116
|
-
fi
|
117
|
-
|
118
|
-
if [ $SALT = 1 ]; then
|
119
|
-
./common/install-salt $ROOTFS
|
120
|
-
fi
|
121
|
-
|
122
|
-
if [ $BABUSHKA = 1 ]; then
|
123
|
-
./common/install-babushka $ROOTFS
|
124
|
-
fi
|
125
|
-
|
126
|
-
|
127
|
-
##################################################################################
|
128
|
-
# 7 - Free up some disk space
|
129
|
-
|
130
|
-
rm -rf ${ROOTFS}/tmp/*
|
131
|
-
# chroot ${ROOTFS} urpmi clean metadata
|
132
|
-
|
133
|
-
|
134
|
-
##################################################################################
|
135
|
-
# 8 - Build box package
|
136
|
-
|
137
|
-
# Compress container's rootfs
|
138
|
-
cd $(dirname $ROOTFS)
|
139
|
-
tar --numeric-owner -czf /tmp/vagrant-lxc-${RELEASE}/rootfs.tar.gz ./rootfs/*
|
140
|
-
|
141
|
-
# Prepare package contents
|
142
|
-
cd $WORKING_DIR
|
143
|
-
cp $LXC_TEMPLATE lxc-template
|
144
|
-
cp $LXC_CONF .
|
145
|
-
cp $METATADA_JSON .
|
146
|
-
chmod +x lxc-template
|
147
|
-
sed -i "s/<TODAY>/${NOW}/" metadata.json
|
148
|
-
|
149
|
-
# Vagrant box!
|
150
|
-
tar -czf $PKG ./*
|
151
|
-
|
152
|
-
chmod +rw ${WORKING_DIR}/${PKG}
|
153
|
-
mkdir -p ${CWD}/output
|
154
|
-
mv ${WORKING_DIR}/${PKG} ${CWD}/output
|
155
|
-
|
156
|
-
# Clean up after ourselves
|
157
|
-
rm -rf ${WORKING_DIR}
|
158
|
-
|
159
|
-
echo "The base box was built successfully to ${CWD}/output/${PKG}"
|