Tweaks to start a container from within the dev container

References #23
This commit is contained in:
Fabio Rehm 2013-03-08 03:36:54 -03:00
parent 72893299f4
commit e406be521a
6 changed files with 13 additions and 25 deletions

View file

@ -30,13 +30,6 @@ Vagrant.configure("2") do |config|
lxc.start_opts << 'lxc.aa_profile=unconfined'
end
config.vm.provision :shell, inline: '
if ! [ -f /home/vagrant/.updated ]; then
sudo apt-get update &&
sudo apt-get install puppet -y &&
touch /home/vagrant/.updated
fi'
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "."
puppet.manifest_file = "site.pp"

View file

@ -27,7 +27,7 @@ USE_LXC_BRIDGE="true"
# name.
# If you have the dnsmasq daemon installed, you'll also have to update
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
LXC_BRIDGE="lxcbr1"
LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.254.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.254.0/24"

View file

@ -2,9 +2,9 @@
set -e
# Package ubuntu-cloud
if ! [ -f ../boxes/output/ubuntu-cloud.box ]; then
bundle exec rake boxes:build:ubuntu-cloud
# Package quantal64
if ! [ -f ../boxes/output/lxc-quantal64.box ]; then
bundle exec rake boxes:quantal64:build
fi
# Fresh start
@ -13,12 +13,7 @@ bundle exec vagrant-lxc destroy
# Skip provisioning as we need to apt-get update first
bundle exec vagrant-lxc up --provider=lxc --no-provision
# Trigger an update from here instead of doing it from puppet as we don't need to
# apt-get update every time we boot the container. If there is a way to do it
# from puppet I don't know. If you do, feel free to send a pull request ;)
bundle exec vagrant-lxc ssh -c '
sudo sed -i -e "s/archive./br.archive./g" /etc/apt/sources.list &&
sudo apt-get update'
bundle exec vagrant-lxc ssh -c 'sudo apt-get update && sudo apt-get install puppet -y'
bundle exec vagrant-lxc provision
# Reload the container just to ensure it can boot properly after the upgrades

View file

@ -2,11 +2,11 @@ Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/', '/usr/local/bin'
# Because I'm lazy ;)
exec {
'echo "alias be=\"bundle exec\"" >> ~/.bashrc':
unless => 'grep -q "bundle exec" ~/.bashrc';
'echo "alias be=\"bundle exec\"" >> /home/vagrant/.bashrc':
unless => 'grep -q "bundle exec" /home/vagrant/.bashrc';
'echo "cd /vagrant" >> ~/.bashrc':
unless => 'grep -q "cd /vagrant" ~/.bashrc';
'echo "cd /vagrant" >> /home/vagrant/.bashrc':
unless => 'grep -q "cd /vagrant" /home/vagrant/.bashrc';
}
# Overwrite LXC default configs
@ -15,12 +15,13 @@ exec {
# We need to do this otherwise IPs will collide with the host's lxc dhcp server.
# If we install the package prior to setting this configs the container will go crazy.
command => 'cp /vagrant/development/lxc-configs/lxc-dev-default /etc/default/lxc',
unless => 'grep -q "10.0.4" /etc/default/lxc'
unless => 'grep -q "10.0.254" /etc/default/lxc'
}
# Install dependencies
package {
[ 'libffi-dev', 'bsdtar', 'exuberant-ctags', 'ruby1.9.1-dev', 'htop', 'git', 'build-essential' ]:
[ 'libffi-dev', 'bsdtar', 'exuberant-ctags', 'ruby1.9.1-dev', 'htop', 'git',
'build-essential', 'dnsutils' ]:
ensure => 'installed'
;

2
example/Vagrantfile vendored
View file

@ -7,11 +7,11 @@ Vagrant.configure("2") do |config|
config.vm.box = "quantal64"
config.vm.box_url = 'http://dl.dropbox.com/u/13510779/lxc-quantal64-2013-03-08.box'
config.vm.hostname = 'lxc-quantal64'
config.vm.network :private_network, ip: "192.168.33.10"
config.vm.synced_folder "/tmp", "/vagrant_data"
config.vm.provider :lxc do |lxc|
lxc.lxc_dhcp_ip = '10.0.254.1' if ENV['USER'] == 'vagrant'
lxc.start_opts << 'lxc.cgroup.memory.limit_in_bytes=400M'
lxc.start_opts << 'lxc.cgroup.memory.memsw.limit_in_bytes=500M'
end

View file

@ -3,4 +3,3 @@ Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/'] }
notice "Hi there! puppet here"
require hello_world