From 61d4353bc7ef62a39440ad50eca08dd808df315e Mon Sep 17 00:00:00 2001 From: David Shea Date: Fri, 28 Sep 2018 14:54:51 -0400 Subject: [PATCH] Add an ami compose type for AWS images This differs from lmc's --make-ami in that creates a full disk image instead of an fsimage. Create a raw disk image with a / and /boot partitions, and enable sshd, chronyd, and cockpit by default. (cherry picked from commit 18188bf6cf6b8ca1e5778d90577b793344b21405) (cherry picked from commit 81d38b64450837c71eaf16b7108e6e8dde56af88) Resolves: rhbz#1656105 --- docs/composer-cli.rst | 4 +-- share/composer/ami.ks | 50 ++++++++++++++++++++++++++++++++++++ src/pylorax/api/compose.py | 22 ++++++++++++++++ tests/pylorax/test_server.py | 2 +- 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 share/composer/ami.ks diff --git a/docs/composer-cli.rst b/docs/composer-cli.rst index 366e01ad..7e32ca60 100644 --- a/docs/composer-cli.rst +++ b/docs/composer-cli.rst @@ -40,8 +40,8 @@ compose start http-server qcow2``. It will print a UUID that you can use to keep track of the build. You can also cancel the build if needed. The available types of images is displayed by ``composer-cli compose types``. -Currently this consists of: ext4-filesystem, live-iso, partitioned-disk, qcow2, -tar +Currently this consists of: ami, ext4-filesystem, live-iso, partitioned-disk, +qcow2, tar Monitor the build status ------------------------ diff --git a/share/composer/ami.ks b/share/composer/ami.ks new file mode 100644 index 00000000..e8e216e8 --- /dev/null +++ b/share/composer/ami.ks @@ -0,0 +1,50 @@ +# Lorax Composer AMI output kickstart template + +# Add a separate /boot partition +part /boot --size=1024 + +# Firewall configuration +firewall --enabled + +# NOTE: The root account is locked by default +# Network information +network --bootproto=dhcp --onboot=on --activate +# System authorization information +auth --useshadow --enablemd5 +# System keyboard +keyboard --xlayouts=us --vckeymap=us +# System language +lang en_US.UTF-8 +# SELinux configuration +selinux --enforcing +# Installation logging level +logging --level=info +# Shutdown after installation +shutdown +# System timezone +timezone US/Eastern +# System bootloader configuration +bootloader --location=mbr --append="no_timer_check console=ttyS0,115200n8 console=tty1 net.ifnames=0" + +# Basic services +services --enabled=sshd,chronyd,cloud-init + +%post +# Remove random-seed +rm /var/lib/systemd/random-seed + +# tell cloud-init to create the ec2-user account +sed -i 's/cloud-user/ec2-user/' /etc/cloud/cloud.cfg +%end + +%packages +kernel +-dracut-config-rescue + +grub2 + +chrony + +cloud-init + +# NOTE lorax-composer will add the recipe packages below here, including the final %end diff --git a/src/pylorax/api/compose.py b/src/pylorax/api/compose.py index b59642c2..6e9e88fd 100644 --- a/src/pylorax/api/compose.py +++ b/src/pylorax/api/compose.py @@ -544,6 +544,28 @@ def compose_args(compose_type): "app_template": None, "app_file": None }, + "ami": {"make_iso": False, + "make_disk": True, + "make_fsimage": False, + "make_appliance": False, + "make_ami": False, + "make_tar": False, + "make_pxe_live": False, + "make_ostree_live": False, + "make_oci": False, + "make_vagrant": False, + "ostree": False, + "live_rootfs_keep_size": False, + "live_rootfs_size": 0, + "image_type": False, + "qemu_args": [], + "image_name": "disk.ami", + "fs_label": "", + "image_only": True, + "app_name": None, + "app_template": None, + "app_file": None, + }, } return _MAP[compose_type] diff --git a/tests/pylorax/test_server.py b/tests/pylorax/test_server.py index ae2ca167..8133f9ec 100644 --- a/tests/pylorax/test_server.py +++ b/tests/pylorax/test_server.py @@ -800,7 +800,7 @@ class ServerTestCase(unittest.TestCase): data = json.loads(resp.data) self.assertNotEqual(data, None) self.assertEqual(data["status"], False, "Failed to fail to start test compose: %s" % data) - self.assertEqual(data["errors"], [{"id": BAD_COMPOSE_TYPE, "msg": "Invalid compose type (snakes), must be one of ['ext4-filesystem', 'live-iso', 'partitioned-disk', 'qcow2', 'tar']"}], + self.assertEqual(data["errors"], [{"id": BAD_COMPOSE_TYPE, "msg": "Invalid compose type (snakes), must be one of ['ami', 'ext4-filesystem', 'live-iso', 'partitioned-disk', 'qcow2', 'tar']"}], "Failed to get errors: %s" % data) def test_compose_03_status_fail(self):