Skip to content

Add systemd units and a basic Makefile to install - #90

Merged
sdemos merged 1 commit into
coreos:masterfrom
cgwalters:upstream-units
Jul 30, 2018
Merged

sdemos merged 1 commit into
coreos:masterfrom
cgwalters:upstream-units

Conversation

@cgwalters

Copy link
Copy Markdown
Member

We're looking at adapting coreos-metdata for FCOS.
We'll need to package it again as an RPM (probably).

Regardless, I think it's best to have systemd unit files upstream.
Taken from:
https://github.com/coreos/coreos-overlay/tree/master/coreos-base/coreos-metadata/files

@bgilbert bgilbert left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Moving the units upstream is probably okay, except for the assumption about the core user.

Please make sure the commit message includes the commit hash from which the unit files were taken.

Comment thread Makefile Outdated
@@ -0,0 +1,10 @@
DESTDIR ?=
PREFIX ?= $(DESTDIR)/usr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overriding both DESTDIR and PREFIX will produce a surprising result.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed, thanks.

Comment thread systemd/[email protected] Outdated
ExecStart=/usr/bin/coreos-metadata ${COREOS_METADATA_OPT_PROVIDER} --ssh-keys=%i

[Install]
DefaultInstance=core

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This embeds the assumption that there is a core user. Perhaps we don't want to do that upstream?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point. Hmm, that definitely makes things harder. We could add make install-units USERNAME=core or so?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think my vote for now is to move forward with the assumption FCOS-derived systems will also have a core user by default.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FCOS-derived systems will have a core user, but this is going into the upstream package. Maybe default the Makefile to core, with an override?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I just checked, and DefaultInstance= can be overridden via a drop-in (which is properly honored at enable time). I'm not much of a fan of templating this here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@cgwalters @bgilbert @csssuf @lucab I think that given the constraints of the problem, templating is the best solution we have. Unless anyone is strongly opposed to it, I think @cgwalters should just implement it for this pr. If we come up with a better solution later, we can revisit this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

AFAIK the cloud image of pretty much every distro has a default user, whether it's ec2-user, ubuntu, root, etc.

Kind of...one really important detail wrt cloud-init is that that default user is only created if you don't specify another user. Concretely for Fedora Atomic (and Fedora Cloud) if you boot a cloud-init config that looks like this (a reduced version of my default one):

users:
  - name: walters
    gecos: Colin Walters
    sudo: ALL=(ALL) NOPASSWD:ALL
    ssh-authorized-keys:
      - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQkQHeKan3X+g1jILw4a3KtcfEIED0kByKGWookU7ev [email protected]

You don't get a fedora user. Or to say it conversely, the user is only created dynamically on boot - and this is different from CL today where the core user exists by default.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So any distribution that wants to use coreos-metadata would have to choose to either do what CL does and precreate that user, or alternatively have coreos-metadata do some sort of search dynamically for the "first" human user created by Ignition (possibly one that's in the wheel/sudo group?)

The thing that makes me uncomfortable about pre-creating e.g. a core user is - what if you join the node to LDAP/ActiveDirectory or whatever and there's already a "core" user? You wouldn't want coreos-metadata granting ssh keys to that user...

In the end of course, an admin could delete the core user of course, but it does seem nicer to me to have the cloud-init semantics where it's a default user, but if you specify another one it doesn't exist.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's not a good way to express the "conditional default user" thing in Ignition right now; that'd be a good issue for coreos/ignition.

Note that we're talking about [email protected], not the entirety of coreos-metadata. Distros which conditionally create the default user can't unconditionally enable that unit anyway, since they don't know what account to associate it with. In that case, I think it makes sense for the distro to either

  1. ignore the DefaultInstance and always specify the desired instance, or
  2. set the DefaultInstance to the conditional default user, and only enable [email protected] when the default user is actually created.

Either way, setting DefaultInstance is either useful or harmless.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Split that to coreos/ignition#600

@cgwalters
cgwalters force-pushed the upstream-units branch 2 times, most recently from a8ff849 to e118ea8 Compare June 21, 2018 17:57
@arithx

arithx commented Jun 21, 2018

Copy link
Copy Markdown
Contributor

tailor disable commit description

sdemos
sdemos previously approved these changes Jun 21, 2018

@sdemos sdemos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this all seems reasonable to me.

@sdemos

sdemos commented Jun 22, 2018

Copy link
Copy Markdown
Contributor

Also this needs a rebase on master. Shouldn't be any conflicts though.

@cgwalters

Copy link
Copy Markdown
Member Author

🏄‍♂️ Rebased

@bgilbert
bgilbert dismissed sdemos’s stale review June 26, 2018 00:44

Ensuring user templating discussion doesn't get overlooked

@cgwalters

Copy link
Copy Markdown
Member Author

I don't think the templating was overlooked, it seemed like there was more disagreement about whether it was necessary among the repo owners here?

If no one objects to doing it though I don't mind updating this PR to do that.

@cgwalters

Copy link
Copy Markdown
Member Author

Rebased 🏄 and updated to template per discussion.

Comment thread systemd/.gitignore Outdated
@@ -0,0 +1 @@
[email protected] No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing trailing newline.

Comment thread systemd/[email protected] Outdated
@@ -0,0 +1,11 @@
[Unit]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

File should be dropped.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oops, thanks! Sorry about being slow here, I saw this comment go by and thought somehow you meant that section in the .in file should be dropped, and I started questioning whether there was some fundamental misunderstanding, then took a context switch. Anyways updated ⬇️

We're looking at adapting coreos-metdata for FCOS:
<https://coreos.fedoraproject.org/>
We'll need to package it again as an RPM (probably).

Regardless, I think it's best to have systemd unit files upstream.
Taken from: https://github.com/coreos/coreos-overlay/tree/25296501691067d3f490d62547b5de047ca28250/coreos-base/coreos-metadata/files

This introduces a default template for the unit; you can change it via
`make install-units DEFAULT_INSTANCE=ubuntu` or whatever.

@sdemos sdemos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, as long as @bgilbert doesn't have any more comments.

@sdemos

sdemos commented Jul 25, 2018

Copy link
Copy Markdown
Contributor

@cgwalters sorry, github is complaining, can you rebase this one more time?

@sdemos

sdemos commented Jul 30, 2018

Copy link
Copy Markdown
Contributor

ehh it'll probably merge cleanly

@sdemos
sdemos merged commit 90b3e9c into coreos:master Jul 30, 2018
cgwalters added a commit to cgwalters/coreos-assembler that referenced this pull request Sep 18, 2018
This way we are truly starting from a clean slate.  It means
we know we won't have a `random-seed` for example.  OSTree is
designed to support this but unless we use it *by default*
we aren't really testing it.

This actually now breaks things since currently the creation of
the `core` user is in `image.ks`, which we need to fix:
coreos/afterburn#90 (comment)
cgwalters added a commit to cgwalters/coreos-assembler that referenced this pull request Sep 18, 2018
This way we are truly starting from a clean slate.  It means
we know we won't have a `random-seed` for example.  OSTree is
designed to support this but unless we use it *by default*
we aren't really testing it.

This actually now breaks things since currently the creation of
the `core` user is in `image.ks`, which we need to fix:
coreos/afterburn#90 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants