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

Generate separate cloud-config.yaml for when not using cidata.iso #2268

Open
afbjorklund opened this issue Apr 4, 2024 · 10 comments
Open

Generate separate cloud-config.yaml for when not using cidata.iso #2268

afbjorklund opened this issue Apr 4, 2024 · 10 comments

Comments

@afbjorklund
Copy link
Contributor

afbjorklund commented Apr 4, 2024

Description

When looking at alternative implementations, such as Raspberry Pi or cloud instances, it could be useful to look at the generated basic cloud-init / cloud-config information. Without having it embedded as user-data, in the cidata.iso

Maybe we could also just create a stand-alone yaml file, like was done for the ignition yaml file. It doesn't include the boot scripts or the lima-guestagent/nerdctl-full, but does include basic stuff like the user and keys and so on (same args).

template: pkg/cidata/cidata.TEMPLATE.d/user-data

Especially when not generating a cidata.iso anymore


example (outdated) background reasoning https://blog.hypriot.com/post/cloud-init-cloud-on-hypriot-x64/

Lima wouldn't actually do anything with the file, it is just provided for the user to create their instance

@afbjorklund
Copy link
Contributor Author

Something like

#cloud-config
# vim:syntax=yaml

growpart:
  mode: auto
  devices: ['/']

{{- if .UpgradePackages }}
package_update: true
package_upgrade: true
package_reboot_if_required: true
{{- end }}

{{- if .TimeZone }}
timezone: {{.TimeZone}}
{{- end }}

users:
  - name: "{{.User}}"
    uid: "{{.UID}}"
    homedir: "{{.Home}}"
    shell: /bin/bash
    sudo: ALL=(ALL) NOPASSWD:ALL
    lock_passwd: true
    ssh-authorized-keys:
    {{- range $val := .SSHPubKeys }}
      - {{ printf "%q" $val }}
    {{- end }}

@jandubois
Copy link
Member

Why not just include user-data under a different name then? You can just ignore the data you don't need.

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Apr 4, 2024

Why not just include user-data under a different name then?

I think that is what I was trying to say 😀 Or it could be user-data

i.e. talking about the file name in the lima instance directory here

EDIT: will hack together some draft, maybe easier to reason about

@jandubois
Copy link
Member

i.e. talking about the file name in the lima instance directory here

Oh, I missed that this would be on the host and not inside the VM. In that case we do need to worry about including keys, or make sure we use 600 permissions for the file.

@afbjorklund
Copy link
Contributor Author

In that case we do need to worry about including keys, or make sure we use 600 permissions for the file.

Something that would probably also apply to the cidata.iso file in that case, and could be done already now?

But since it is only the public keys, I don't think that is necessary... The password (from blog above) is outdated*

The original images (on https://blog.hypriot.com/) had:

users:
  - name: pirate
    gecos: "Hypriot Pirate"
    sudo: ALL=(ALL) NOPASSWD:ALL
    shell: /bin/bash
    groups: users,docker,video
    plain_text_passwd: hypriot
    lock_passwd: false
    ssh_pwauth: true
    chpasswd: { expire: false }

* the Raspberry Pi OS images no longer ship with a default user, but add one during first boot instead

@afbjorklund
Copy link
Contributor Author

@jandubois
Copy link
Member

But since it is only the public keys, I don't think that is necessary...

Yes, you are right; I was confused.

@afbjorklund
Copy link
Contributor Author

Note: the new file is generated when the instance is created, since it is needed before it can be started

@jandubois
Copy link
Member

Note: the new file is generated when the instance is created, since it is needed before it can be started

Shouldn't it be created every time before the instance is started, in case lima.yaml has changed?

I guess this becomes a chicken-and-egg problem now, as you would still need access to the updated file before starting the instance.

Something like limactl start INSTANCE --not-really-just-update-the-config --set …, but less awkward. 😄

@afbjorklund
Copy link
Contributor Author

I added code to the hostagent, to (re)create the cloud-config.yaml file at the same time as the cidata.iso

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

No branches or pull requests

2 participants