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

Add support for linux VMs #33

Merged
merged 1 commit into from
Nov 4, 2022
Merged

Add support for linux VMs #33

merged 1 commit into from
Nov 4, 2022

Conversation

mayeut
Copy link
Contributor

@mayeut mayeut commented Nov 1, 2022

Resolves #32

I'm new to packer, go & provisioning in general so things might be ill formed but the example works.

Used https://ubuntu.com/server/docs/install/autoinstall-quickstart as a starting point for auto install.

A few notes:
It assumes the install process will shutdown the VM rather than restart it at the end of installation: the sample ubuntu autoinstall will just loop into the installer if the system is restarted rather than shutdown.
The auto-resize in the guest OS is probably less generic than the macOS one so a resize_disk_command was introduced. fixing the disk size is left to the user with generic shell provisioning steps.
The boot_command is hijacked to be used for the VM creation/installation rather than the following run.

Copy link
Contributor

@fkorotkov fkorotkov left a comment

Choose a reason for hiding this comment

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

Thank you for the PoC! I think we should leave resizing of the disk out of scope for this PR. There is some very specific logic for macOS, I think in a follow up PR we can create similar steps for Linux and depending on imageConfig["os"] add different steps.

version: 1
identity:
hostname: ubuntu-server
password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this password? Should it be ubuntu?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should it be ubuntu?

Well it is:

echo 'ubuntu' |openssl passwd -6 -stdin -salt exDY1mhS4KUYCE/2
$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0

@mayeut
Copy link
Contributor Author

mayeut commented Nov 1, 2022

I think we should leave resizing of the disk out of scope for this PR

Ok, shall I remove everything or shall I leave the OS detection and the following ?

if isLinux {
	ui.Error("Automatic partition resizing not implemented, guest OS might not see the full disk capacity.")
	return multistep.ActionContinue
 }

The original step didn't have a check on ExitStatus so it will just print a diskutil: command not found message but it won't fail the build.

@edigaryev
Copy link
Contributor

Ok, shall I remove everything or shall I leave the OS detection and the following ?

It seems that we can offload most of the OS-specific logic from stepResize to a user-managed .hcl (which knows the OS by design) and have no OS detection logic at all.

But this is for a separate PR, as noted by @fkorotkov.

@mayeut
Copy link
Contributor Author

mayeut commented Nov 2, 2022

When rebasing on main, I had to leave a check to avoid failure with the disk parsing introduced on macOS.
The check changed to a $(uname -s) == Darwin check.
I removed the specific resize_disk_command.

builder/tart/builder.go Show resolved Hide resolved
builder/tart/step_disk_resize.go Show resolved Hide resolved
@fkorotkov fkorotkov merged commit 059f836 into cirruslabs:main Nov 4, 2022
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.

Create Linux VM
3 participants