Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

coreos-base/oem-ec2-compat: pull ssh keys from metadata server #2246

Merged
merged 2 commits into from
Oct 21, 2022

Conversation

tormath1
Copy link
Contributor

@tormath1 tormath1 commented Oct 20, 2022

In this PR, we're enabling the coreos-metadata-sshkeys@.service for the OpenStack image in order to pull SSH keys from the OpenStack metadata server if no user configuration is provided.

How to use

Boot an instance on OpenStack without Ignition provided SSH keys.

Testing done

Manually tested with flatcar/mantle#388


Should fix: flatcar/Flatcar#817

@tormath1 tormath1 self-assigned this Oct 20, 2022
@tormath1 tormath1 marked this pull request as ready for review October 20, 2022 07:14
@tormath1 tormath1 requested a review from a team October 20, 2022 07:14
@tormath1 tormath1 added the main label Oct 20, 2022
@@ -63,4 +63,6 @@ src_install() {
if use ec2 ; then
newins "${FILESDIR}/base/base-ec2.ign" base.ign
fi

use openstack && newins "${FILESDIR}/base/openstack.ign" base.ign
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the return code of src_install matter or can it be non-0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newins calls die if there is an error during the installation of the file: this operation should succeed or die.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the question is whether the return value of src_install has any meaning. This function's return value will the return value of use openstack && newins "…", which will be 1 for non-openstack images (because use openstack will return 1).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd recommend rewriting this as if use openstack; then newins "…"; fi for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I tend to follow this documentation: https://devmanual.gentoo.org/ebuild-writing/use-conditional-code/index.html

For single-statement conditions, the use foo && blah (or use foo || blah for negatives) form is often more readable.

But yes, in this case it's wrong to return use openstack && newins "…" as it will be 1 for non-openstack image (AWS). Thanks!

Without this Ignition configuration, the SSH keys are
not installed from the Openstack metadata server.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
@tormath1
Copy link
Contributor Author

cherry-picked to:

  • flatcar-3227
  • flatcar-3346
  • flatcar-3374

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot SSH into Flatcar 3227.2.0 instance created in OpenStack
3 participants