Tweaks to start a container from within the dev container
References #23
This commit is contained in:
parent
72893299f4
commit
e406be521a
6 changed files with 13 additions and 25 deletions
7
development/Vagrantfile
vendored
7
development/Vagrantfile
vendored
|
@ -30,13 +30,6 @@ Vagrant.configure("2") do |config|
|
||||||
lxc.start_opts << 'lxc.aa_profile=unconfined'
|
lxc.start_opts << 'lxc.aa_profile=unconfined'
|
||||||
end
|
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|
|
config.vm.provision :puppet do |puppet|
|
||||||
puppet.manifests_path = "."
|
puppet.manifests_path = "."
|
||||||
puppet.manifest_file = "site.pp"
|
puppet.manifest_file = "site.pp"
|
||||||
|
|
|
@ -27,7 +27,7 @@ USE_LXC_BRIDGE="true"
|
||||||
# name.
|
# name.
|
||||||
# If you have the dnsmasq daemon installed, you'll also have to update
|
# If you have the dnsmasq daemon installed, you'll also have to update
|
||||||
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
|
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
|
||||||
LXC_BRIDGE="lxcbr1"
|
LXC_BRIDGE="lxcbr0"
|
||||||
LXC_ADDR="10.0.254.1"
|
LXC_ADDR="10.0.254.1"
|
||||||
LXC_NETMASK="255.255.255.0"
|
LXC_NETMASK="255.255.255.0"
|
||||||
LXC_NETWORK="10.0.254.0/24"
|
LXC_NETWORK="10.0.254.0/24"
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Package ubuntu-cloud
|
# Package quantal64
|
||||||
if ! [ -f ../boxes/output/ubuntu-cloud.box ]; then
|
if ! [ -f ../boxes/output/lxc-quantal64.box ]; then
|
||||||
bundle exec rake boxes:build:ubuntu-cloud
|
bundle exec rake boxes:quantal64:build
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fresh start
|
# Fresh start
|
||||||
|
@ -13,12 +13,7 @@ bundle exec vagrant-lxc destroy
|
||||||
# Skip provisioning as we need to apt-get update first
|
# Skip provisioning as we need to apt-get update first
|
||||||
bundle exec vagrant-lxc up --provider=lxc --no-provision
|
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
|
bundle exec vagrant-lxc ssh -c 'sudo apt-get update && sudo apt-get install puppet -y'
|
||||||
# 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 provision
|
bundle exec vagrant-lxc provision
|
||||||
|
|
||||||
# Reload the container just to ensure it can boot properly after the upgrades
|
# Reload the container just to ensure it can boot properly after the upgrades
|
||||||
|
|
|
@ -2,11 +2,11 @@ Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/', '/usr/local/bin'
|
||||||
|
|
||||||
# Because I'm lazy ;)
|
# Because I'm lazy ;)
|
||||||
exec {
|
exec {
|
||||||
'echo "alias be=\"bundle exec\"" >> ~/.bashrc':
|
'echo "alias be=\"bundle exec\"" >> /home/vagrant/.bashrc':
|
||||||
unless => 'grep -q "bundle exec" ~/.bashrc';
|
unless => 'grep -q "bundle exec" /home/vagrant/.bashrc';
|
||||||
|
|
||||||
'echo "cd /vagrant" >> ~/.bashrc':
|
'echo "cd /vagrant" >> /home/vagrant/.bashrc':
|
||||||
unless => 'grep -q "cd /vagrant" ~/.bashrc';
|
unless => 'grep -q "cd /vagrant" /home/vagrant/.bashrc';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Overwrite LXC default configs
|
# 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.
|
# 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.
|
# 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',
|
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
|
# Install dependencies
|
||||||
package {
|
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'
|
ensure => 'installed'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
2
example/Vagrantfile
vendored
2
example/Vagrantfile
vendored
|
@ -7,11 +7,11 @@ Vagrant.configure("2") do |config|
|
||||||
config.vm.box = "quantal64"
|
config.vm.box = "quantal64"
|
||||||
config.vm.box_url = 'http://dl.dropbox.com/u/13510779/lxc-quantal64-2013-03-08.box'
|
config.vm.box_url = 'http://dl.dropbox.com/u/13510779/lxc-quantal64-2013-03-08.box'
|
||||||
config.vm.hostname = 'lxc-quantal64'
|
config.vm.hostname = 'lxc-quantal64'
|
||||||
config.vm.network :private_network, ip: "192.168.33.10"
|
|
||||||
|
|
||||||
config.vm.synced_folder "/tmp", "/vagrant_data"
|
config.vm.synced_folder "/tmp", "/vagrant_data"
|
||||||
|
|
||||||
config.vm.provider :lxc do |lxc|
|
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.limit_in_bytes=400M'
|
||||||
lxc.start_opts << 'lxc.cgroup.memory.memsw.limit_in_bytes=500M'
|
lxc.start_opts << 'lxc.cgroup.memory.memsw.limit_in_bytes=500M'
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,4 +3,3 @@ Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/'] }
|
||||||
notice "Hi there! puppet here"
|
notice "Hi there! puppet here"
|
||||||
|
|
||||||
require hello_world
|
require hello_world
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue