From 8bbf1b3fec275d8581f9b27ae6d34b3d4bcec9e0 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Mon, 1 Jul 2013 23:29:10 +0200 Subject: [PATCH] Implemented BlackListModules --- providers/ec2/__init__.py | 3 ++- providers/ec2/tasks/boot.py | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index 523403a..f43eb51 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -41,7 +41,8 @@ def tasks(tasklist, manifest): apt.AptSources(), apt.AptUpgrade(), boot.ConfigureGrub(), - boot.ModifyFstab()) + boot.ModifyFstab(), + boot.BlackListModules()) from common.tasks import TriggerRollback tasklist.add(TriggerRollback()) diff --git a/providers/ec2/tasks/boot.py b/providers/ec2/tasks/boot.py index 7c87a4f..63a514d 100644 --- a/providers/ec2/tasks/boot.py +++ b/providers/ec2/tasks/boot.py @@ -36,17 +36,27 @@ class ConfigureGrub(Task): class ModifyFstab(Task): - description = 'Add root volume to the fstab' + description = 'Adding root volume to the fstab' phase = phases.system_modification def run(self, info): - fstab_path = os.path.join(info.root, 'etc/fstab') mount_opts = ['defaults'] if info.manifest.volume['filesystem'].lower() in ['ext2', 'ext3', 'ext4']: mount_opts.append('barrier=0') if info.manifest.volume['filesystem'].lower() == 'xfs': mount_opts.append('nobarrier') + fstab_path = os.path.join(info.root, 'etc/fstab') with open(fstab_path, 'a') as fstab: fstab.write(('/dev/xvda1 / {filesystem} {mount_opts} 1 1' .format(filesystem=info.manifest.volume['filesystem'].lower(), mount_opts=','.join(mount_opts)))) + + +class BlackListModules(Task): + description = 'Blacklisting kernel modules' + phase = phases.system_modification + + def run(self, info): + blacklist_path = os.path.join(info.root, 'etc/modprobe.d/blacklist.conf') + with open(blacklist_path, 'a') as blacklist: + blacklist.write(('# disable pc speaker\nblacklist pcspkr'))