Created
January 19, 2015 20:49
-
-
Save asakura/12ce4108ca2d34f561e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prepare your host machine | |
```sh-session | |
sudo apt-get install -y python-software-properties | |
sudo apt-add-repository -y ppa:ubuntu-lxc/stable | |
sudo apt-get update | |
sudo apt-get dist-upgrade | |
sudo apt-get install -y lxc | |
sudo modprobe ip6table_filter | |
``` | |
# Building | |
## Showing information abouts guests | |
```sh-session | |
sudo lxc-ls -f | |
``` | |
## Creating guest | |
```sh-session | |
GUEST_NAME=conjur-1 | |
sudo lxc-create -t ubuntu -n ${GUEST_NAME} -- -r precise | |
``` | |
## Fix guest settings | |
Upload keys, mount kernel's modules dep file... | |
```sh-session | |
echo -e "/lib/modules\t/var/lib/lxc/${GUEST_NAME}/rootfs/lib/modules\tnone\tbind\t0\t0" | sudo tee --append /var/lib/lxc/${GUEST_NAME}/fstab > /dev/null | |
echo -e '%sudo\tALL=NOPASSWD: ALL' | sudo tee --append /var/lib/lxc/${GUEST_NAME}/rootfs/etc/sudoers.d/nopasswd > /dev/null | |
echo -e 'Defaults\tenv_keep+=SSH_AUTH_SOCK' | sudo tee --append /var/lib/lxc/${GUEST_NAME}/rootfs/etc/sudoers.d/sshagent > /dev/null | |
echo -e 'Defaults\ttimestamp_timeout=6000' | sudo tee --append /var/lib/lxc/${GUEST_NAME}/rootfs/etc/sudoers.d/timeout > /dev/null | |
sudo chmod -R 0440 /var/lib/lxc/${GUEST_NAME}/rootfs/etc/sudoers.d | |
sudo chmod 0755 /var/lib/lxc/${GUEST_NAME}/rootfs/etc/sudoers.d | |
sudo mkdir /var/lib/lxc/${GUEST_NAME}/rootfs/home/ubuntu/.ssh | |
cat ~/.ssh/id_rsa.pub | sudo tee --append /var/lib/lxc/${GUEST_NAME}/rootfs/home/ubuntu/.ssh/authorized_keys > /dev/null | |
sudo mkdir -p /var/lib/lxc/${GUEST_NAME}/rootfs/var/chef/cache | |
sudo lxc-execute -n ${GUEST_NAME} -- sudo apt-get install -y dbus | |
``` | |
## Running/Stopping guest | |
```sh-session | |
sudo lxc-start -n ${GUEST_NAME} | |
``` | |
```sh-session | |
sudo lxc-stop -n ${GUEST_NAME} | |
``` | |
## Run chef on guest | |
```sh-session | |
bundle install | |
berks install | |
knife solo bootstrap --bootstrap-version 10.14.0 -r role[conjur] --forward-agent ubuntu@$(sudo lxc-info -iHn ${GUEST_NAME}) | |
``` | |
## Free some space | |
```sh-session | |
sudo lxc-attach -n ${GUEST_NAME} -- sudo apt-get purge -y build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev autoconf | |
sudo lxc-attach -n ${GUEST_NAME} -- sudo apt-get autoremove | |
sudo lxc-attach -n ${GUEST_NAME} -- sudo bash -c 'rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/* /opt/conjur/vendor/cache/* /opt/conjur/vendor/bundle/ruby/*/cache/* /opt/conjur/vendor/bundle/ruby/*/gems/nokogiri-*/ext/nokogiri/tmp/* /opt/conjur/vendor/bundle/ruby/*/gems/nokogiri-*/ports/archives/*' | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment