diff --git a/base/manifest-schema.json b/base/manifest-schema.json index a5d09c3..b9adbbe 100644 --- a/base/manifest-schema.json +++ b/base/manifest-schema.json @@ -25,7 +25,7 @@ "system": { "type": "object", "properties": { - "release": { "enum": ["wheezy", "testing", "unstable"] }, + "release": { "enum": ["wheezy", "jessie", "testing", "unstable"] }, "sections": { "type": "array", "minItems": 1 diff --git a/common/tasks/host.py b/common/tasks/host.py index f156bf4..7bf79dd 100644 --- a/common/tasks/host.py +++ b/common/tasks/host.py @@ -35,7 +35,9 @@ class CheckHostDependencies(Task): missing_packages = [] for package in info.host_dependencies: try: - log_check_call(['/usr/bin/dpkg-query', '-s', package]) + import os.path + if os.path.isfile('/usr/bin/dpkg-query'): + log_check_call(['/usr/bin/dpkg-query', '-s', package]) except CalledProcessError: missing_packages.append(package) if len(missing_packages) > 0: diff --git a/common/tasks/network-configuration.json b/common/tasks/network-configuration.json index 44e540b..5a3c533 100644 --- a/common/tasks/network-configuration.json +++ b/common/tasks/network-configuration.json @@ -7,6 +7,9 @@ "wheezy": [ "auto eth0", "iface eth0 inet dhcp" ], + "jessie": [ + "auto eth0", + "iface eth0 inet dhcp" ], "testing": [ "auto eth0", "iface eth0 inet dhcp" ], diff --git a/common/tasks/network.py b/common/tasks/network.py index 32bfd01..8418a84 100644 --- a/common/tasks/network.py +++ b/common/tasks/network.py @@ -10,7 +10,9 @@ class RemoveDNSInfo(Task): @classmethod def run(cls, info): from os import remove - remove(os.path.join(info.root, 'etc/resolv.conf')) + import os.path + if os.path.isfile(os.path.join(info.root, 'etc/resolv.conf')): + remove(os.path.join(info.root, 'etc/resolv.conf')) class RemoveHostname(Task): @@ -20,7 +22,9 @@ class RemoveHostname(Task): @classmethod def run(cls, info): from os import remove - remove(os.path.join(info.root, 'etc/hostname')) + import os.path + if os.path.isfile(os.path.join(info.root, 'etc/hostname')): + remove(os.path.join(info.root, 'etc/hostname')) class ConfigureNetworkIF(Task): diff --git a/manifests/ec2-ebs-debian-official-amd64-hvm-cn-north-1.manifest.json b/manifests/ec2-ebs-debian-official-amd64-hvm-cn-north-1.manifest.json new file mode 100644 index 0000000..afd55ba --- /dev/null +++ b/manifests/ec2-ebs-debian-official-amd64-hvm-cn-north-1.manifest.json @@ -0,0 +1,44 @@ +{ + "provider": "ec2", + "virtualization": "hvm", + "credentials": { + // "access-key": null, + // "secret-key": null + }, + + "bootstrapper": { + "workspace": "/target" + }, + "image": { + "name": "debian-{system.release}-{system.architecture}-{virtualization}-{%Y}-{%m}-{%d}-ebs", + "description": "Debian {system.release} {system.architecture}" + }, + "system": { + "release": "wheezy", + "architecture": "amd64", + "bootloader": "extlinux", + "timezone": "UTC", + "locale": "en_US", + "charmap": "UTF-8" + }, + "packages": { + "mirror": "http://ftp.cn.debian.org/debian" + }, + "volume": { + "backing": "ebs", + "partitions": { + "type": "none", + "root": { + "size": "8GiB", + "filesystem": "ext4" + } + } + }, + "plugins": { + "cloud_init": { + "username": "admin", + //"metadata_sources": "Ec2", + "disable_modules": [ "landscape", "byobu", "ssh-import-id" ] + } + } +} diff --git a/manifests/ec2-ebs-debian-official-amd64-pvm-cn-north-1.manifest.json b/manifests/ec2-ebs-debian-official-amd64-pvm-cn-north-1.manifest.json new file mode 100644 index 0000000..18dd022 --- /dev/null +++ b/manifests/ec2-ebs-debian-official-amd64-pvm-cn-north-1.manifest.json @@ -0,0 +1,44 @@ +{ + "provider": "ec2", + "virtualization": "pvm", + "credentials": { + // "access-key": null, + // "secret-key": null + }, + + "bootstrapper": { + "workspace": "/target" + }, + "image": { + "name": "debian-{system.release}-{system.architecture}-{virtualization}-{%Y}-{%m}-{%d}-ebs", + "description": "Debian {system.release} {system.architecture}" + }, + "system": { + "release": "wheezy", + "architecture": "amd64", + "bootloader": "pvgrub", + "timezone": "UTC", + "locale": "en_US", + "charmap": "UTF-8" + }, + "packages": { + "mirror": "http://ftp.cn.debian.org/debian" + }, + "volume": { + "backing": "ebs", + "partitions": { + "type": "none", + "root": { + "size": "8GiB", + "filesystem": "ext4" + } + } + }, + "plugins": { + "cloud_init": { + "username": "admin", + //"metadata_sources": "Ec2", + "disable_modules": [ "landscape", "byobu", "ssh-import-id" ] + } + } +} diff --git a/manifests/ec2-s3-debian-official-amd64-pvm-cn-north-1.manifest.json b/manifests/ec2-s3-debian-official-amd64-pvm-cn-north-1.manifest.json new file mode 100644 index 0000000..57cf316 --- /dev/null +++ b/manifests/ec2-s3-debian-official-amd64-pvm-cn-north-1.manifest.json @@ -0,0 +1,47 @@ +{ + "provider": "ec2", + "virtualization": "pvm", + "credentials": { + // "access-key": null, + // "secret-key": null, + // "certificate": null, + // "private-key": null, + // "user-id": null + }, + + "bootstrapper": { + "workspace": "/target" + }, + "image": { + "name": "debian-{system.release}-{system.architecture}-{virtualization}-{%Y}-{%m}-{%d}", + "description": "Debian {system.release} {system.architecture} AMI", + "bucket": "debian-amis-cn-north-1" + }, + "system": { + "release": "wheezy", + "architecture": "amd64", + "bootloader": "pvgrub", + "timezone": "UTC", + "locale": "en_US", + "charmap": "UTF-8" + }, + "packages": { + "mirror": "http://ftp.cn.debian.org/debian" + }, + "volume": { + "backing": "s3", + "partitions": { + "type": "none", + "root": { + "size": "1GiB", + "filesystem": "ext4" + } + } + }, + "plugins": { + "cloud_init": { + "username": "admin", + "disable_modules": [ "landscape", "byobu", "ssh-import-id" ] + } + } +} diff --git a/providers/ec2/tasks/ami.py b/providers/ec2/tasks/ami.py index 000c0db..9e0ff0b 100644 --- a/providers/ec2/tasks/ami.py +++ b/providers/ec2/tasks/ami.py @@ -58,8 +58,11 @@ class UploadImage(Task): manifest_file = os.path.join(info.bundle_path, info.ami_name + '.manifest.xml') if info.host['region'] == 'us-east-1': s3_url = 'https://s3.amazonaws.com/' + elif info.host['region'] == 'cn-north-1': + s3_url = 'https://s3.cn-north-1.amazonaws.com.cn' else: s3_url = 'https://s3-{region}.amazonaws.com/'.format(region=info.host['region']) + info.manifest.manifest_location = info.manifest.image['bucket'] + '/' + info.ami_name + '.manifest.xml' log_check_call(['/usr/bin/euca-upload-bundle', '--bucket', info.manifest.image['bucket'], '--manifest', manifest_file, @@ -89,61 +92,46 @@ class RegisterAMI(Task): # Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UserProvidedKernels.html#AmazonKernelImageIDs kernel_mapping = {'ap-northeast-1': # Asia Pacific (Tokyo) Region - {'hd0': {'i386': 'aki-136bf512', # pv-grub-hd0_1.04-i386.gz - 'amd64': 'aki-176bf516'}, # pv-grub-hd0_1.04-x86_64.gz - 'hd00': {'i386': 'aki-196bf518', # pv-grub-hd00_1.04-i386.gz - 'amd64': 'aki-1f6bf51e'} # pv-grub-hd00_1.04-x86_64.gz - }, + {'i386': 'aki-136bf512', # pv-grub-hd0_1.04-i386.gz + 'amd64': 'aki-176bf516' # pv-grub-hd0_1.04-x86_64.gz + }, 'ap-southeast-1': # Asia Pacific (Singapore) Region - {'hd0': {'i386': 'aki-ae3973fc', # pv-grub-hd0_1.04-i386.gz - 'amd64': 'aki-503e7402'}, # pv-grub-hd0_1.04-x86_64.gz - 'hd00': {'i386': 'aki-563e7404', # pv-grub-hd00_1.04-i386.gz - 'amd64': 'aki-5e3e740c'} # pv-grub-hd00_1.04-x86_64.gz - }, + {'i386': 'aki-ae3973fc', # pv-grub-hd0_1.04-i386.gz + 'amd64': 'aki-503e7402' # pv-grub-hd0_1.04-x86_64.gz + }, 'ap-southeast-2': # Asia Pacific (Sydney) Region - {'hd0': {'i386': 'aki-cd62fff7', # pv-grub-hd0_1.04-i386.gz - 'amd64': 'aki-c362fff9'}, # pv-grub-hd0_1.04-x86_64.gz - 'hd00': {'i386': 'aki-c162fffb', # pv-grub-hd00_1.04-i386.gz - 'amd64': 'aki-3b1d8001'} # pv-grub-hd00_1.04-x86_64.gz + {'i386': 'aki-cd62fff7', # pv-grub-hd0_1.04-i386.gz + 'amd64': 'aki-c362fff9' # pv-grub-hd0_1.04-x86_64.gz }, 'eu-west-1': # EU (Ireland) Region - {'hd0': {'i386': 'aki-68a3451f', # pv-grub-hd0_1.04-i386.gz - 'amd64': 'aki-52a34525'}, # pv-grub-hd0_1.04-x86_64.gz - 'hd00': {'i386': 'aki-5ea34529', # pv-grub-hd00_1.04-i386.gz - 'amd64': 'aki-58a3452f'} # pv-grub-hd00_1.04-x86_64.gz + {'i386': 'aki-68a3451f', # pv-grub-hd0_1.04-i386.gz + 'amd64': 'aki-52a34525' # pv-grub-hd0_1.04-x86_64.gz }, 'sa-east-1': # South America (Sao Paulo) Region - {'hd0': {'i386': 'aki-5b53f446', # pv-grub-hd0_1.04-i386.gz - 'amd64': 'aki-5553f448'}, # pv-grub-hd0_1.04-x86_64.gz - 'hd00': {'i386': 'aki-5753f44a', # pv-grub-hd00_1.04-i386.gz - 'amd64': 'aki-5153f44c'} # pv-grub-hd00_1.04-x86_64.gz + {'i386': 'aki-5b53f446', # pv-grub-hd0_1.04-i386.gz + 'amd64': 'aki-5553f448' # pv-grub-hd0_1.04-x86_64.gz }, 'us-east-1': # US East (Northern Virginia) Region - {'hd0': {'i386': 'aki-8f9dcae6', # pv-grub-hd0_1.04-i386.gz - 'amd64': 'aki-919dcaf8'}, # pv-grub-hd0_1.04-x86_64.gz - 'hd00': {'i386': 'aki-659ccb0c', # pv-grub-hd00_1.04-i386.gz - 'amd64': 'aki-499ccb20'} # pv-grub-hd00_1.04-x86_64.gz + {'i386': 'aki-8f9dcae6', # pv-grub-hd0_1.04-i386.gz + 'amd64': 'aki-919dcaf8' # pv-grub-hd0_1.04-x86_64.gz }, 'us-gov-west-1': # AWS GovCloud (US) - {'hd0': {'i386': 'aki-1fe98d3c', # pv-grub-hd0_1.04-i386.gz - 'amd64': 'aki-1de98d3e'}, # pv-grub-hd0_1.04-x86_64.gz - 'hd00': {'i386': 'aki-63e98d40', # pv-grub-hd00_1.04-i386.gz - 'amd64': 'aki-61e98d42'} # pv-grub-hd00_1.04-x86_64.gz + {'i386': 'aki-1fe98d3c', # pv-grub-hd0_1.04-i386.gz + 'amd64': 'aki-1de98d3e' # pv-grub-hd0_1.04-x86_64.gz }, 'us-west-1': # US West (Northern California) Region - {'hd0': {'i386': 'aki-8e0531cb', # pv-grub-hd0_1.04-i386.gz - 'amd64': 'aki-880531cd'}, # pv-grub-hd0_1.04-x86_64.gz - 'hd00': {'i386': 'aki-960531d3', # pv-grub-hd00_1.04-i386.gz - 'amd64': 'aki-920531d7'} # pv-grub-hd00_1.04-x86_64.gz + {'i386': 'aki-8e0531cb', # pv-grub-hd0_1.04-i386.gz + 'amd64': 'aki-880531cd' # pv-grub-hd0_1.04-x86_64.gz }, 'us-west-2': # US West (Oregon) Region - {'hd0': {'i386': 'aki-f08f11c0', # pv-grub-hd0_1.04-i386.gz - 'amd64': 'aki-fc8f11cc'}, # pv-grub-hd0_1.04-x86_64.gz - 'hd00': {'i386': 'aki-e28f11d2', # pv-grub-hd00_1.04-i386.gz - 'amd64': 'aki-e68f11d6'} # pv-grub-hd00_1.04-x86_64.gz - } + {'i386': 'aki-f08f11c0', # pv-grub-hd0_1.04-i386.gz + 'amd64': 'aki-fc8f11cc' # pv-grub-hd0_1.04-x86_64.gz + }, + 'cn-north-1': # China North (Beijing) Region + {'i386': 'aki-908f1da9', # pv-grub-hd0_1.04-i386.gz + 'amd64': 'aki-9e8f1da7' # pv-grub-hd0_1.04-x86_64.gz } - + } @classmethod def run(cls, info): registration_params = {'name': info.ami_name, @@ -153,6 +141,7 @@ class RegisterAMI(Task): if info.manifest.volume['backing'] == 's3': grub_boot_device = 'hd0' + registration_params['image_location'] = info.manifest.manifest_location else: root_dev_name = {'pvm': '/dev/sda', 'hvm': '/dev/xvda'}.get(info.manifest.data['virtualization']) @@ -176,7 +165,6 @@ class RegisterAMI(Task): registration_params['virtualization_type'] = 'paravirtual' registration_params['kernel_id'] = (cls.kernel_mapping .get(info.host['region']) - .get(grub_boot_device) .get(info.manifest.system['architecture'])) info.image = info.connection.register_image(**registration_params) diff --git a/providers/ec2/tasks/packages-kernels.json b/providers/ec2/tasks/packages-kernels.json index 74a3df7..3c9e39f 100644 --- a/providers/ec2/tasks/packages-kernels.json +++ b/providers/ec2/tasks/packages-kernels.json @@ -5,6 +5,9 @@ "wheezy": { "amd64": "linux-image-amd64", "i386" : "linux-image-686" }, + "jessie": { + "amd64": "linux-image-amd64", + "i386" : "linux-image-686" }, "testing": { "amd64": "linux-image-amd64", "i386" : "linux-image-686" },