mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-07 17:40:30 +00:00
ec2: Add tasks for EC2 tuning
Snatched from PR #256 by @JamesBromberger
This commit is contained in:
parent
c14687a171
commit
98de220f78
4 changed files with 63 additions and 0 deletions
|
@ -8,6 +8,7 @@ import tasks.filesystem
|
|||
import tasks.boot
|
||||
import tasks.network
|
||||
import tasks.initd
|
||||
import tasks.tuning
|
||||
from bootstrapvz.common.tasks import volume
|
||||
from bootstrapvz.common.tasks import filesystem
|
||||
from bootstrapvz.common.tasks import boot
|
||||
|
@ -15,6 +16,7 @@ from bootstrapvz.common.tasks import grub
|
|||
from bootstrapvz.common.tasks import initd
|
||||
from bootstrapvz.common.tasks import loopback
|
||||
from bootstrapvz.common.tasks import kernel
|
||||
from bootstrapvz.common.tasks import apt
|
||||
|
||||
|
||||
def validate_manifest(data, validator, error):
|
||||
|
@ -65,6 +67,8 @@ def resolve_tasks(taskset, manifest):
|
|||
tasks.ami.AMIName,
|
||||
tasks.connection.Connect,
|
||||
|
||||
tasks.tuning.TuneSystem,
|
||||
tasks.tuning.BlackListModules,
|
||||
boot.BlackListModules,
|
||||
boot.DisableGetTTYs,
|
||||
initd.AddExpandRoot,
|
||||
|
@ -82,6 +86,8 @@ def resolve_tasks(taskset, manifest):
|
|||
taskset.add(tasks.network.EnableDHCPCDDNS)
|
||||
|
||||
if manifest.release >= jessie:
|
||||
taskset.add(apt.AddBackports)
|
||||
taskset.add(tasks.tuning.SetCloudInitMountOptions)
|
||||
taskset.add(tasks.packages.AddWorkaroundGrowpart)
|
||||
taskset.add(initd.AdjustGrowpartWorkaround)
|
||||
taskset.add(grub.EnableSystemd)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
mount_default_fields: [ None, None, "auto", "defaults,nofail", "0", "2" ]
|
15
bootstrapvz/providers/ec2/assets/sysctl.d/tuning.conf
Normal file
15
bootstrapvz/providers/ec2/assets/sysctl.d/tuning.conf
Normal file
|
@ -0,0 +1,15 @@
|
|||
vm.swappiness = 0
|
||||
vm.dirty_ratio = 80
|
||||
vm.dirty_background_ratio = 5
|
||||
vm.dirty_expire_centisecs = 12000
|
||||
net.core.somaxconn = 1000
|
||||
net.core.netdev_max_backlog = 5000
|
||||
net.core.rmem_max = 16777216
|
||||
net.core.wmem_max = 16777216
|
||||
net.ipv4.tcp_wmem = 4096 12582912 16777216
|
||||
net.ipv4.tcp_rmem = 4096 12582912 16777216
|
||||
net.ipv4.tcp_max_syn_backlog = 8096
|
||||
net.ipv4.tcp_slow_start_after_idle = 0
|
||||
net.ipv4.tcp_tw_reuse = 1
|
||||
net.ipv4.ip_local_port_range = 10240 65535
|
||||
kernel.sysrq = 0
|
41
bootstrapvz/providers/ec2/tasks/tuning.py
Normal file
41
bootstrapvz/providers/ec2/tasks/tuning.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
from bootstrapvz.base import Task
|
||||
from bootstrapvz.common import phases
|
||||
from . import assets
|
||||
from shutil import copy
|
||||
import os
|
||||
|
||||
|
||||
class TuneSystem(Task):
|
||||
description = 'Tuning system for EC2'
|
||||
phase = phases.system_modification
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
sysctl_src = os.path.join(assets, 'sysctl.d/tuning.conf')
|
||||
sysctl_dst = os.path.join(info.root, 'etc/sysctl.d/01_ec2.conf')
|
||||
copy(sysctl_src, sysctl_dst)
|
||||
os.chmod(sysctl_dst, 0644)
|
||||
|
||||
|
||||
class SetCloudInitMountOptions(Task):
|
||||
description = 'Setting cloud-init default mount options'
|
||||
phase = phases.system_modification
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
cloud_init_src = os.path.join(assets, 'cloud-init/debian_cloud.conf')
|
||||
cloud_init_dst = os.path.join(info.root, 'etc/cloud/cloud.cfg.d/01_debian_cloud.conf')
|
||||
copy(cloud_init_src, cloud_init_dst)
|
||||
os.chmod(cloud_init_dst, 0644)
|
||||
|
||||
|
||||
class BlackListModules(Task):
|
||||
description = 'Blacklisting unused kernel modules'
|
||||
phase = phases.system_modification
|
||||
|
||||
@classmethod
|
||||
def run(cls, info):
|
||||
blacklist_path = os.path.join(info.root, 'etc/modprobe.d/blacklist.conf')
|
||||
with open(blacklist_path, 'a') as blacklist:
|
||||
blacklist.write(('blacklist i2c_piix4\n'
|
||||
'blacklist psmouse\n'))
|
Loading…
Add table
Reference in a new issue