From 49810847c4d8428e6b3351e2abf5f5aea260fd74 Mon Sep 17 00:00:00 2001 From: David Shea Date: Fri, 29 Mar 2019 11:09:50 -0400 Subject: [PATCH] Add a compose type for Google Compute Engine (cherry picked from commit bd804c271b15af36d608711af5029d8438393635) Resolved: rhbz#1689140 --- docs/composer-cli.rst | 2 +- share/composer/google.ks | 77 ++++++++++++++++++++++++++++++++ tests/cli/test_compose_sanity.sh | 2 +- tests/pylorax/test_server.py | 2 +- 4 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 share/composer/google.ks diff --git a/docs/composer-cli.rst b/docs/composer-cli.rst index 6c1116fb..5e8b115e 100644 --- a/docs/composer-cli.rst +++ b/docs/composer-cli.rst @@ -40,7 +40,7 @@ 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: ami, ext4-filesystem, live-iso, openstack, +Currently this consists of: ami, ext4-filesystem, google, live-iso, openstack, partitioned-disk, qcow2, tar, vhd, vmdk Monitor the build status diff --git a/share/composer/google.ks b/share/composer/google.ks new file mode 100644 index 00000000..d9390ab1 --- /dev/null +++ b/share/composer/google.ks @@ -0,0 +1,77 @@ +# Lorax Composer partitioned disk output kickstart template + +# Firewall configuration +firewall --disabled + +# NOTE: The root account is locked by default +# Network information +network --bootproto=dhcp --onboot=on --mtu=1460 --noipv6 --activate +# 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 --ntpservers metadata.google.internal UTC +# System bootloader configuration +bootloader --location=mbr --append="ttyS0,38400n8d" +# Add platform specific partitions +reqpart --add-boot + +services --disabled=irqbalance + +%post +# Remove random-seed +rm /var/lib/systemd/random-seed + +# Clear /etc/machine-id +rm /etc/machine-id +touch /etc/machine-id + +# Remove the rescue kernel and image to save space +rm -f /boot/*-rescue* + +# Replace the ssh configuration +cat > /etc/ssh/sshd_config << EOF +# Disable PasswordAuthentication as ssh keys are more secure. +PasswordAuthentication no + +# Disable root login, using sudo provides better auditing. +PermitRootLogin no + +PermitTunnel no +AllowTcpForwarding yes +X11Forwarding no + +# Compute times out connections after 10 minutes of inactivity. Keep alive +# ssh connections by sending a packet every 7 minutes. +ClientAliveInterval 420 +EOF + +cat > /etc/ssh/ssh_config << EOF +Host * +Protocol 2 +ForwardAgent no +ForwardX11 no +HostbasedAuthentication no +StrictHostKeyChecking no +Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc +Tunnel no + +# Google Compute Engine times out connections after 10 minutes of inactivity. +# Keep alive ssh connections by sending a packet every 7 minutes. +ServerAliveInterval 420 +EOF + +%end + +%packages +kernel +selinux-policy-targeted + +# NOTE lorax-composer will add the blueprint packages below here, including the final %end diff --git a/tests/cli/test_compose_sanity.sh b/tests/cli/test_compose_sanity.sh index 7e63a781..1386b603 100755 --- a/tests/cli/test_compose_sanity.sh +++ b/tests/cli/test_compose_sanity.sh @@ -9,7 +9,7 @@ CLI="${CLI:-./src/bin/composer-cli}" rlJournalStart rlPhaseStartTest "compose types" rlAssertEquals "lists all supported types" \ - "`$CLI compose types | sort | xargs`" "ami ext4-filesystem live-iso openstack partitioned-disk qcow2 tar vhd vmdk" + "`$CLI compose types | sort | xargs`" "ami ext4-filesystem google live-iso openstack partitioned-disk qcow2 tar vhd vmdk" rlPhaseEnd rlPhaseStartTest "compose start" diff --git a/tests/pylorax/test_server.py b/tests/pylorax/test_server.py index 3aaf0fc6..15f460b7 100644 --- a/tests/pylorax/test_server.py +++ b/tests/pylorax/test_server.py @@ -843,7 +843,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 ['ami', 'ext4-filesystem', 'live-iso', 'openstack', 'partitioned-disk', 'qcow2', 'tar', 'vhd', 'vmdk']"}], + self.assertEqual(data["errors"], [{"id": BAD_COMPOSE_TYPE, "msg": "Invalid compose type (snakes), must be one of ['ami', 'ext4-filesystem', 'google', 'live-iso', 'openstack', 'partitioned-disk', 'qcow2', 'tar', 'vhd', 'vmdk']"}], "Failed to get errors: %s" % data) def test_compose_03_status_fail(self):