From 477afcd01d3d015dbd00555364c53536351ca2d6 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Tue, 1 Jul 2014 11:44:42 -0700 Subject: [PATCH] Revert "oem-ec2-compat: Check for metadata service and config drive" The functionality for this in cloudinit 0.8.x is broken. This reverts commit 91cc8446212c6b35c80cbdbbc204a9fe3cd1f756. --- .../oem-ec2-compat/files/cloud-config.yml | 19 ++++++++---- .../files/coreos-setup-environment | 29 +++++++++++++++++++ .../oem-ec2-compat/files/ec2-ssh-key | 6 ++++ .../oem-ec2-compat-0.0.1-r14.ebuild | 1 + ...0.2.ebuild => oem-ec2-compat-0.0.1.ebuild} | 4 +++ 5 files changed, 53 insertions(+), 6 deletions(-) create mode 100755 sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/coreos-setup-environment create mode 100755 sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/ec2-ssh-key create mode 120000 sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1-r14.ebuild rename sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/{oem-ec2-compat-0.0.2.ebuild => oem-ec2-compat-0.0.1.ebuild} (90%) diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/cloud-config.yml b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/cloud-config.yml index f393475480..0551114a15 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/cloud-config.yml +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/cloud-config.yml @@ -2,11 +2,18 @@ coreos: units: - - name: user-configdrive.service - mask: yes - - name: user-configvirtfs.service - mask: yes - - name: oem-cloudinit.service + - name: ec2-ssh-key.service + command: restart + runtime: yes + content: | + [Unit] + Description=Sets SSH key from metadata + + [Service] + Type=oneshot + StandardOutput=journal+console + ExecStart=/usr/share/oem/bin/ec2-ssh-key + - name: ec2-cloudinit.service command: restart runtime: yes content: | @@ -18,7 +25,7 @@ coreos: [Service] Type=oneshot EnvironmentFile=/etc/environment - ExecStart=/usr/bin/coreos-cloudinit --from-configdrive=/media/configdrive --from-metadata-service + ExecStart=/usr/bin/coreos-cloudinit -ignore-failure=true -from-url=http://169.254.169.254/latest/user-data oem: id: @@OEM_ID@@ name: @@OEM_NAME@@ diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/coreos-setup-environment b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/coreos-setup-environment new file mode 100755 index 0000000000..4e3b0c4dee --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/coreos-setup-environment @@ -0,0 +1,29 @@ +#!/bin/bash + +ENV=$1 + +if [ -z "$ENV" ]; then + echo usage: $0 /etc/environment + exit 1 +fi +# test for rw +touch $ENV +if [ $? -ne 0 ]; then + echo exiting, unable to modify: $ENV + exit 1 +fi + +sed -i -e '/^COREOS_PUBLIC_IPV4=/d' \ + -e '/^COREOS_PRIVATE_IPV4=/d' \ + "${ENV}" + +/usr/bin/block-until-url http://169.254.169.254/latest/meta-data/public-ipv4 + +# get public ip from metadata +PUB_IP_URL=http://169.254.169.254/latest/meta-data/public-ipv4 +IP=$(/usr/bin/curl --fail -s "$PUB_IP_URL") +echo COREOS_PUBLIC_IPV4=${IP} >> $ENV + +PRIV_IP_URL=http://169.254.169.254/latest/meta-data/local-ipv4 +IP=$(/usr/bin/curl --fail -s "$PRIV_IP_URL") +echo COREOS_PRIVATE_IPV4=${IP} >> $ENV diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/ec2-ssh-key b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/ec2-ssh-key new file mode 100755 index 0000000000..65dfeaae55 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/ec2-ssh-key @@ -0,0 +1,6 @@ +#!/bin/sh -e + +KEY_URL="http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key" + +/usr/bin/block-until-url "$KEY_URL" +/usr/bin/curl --fail -s "$KEY_URL" | /usr/bin/update-ssh-keys -a ec2 diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1-r14.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1-r14.ebuild new file mode 120000 index 0000000000..653407e6ba --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1-r14.ebuild @@ -0,0 +1 @@ +oem-ec2-compat-0.0.1.ebuild \ No newline at end of file diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.2.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1.ebuild similarity index 90% rename from sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.2.ebuild rename to sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1.ebuild index a7042cfc5a..ba97b4ac5c 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.2.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1.ebuild @@ -40,6 +40,10 @@ src_prepare() { } src_install() { + into "/usr/share/oem" + dobin ${FILESDIR}/ec2-ssh-key + dobin ${FILESDIR}/coreos-setup-environment + insinto "/usr/share/oem" doins ${T}/cloud-config.yml }