Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

userless conf fails assign user[0] as the default user #2286

Closed
ubuntu-server-builder opened this issue May 9, 2023 · 4 comments
Closed
Labels
launchpad Migrated from Launchpad priority Fix soon

Comments

@ubuntu-server-builder
Copy link
Collaborator

This bug was originally filed in Launchpad as LP: #1041384

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = 2012-09-19T21:08:58.585528+00:00
date_created = 2012-08-24T21:43:13.622929+00:00
date_fix_committed = 2012-09-19T21:08:58.585528+00:00
date_fix_released = 2012-09-19T21:08:58.585528+00:00
id = 1041384
importance = high
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1041384
milestone = None
owner = darkmuggle-deactivatedaccount
owner_name = Ben Howard
private = False
status = fix_released
submitter = darkmuggle-deactivatedaccount
submitter_name = Ben Howard
tags = []
duplicates = []

Launchpad user Ben Howard(darkmuggle-deactivatedaccount) wrote on 2012-08-24T21:43:13.622929+00:00

The userles merge fails to properly assign user[0] as the default user due to default configuration and the way that cloud-init merges the ondisk configuration with the cloud-config sent by the user.

cloud-init/config/cloud.cfg (Default configuration)
  4 # Implement for Ubuntu only: create the default 'ubuntu' user
  5 users:
  6 default: true
  7

If a user launches with the cloud config of:
users:
    foo: True

The expected behavior is that user foo would be configured equivalent to the parameter "user: foo".

However, due to this code and the default configuration:
cloud-init/cloudinit/stages.py
164
165.....def _read_cfg(self, extra_fns):
166.........no_cfg_paths = helpers.Paths({}, self.datasource)
167.........merger = helpers.ConfigMerger(paths=no_cfg_paths,
168.......................................datasource=self.datasource,
169.......................................additional_fns=extra_fns,
170.......................................base_cfg=self._read_base_cfg())
171........return merger.cfg

cloud-init generates the user lists as:
users:
    default: True
    foo: True

So what is happening is the default configuratoin is merged with the cloud-config.

Effectively this means that regardless of the user configuration send in the cloud-config:
  - The ubuntu user will always be created on a Ubuntu systems
  - The ubuntu user is always user[0]
  - Any configured user is user[n+1], and therefore will not be uzer[0]
  - A cloud-config of "user: default: false" will be ignored.

IMHO, this is a pretty serious bug.

@ubuntu-server-builder ubuntu-server-builder added launchpad Migrated from Launchpad priority Fix soon labels May 9, 2023
@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Ben Howard(darkmuggle-deactivatedaccount) wrote on 2012-08-24T22:17:57.644633+00:00

Filed MP: #121295 as a potential fix.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Ben Howard(darkmuggle-deactivatedaccount) wrote on 2012-08-24T22:20:23.038973+00:00

Note, this bug appears to affect other cloud-config options that have a default option set.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Scott Moser(smoser) wrote on 2012-08-27T13:24:53.928691+00:00

What you're running into is really just a generic limitation of the merge routine that cloud-init uses. We had hoped to improve the function of this merge routine at Bug 1023179, but have not implemented this yet.

I don't think its really safe or desirable to change this at the moment.

A more reasonable change I think is to change the users and groups to be lists of dicts rather than a dict of dicts.
dicts get added to or updated, but lists get replaced. So, if your default config entry is a list rather than a dict, then the user's value will entirely replace the list.

Ie:
groups:

  • ubuntu: [foo,bar]
  • cloud-users
    users:
  • name: ubuntu

you could also allow for the case where an entry in the ''users" list is a string:
users:

  • default

basically, then the presense of the 'default' user in the users list would trigger creation of the "default" user.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Ben Howard(darkmuggle-deactivatedaccount) wrote on 2012-09-19T21:08:52.555574+00:00

This was fixed in r641. Marking as fixed released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
launchpad Migrated from Launchpad priority Fix soon
Projects
None yet
Development

No branches or pull requests

1 participant