| 1 |
.. _setup_for_ec2: |
| 2 |
|
| 3 |
Image Description for Amazon EC2 |
| 4 |
================================ |
| 5 |
|
| 6 |
.. sidebar:: Abstract |
| 7 |
|
| 8 |
This page provides further information for handling |
| 9 |
Amazon EC2 images built with {kiwi} and references the following |
| 10 |
articles: |
| 11 |
|
| 12 |
* :ref:`simple_disk` |
| 13 |
|
| 14 |
A virtual disk image that is able to boot in the Amazon EC2 |
| 15 |
cloud framework has to comply with the following constraints: |
| 16 |
|
| 17 |
* Xen tools and libraries must be installed. |
| 18 |
* The cloud-init package must be installed. |
| 19 |
* A cloud-init configuration for Amazon must be provided. |
| 20 |
* Grub bootloader modules for Xen must be installed. |
| 21 |
* AWS tools must be installed. |
| 22 |
* The disk size must be set to 10G. |
| 23 |
* Kernel parameters must allow for a Xen console. |
| 24 |
|
| 25 |
To meet these requirements, add or update the {kiwi} image |
| 26 |
description as follows: |
| 27 |
|
| 28 |
1. Software packages |
| 29 |
|
| 30 |
Make sure to add the following packages to the package list: |
| 31 |
|
| 32 |
.. note:: |
| 33 |
|
| 34 |
Package names used in the following list match the |
| 35 |
package names of the SUSE distribution and might be different |
| 36 |
on other distributions. |
| 37 |
|
| 38 |
.. code:: xml |
| 39 |
|
| 40 |
<package name="aws-cli"/> |
| 41 |
<package name="grub2-x86_64-xen"/> |
| 42 |
<package name="xen-libs"/> |
| 43 |
<package name="xen-tools-domU"/> |
| 44 |
<package name="cloud-init"/> |
| 45 |
|
| 46 |
2. Image Type definition |
| 47 |
|
| 48 |
Update the oem image type setup as follows: |
| 49 |
|
| 50 |
.. code:: xml |
| 51 |
|
| 52 |
<type image="oem" |
| 53 |
filesystem="ext4" |
| 54 |
kernelcmdline="console=xvc0 multipath=off net.ifnames=0" |
| 55 |
devicepersistency="by-label" |
| 56 |
firmware="ec2"> |
| 57 |
<bootloader name="grub2" timeout="1"/> |
| 58 |
<size unit="M">10240</size> |
| 59 |
<machine xen_loader="hvmloader"/> |
| 60 |
<oemconfig> |
| 61 |
<oem-resize>false</oem-resize> |
| 62 |
</oemconfig> |
| 63 |
</type> |
| 64 |
|
| 65 |
3. Cloud-Init setup |
| 66 |
|
| 67 |
Cloud-init is a service that runs at boot time and allows |
| 68 |
you to customize the system by activating one or more cloud-init |
| 69 |
modules. For Amazon EC2, the following configuration file, |
| 70 |
:file:`/etc/cloud/cloud.cfg`, needs to be provided as part of the |
| 71 |
overlay files in your {kiwi} image description: |
| 72 |
|
| 73 |
.. code:: yaml |
| 74 |
|
| 75 |
users: |
| 76 |
- default |
| 77 |
|
| 78 |
disable_root: true |
| 79 |
preserve_hostname: false |
| 80 |
syslog_fix_perms: root:root |
| 81 |
|
| 82 |
datasource_list: [ NoCloud, Ec2, None ] |
| 83 |
|
| 84 |
cloud_init_modules: |
| 85 |
- migrator |
| 86 |
- bootcmd |
| 87 |
- write-files |
| 88 |
- growpart |
| 89 |
- resizefs |
| 90 |
- set_hostname |
| 91 |
- update_hostname |
| 92 |
- update_etc_hosts |
| 93 |
- ca-certs |
| 94 |
- rsyslog |
| 95 |
- users-groups |
| 96 |
- ssh |
| 97 |
|
| 98 |
cloud_config_modules: |
| 99 |
- mounts |
| 100 |
- ssh-import-id |
| 101 |
- locale |
| 102 |
- set-passwords |
| 103 |
- package-update-upgrade-install |
| 104 |
- timezone |
| 105 |
|
| 106 |
cloud_final_modules: |
| 107 |
- scripts-per-once |
| 108 |
- scripts-per-boot |
| 109 |
- scripts-per-instance |
| 110 |
- scripts-user |
| 111 |
- ssh-authkey-fingerprints |
| 112 |
- keys-to-console |
| 113 |
- phone-home |
| 114 |
- final-message |
| 115 |
- power-state-change |
| 116 |
|
| 117 |
system_info: |
| 118 |
default_user: |
| 119 |
name: ec2-user |
| 120 |
gecos: "cloud-init created default user" |
| 121 |
lock_passwd: True |
| 122 |
sudo: ["ALL=(ALL) NOPASSWD:ALL"] |
| 123 |
shell: /bin/bash |
| 124 |
paths: |
| 125 |
cloud_dir: /var/lib/cloud/ |
| 126 |
templates_dir: /etc/cloud/templates/ |
| 127 |
ssh_svcname: sshd |
| 128 |
|
| 129 |
An image built with the above setup can be uploaded into the |
| 130 |
Amazon EC2 cloud and registered as an image. For further information |
| 131 |
on how to upload to EC2, see: `ec2uploadimg <https://github.com/SUSE-Enceladus/ec2imgutils>`_. |