diff --git a/bootstrapvz/providers/ec2/__init__.py b/bootstrapvz/providers/ec2/__init__.py index b3f2287..f6ed3e9 100644 --- a/bootstrapvz/providers/ec2/__init__.py +++ b/bootstrapvz/providers/ec2/__init__.py @@ -65,7 +65,6 @@ def resolve_tasks(taskset, manifest): boot.BlackListModules, boot.DisableGetTTYs, - tasks.network.EnableDHCPCDDNS, initd.AddExpandRoot, initd.RemoveHWClock, initd.InstallInitScripts, @@ -73,6 +72,12 @@ def resolve_tasks(taskset, manifest): tasks.ami.RegisterAMI, ]) + from bootstrapvz.common.releases import wheezy + if manifest.release <= wheezy: + # The default DHCP client `isc-dhcp' doesn't work properly on wheezy and earlier + taskset.add(tasks.network.InstallDHCPCD) + taskset.add(tasks.network.EnableDHCPCDDNS) + if manifest.provider.get('install_init_scripts', True): taskset.add(tasks.initd.AddEC2InitScripts) diff --git a/bootstrapvz/providers/ec2/tasks/network.py b/bootstrapvz/providers/ec2/tasks/network.py index b707600..33c00d0 100644 --- a/bootstrapvz/providers/ec2/tasks/network.py +++ b/bootstrapvz/providers/ec2/tasks/network.py @@ -4,19 +4,27 @@ from bootstrapvz.common.tasks import kernel import os.path +class InstallDHCPCD(Task): + description = 'Replacing isc-dhcp with dhcpcd' + phase = phases.preparation + + @classmethod + def run(cls, info): + # isc-dhcp-client before jessie doesn't work properly with ec2 + info.packages.add('dhcpcd') + info.exclude_packages.add('isc-dhcp-client') + info.exclude_packages.add('isc-dhcp-common') + + class EnableDHCPCDDNS(Task): description = 'Configuring the DHCP client to set the nameservers' phase = phases.system_modification @classmethod def run(cls, info): - # The dhcp client that ships with debian sets the DNS servers per default. - # For dhcpcd in Wheezy and earlier we need to configure it to do that. - from bootstrapvz.common.releases import wheezy - if info.manifest.release <= wheezy: - from bootstrapvz.common.tools import sed_i - dhcpcd = os.path.join(info.root, 'etc/default/dhcpcd') - sed_i(dhcpcd, '^#*SET_DNS=.*', 'SET_DNS=\'yes\'') + from bootstrapvz.common.tools import sed_i + dhcpcd = os.path.join(info.root, 'etc/default/dhcpcd') + sed_i(dhcpcd, '^#*SET_DNS=.*', 'SET_DNS=\'yes\'') class AddBuildEssentialPackage(Task): diff --git a/bootstrapvz/providers/ec2/tasks/packages.py b/bootstrapvz/providers/ec2/tasks/packages.py index eab7b86..bec331c 100644 --- a/bootstrapvz/providers/ec2/tasks/packages.py +++ b/bootstrapvz/providers/ec2/tasks/packages.py @@ -9,14 +9,6 @@ class DefaultPackages(Task): @classmethod def run(cls, info): info.packages.add('file') # Needed for the init scripts - - # isc-dhcp-client before jessie doesn't work properly with ec2 - from bootstrapvz.common.releases import jessie - if info.manifest.release < jessie: - info.packages.add('dhcpcd') - info.exclude_packages.add('isc-dhcp-client') - info.exclude_packages.add('isc-dhcp-common') - import os.path kernel_packages_path = os.path.join(os.path.dirname(__file__), 'packages-kernels.yml') from bootstrapvz.common.tools import config_get