Merge pull request #346 from vorlock/master

Added tagging for the created images +
This commit is contained in:
Anders Ingemann 2016-10-31 16:43:06 +01:00 committed by GitHub
commit d99f345fa9
7 changed files with 124 additions and 46 deletions

View file

@ -47,10 +47,10 @@ properties:
enum: [i386] enum: [i386]
bootloader: bootloader:
enum: enum:
- pvgrub - pvgrub
- grub - grub
- extlinux - extlinux
- none - none
charmap: {type: string} charmap: {type: string}
hostname: hostname:
type: string type: string
@ -59,12 +59,12 @@ properties:
release: {type: string} release: {type: string}
timezone: {type: string} timezone: {type: string}
required: required:
- release - release
- architecture - architecture
- bootloader - bootloader
- timezone - timezone
- locale - locale
- charmap - charmap
additionalProperties: false additionalProperties: false
packages: packages:
type: object type: object
@ -77,8 +77,8 @@ properties:
type: array type: array
items: items:
anyOf: anyOf:
- pattern: ^[^/]+(/[^/]+)?$ - pattern: ^[^/]+(/[^/]+)?$
- $ref: '#/definitions/absolute_path' - $ref: '#/definitions/absolute_path'
minItems: 1 minItems: 1
install_standard: {type: boolean} install_standard: {type: boolean}
mirror: mirror:
@ -137,8 +137,8 @@ properties:
partitions: partitions:
type: object type: object
oneOf: oneOf:
- $ref: '#/definitions/no_partitions' - $ref: '#/definitions/no_partitions'
- $ref: '#/definitions/partition_table' - $ref: '#/definitions/partition_table'
required: [partitions] required: [partitions]
additionalProperties: false additionalProperties: false
definitions: definitions:

View file

@ -110,7 +110,7 @@ class Manifest(object):
self.system = self.data['system'] self.system = self.data['system']
from bootstrapvz.common.releases import get_release from bootstrapvz.common.releases import get_release
self.release = get_release(self.system['release']) self.release = get_release(self.system['release'])
# The packages and plugins section is not required # The packages and plugins sections are not required
self.packages = self.data['packages'] if 'packages' in self.data else {} self.packages = self.data['packages'] if 'packages' in self.data else {}
self.plugins = self.data['plugins'] if 'plugins' in self.data else {} self.plugins = self.data['plugins'] if 'plugins' in self.data else {}

View file

@ -49,6 +49,9 @@ def validate_manifest(data, validator, error):
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
"""
Function setting up tasks to run for this provider
"""
from bootstrapvz.common.releases import wheezy, jessie, stable from bootstrapvz.common.releases import wheezy, jessie, stable
taskset.update(task_groups.get_standard_groups(manifest)) taskset.update(task_groups.get_standard_groups(manifest))

View file

@ -3,6 +3,9 @@ $schema: http://json-schema.org/draft-04/schema#
title: EC2 manifest title: EC2 manifest
type: object type: object
properties: properties:
tags:
type: object
minProperties: 1
provider: provider:
type: object type: object
properties: properties:
@ -14,12 +17,12 @@ properties:
secret-key: {type: string} secret-key: {type: string}
virtualization: virtualization:
enum: enum:
- pvm - pvm
- hvm - hvm
enhanced_networking: enhanced_networking:
enum: enum:
- none - none
- simple - simple
required: [description, virtualization] required: [description, virtualization]
system: system:
type: object type: object
@ -27,22 +30,22 @@ properties:
bootloader: bootloader:
type: string type: string
enum: enum:
- pvgrub - pvgrub
- grub - grub
- extlinux - extlinux
volume: volume:
type: object type: object
properties: properties:
backing: backing:
enum: enum:
- ebs - ebs
- s3 - s3
partitions: partitions:
type: object type: object
properties: properties:
type: type:
enum: enum:
- none - none
- msdos - msdos
- gpt - gpt
required: [backing] required: [backing]

View file

@ -125,3 +125,9 @@ class RegisterAMI(Task):
registration_params['sriov_net_support'] = 'simple' registration_params['sriov_net_support'] = 'simple'
info._ec2['image'] = info._ec2['connection'].register_image(**registration_params) info._ec2['image'] = info._ec2['connection'].register_image(**registration_params)
# Setting up tags on the AMI
if 'tags' in info.manifest.data:
raw_tags = info.manifest.data['tags']
tags = {k: v.format(**info.manifest_vars) for k, v in raw_tags.items()}
info._ec2['connection'].create_tags(info._ec2['image'], tags)

View file

@ -27,31 +27,31 @@ volume:
packages: packages:
mirror: http://cloudfront.debian.net/debian mirror: http://cloudfront.debian.net/debian
components: components:
- main - main
- contrib - contrib
- non-free - non-free
preferences: preferences:
backport-cloud-init-cloud-utils: backport-cloud-init-cloud-utils:
- package: cloud-init cloud-utils - package: cloud-init cloud-utils
pin: release n=jessie-backports pin: release n=jessie-backports
pin-priority: 500 pin-priority: 500
install: install:
- awscli - awscli
- python-boto - python-boto
- python3-boto - python3-boto
- apt-transport-https - apt-transport-https
- lvm2 - lvm2
- ncurses-term - ncurses-term
- parted - parted
- cloud-init - cloud-init
- cloud-utils - cloud-utils
- gdisk - gdisk
- systemd - systemd
- systemd-sysv - systemd-sysv
plugins: plugins:
cloud_init: cloud_init:
metadata_sources: Ec2 metadata_sources: Ec2
username: admin username: admin
enable_modules: enable_modules:
cloud_init_modules: cloud_init_modules:
- { module: growpart, position: 4} - {module: growpart, position: 4}

View file

@ -0,0 +1,66 @@
---
name: debian-{system.release}-{system.architecture}-{provider.virtualization}-{%Y}-{%m}-{%d}-{%H}{%M}-ebs
tags:
Name: "Stretch 9.0 alpha"
Debian: "9.0~{%Y}{%m}{%d}"
provider:
name: ec2
virtualization: hvm
enhanced_networking: simple
# credentials:
# access-key: AFAKEACCESSKEYFORAWS
# secret-key: thes3cr3tkeyf0ryourawsaccount/FS4d8Qdva
description: Debian {system.release} {system.architecture}
bootstrapper:
workspace: /target
system:
release: stretch
architecture: amd64
bootloader: grub
charmap: UTF-8
locale: en_US
timezone: UTC
volume:
backing: ebs
partitions:
type: gpt
root:
filesystem: ext4
size: 8GiB
packages:
mirror: http://cloudfront.debian.net/debian
components:
- main
- contrib
- non-free
install:
- awscli
- python-boto
- python3-boto
- apt-transport-https
- lvm2
- ncurses-term
- parted
- cloud-init
- cloud-utils
- gdisk
- systemd
- systemd-sysv
plugins:
cloud_init:
metadata_sources: Ec2
username: admin
enable_modules:
cloud_init_modules:
- {module: growpart, position: 4}
# ec2_launch:
# security_group_ids:
# # this have to be a NONE VPC SG
# - sg-398a704f
# instance_type: m3.medium
# ssh_key: my_ssh_key
# print_public_ip: "/tmp/stretch-ami-test-ip"
# tags:
# Name: "testing-ami-{system.release}"
# Debian: "9.0~{%Y}{%m}{%d}{%H}{%M}"
# deregister_ami: false