Skip to content

Instantly share code, notes, and snippets.

@bkreider
Created June 5, 2014 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkreider/a35d1daf58c0a89f0d64 to your computer and use it in GitHub Desktop.
Save bkreider/a35d1daf58c0a89f0d64 to your computer and use it in GitHub Desktop.
VZ configuration
def configure_vzkernel():
def run_in_vz(veid, cmd):
# Use pty so commands with sudo in them work
sudo("vzctl exec %s '%s'" % (veid, cmd), pty=True)
log.info("Downloading Centos6 VZ template")
sudo("wget http://download.openvz.org/template/precreated/centos-6-x86_64.tar.gz")
sudo("mv centos-6-x86_64.tar.gz /vz/template/cache")
sed("/boot/grub/menu.lst", before='^default=1$', after='default=0', use_sudo=True)
# OpenVZ turns off NAT - need to turn back on - performance bug but we need NAT
sed("/etc/modprobe.d/openvz.conf", before="ip_conntrack_disable_ve0=1",
after="ip_conntrack_disable_ve0=0", use_sudo=True)
sudo("shutdown -r now")
# Force Fabric to reconnect instead of caching the connection
disconnect_all()
log.info("Rebooting into OpenVZ kernel -- sleeping 90 seconds")
time.sleep(90)
VZ_SUBNET = "192.168.2.0/24"
host_node_ip = run("curl http://169.254.169.254/latest/meta-data/local-ipv4")
# Source NAT - 192.168.2.0/24 maps to the HN's private IP
sudo("iptables -t nat -A POSTROUTING -s %s -o eth0 -j SNAT --to %s"
% (VZ_SUBNET, host_node_ip))
# OpenVZ bug with ploop? http://en.5.ispdoc.com/index.php/No_space_left_on_device
sudo("echo 0 > /sys/module/ploop/parameters/root_threshold")
sudo("echo 0 > /sys/module/ploop/parameters/user_threshold")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment