diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index a719590..523403a 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -29,8 +29,7 @@ def tasks(tasklist, manifest): tasklist.add(filesystem.FormatVolume()) if manifest.volume['filesystem'].lower() == 'xfs': tasklist.add(filesystem.AddXFSProgs()) - import re - if re.search('ext.', manifest.volume['filesystem'].lower()): + if manifest.volume['filesystem'].lower() in ['ext2', 'ext3', 'ext4']: tasklist.add(filesystem.TuneVolumeFS()) tasklist.add(filesystem.CreateMountDir(), filesystem.MountVolume()) if manifest.bootstrapper['tarball']: @@ -41,7 +40,8 @@ def tasks(tasklist, manifest): locale.SetTimezone(), apt.AptSources(), apt.AptUpgrade(), - boot.ConfigureGrub()) + boot.ConfigureGrub(), + boot.ModifyFstab()) from common.tasks import TriggerRollback tasklist.add(TriggerRollback()) diff --git a/providers/ec2/tasks/apt.py b/providers/ec2/tasks/apt.py index 2968fd1..1f5d8d3 100644 --- a/providers/ec2/tasks/apt.py +++ b/providers/ec2/tasks/apt.py @@ -13,13 +13,13 @@ class AptSources(Task): sources_path = os.path.join(info.root, 'etc/apt/sources.list') with open(sources_path, 'w') as apt_sources: apt_sources.write(('deb {apt_mirror} {release} main\n' - 'deb-src {apt_mirror} {release} main\n'. - format(apt_mirror='http://http.debian.net/debian', - release=info.manifest.system['release']))) + 'deb-src {apt_mirror} {release} main\n' + .format(apt_mirror='http://http.debian.net/debian', + release=info.manifest.system['release']))) apt_sources.write(('deb {apt_mirror} {release}/updates main\n' - 'deb-src {apt_mirror} {release}/updates main\n'. - format(apt_mirror='http://security.debian.org/', - release=info.manifest.system['release']))) + 'deb-src {apt_mirror} {release}/updates main\n' + .format(apt_mirror='http://security.debian.org/', + release=info.manifest.system['release']))) class AptUpgrade(Task): diff --git a/providers/ec2/tasks/boot.py b/providers/ec2/tasks/boot.py index 9de037f..7c87a4f 100644 --- a/providers/ec2/tasks/boot.py +++ b/providers/ec2/tasks/boot.py @@ -33,3 +33,20 @@ class ConfigureGrub(Task): from common.tools import log_check_call log_check_call(['chroot', info.root, 'update-grub']) log_check_call(['chroot', info.root, 'ln', '-s', '/boot/grub/grub.cfg', '/boot/grub/menu.lst']) + + +class ModifyFstab(Task): + description = 'Add 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') + 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))))