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

Document network-based alternatives to seed.iso booting with Amazon Linux 2 #123

Closed
mikaelhg opened this issue Jul 10, 2020 · 8 comments
Closed
Assignees

Comments

@mikaelhg
Copy link

mikaelhg commented Jul 10, 2020

The "Run Amazon Linux 2 as a virtual machine on premises" page describes a fairly cumbersome way of running Amazon Linux 2 in local virtual machines through using various tools to provision ISO9660 seed.iso files just to serve the VM instance two small data files.

It would be great it the documentation also pointed out that since the VM provisioning is being done with cloud-init, and the image has configured a fairly extensive datasource_list: [ NoCloud, AltCloud, ConfigDrive, OVF, None ] which starts with NoCloud, that NoCloud also allows you to serve these files over HTTP.

There are two easy ways of using network configuration instead of seed.iso. Either you tell GRUB to add a parameter to the kernel boot configuration, or you tell KVM/VMWare/Virtualbox to set the virtual machine's SMBIOS value to something which cloud-init's NoCloud understands.

The documentation page https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html describes the parameters.

If you wish to use Packer, for example, to provision local KVM qcow2 files of AL2, you'd use a configuration which looks a bit like this:

{
  "builders": [
    {
      "vm_name": "alpha",
      "type": "qemu",
      "accelerator": "kvm",
      "qemuargs": [
        ["-display", "none"],
        ["-smbios", "type=1,serial=ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"]
      ],
      "format": "qcow2",
      "iso_url": "images/amzn2-kvm-2.0.20200602.0-x86_64.xfs.gpt.qcow2",
      "iso_checksum": "sha256:1ca3af1df04dd9c46240414be3fbc024cdd1fab5fe9b00a975614f24e682da85",
      "disk_image": true,

      "ssh_handshake_attempts": "20",
      "ssh_username": "ec2-user",

      "net_device": "virtio-net",
      "disk_interface": "virtio",

      "http_directory": "httpserver",
      "output_directory": "output"

    }
  ]
}

the sillier way to achieve the same is to tell your VM creator to send keypresses to the virtual terminal which is booting up AL2 for the first time:

"boot_wait": "1s",
"boot_command": [
    "<shift><shift><wait><wait>e<down><down><down><down><down><down><down><down><down><down><down><down><left>",
    " ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/",
    "<leftCtrlOn>x<leftCtrlOff>"
  ]
@meiringa
Copy link
Contributor

Thank you for the suggestions. The service team is looking into this. We will provide feedback shortly.

@mikaelhg
Copy link
Author

mikaelhg commented Jul 27, 2020

No hurry. At least 80% of my purpose was achieved by making this solution googleable for people who bump into the same issue.

@julieso julieso assigned julieso and meiringa and unassigned julieso Nov 17, 2020
@mojoa
Copy link

mojoa commented Apr 29, 2021

Any updates?

I can't seem get the seed.iso method to update the network settings with 2.0.20210326.0 using vmware. The hostname updates but not the network settings. I used the document listed sample seed.iso on a 192.168.1.0 network so I literally had nothing to change. dmesg gives no clue and the documentation gives no indication of when in the boot process the seed.iso file comes into play.

As far as "easy" ways other than seed.iso file, I need some specific examples of how these would work, possibly including troubleshooting.

So it would be great if there were more detail in the documentation including all the various boot methods.

@mikaelhg
Copy link
Author

Alas, I don't have a VMWare license, nor a yacht to sell to finance one.

@mojoa
Copy link

mojoa commented Apr 29, 2021

What the market will bear..:-(
Actually, vmware workstation 16 is free and works well for those constrained by a Windows environment.
As far as Documentation for this use case, it seems "easy" to follow the instructions, but the AL2 network is unchanged and I can't find any information on settings, proper configuration or troubleshooting.

I know the seed file is being read because the hostname changes.

local-hostname: k2a

# eth0 is the default network interface enabled in the image. You can configure
# static network settings with an entry like below.
network-interfaces: |
  auto eth0
  iface eth0 inet static
  address 192.168.1.40
  network 192.168.1.0
  netmask 255.255.255.0
  broadcast 192.168.1.255
  gateway 192.168.1.254

https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html mentions injecting network settings:

Also, you can inject an /etc/network/interfaces file by providing the content for that file in the network-interfaces field of metadata.

But how network configuration is implemented for al2 interfaces in network-scripts is unclear to me and I feel needs to be documented.

Also, what other configuration options do I have? How would I implement iptables or routing options on boot for AL2?

@mojoa
Copy link

mojoa commented Apr 29, 2021

Just found a forum link https://forums.aws.amazon.com/thread.jspa?messageID=971373&#971373

It appears as though this is method is broken and has been for some time.

This needs to be highlighted in the documentation, rather than wasting peoples time.

From the forum:

This is sadly still broken with the latest 2.0.20210126.0 release.

The documentation in the README.cloud-init is broken, as is the document here:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html

The linked reply with a diff to fix cloud-init does look like it would work, but there's no way to patch this at boot time that I can see. I'm really stuck trying to figure out how to work around this, and I'm still stuck loading a two year old image and then upgrading it. Really frustrating - I've tried all sorts of yaml config variants for the seed.iso with no luck.

@mojoa
Copy link

mojoa commented Apr 29, 2021

Another forum link showing heath@aws seems to acknowledge the problem but I am not seeing any final resolution.

https://forums.aws.amazon.com/thread.jspa?messageID=971374&#971374

@mikaelhg
Copy link
Author

Seems like you're describing a completely different issue than what is the topic of this ticket, so you might want to open a new ticket for that issue.

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

No branches or pull requests

5 participants