Running Amazon Linux 2 on prem on VMware

There is no default ec2-user or root password set for the Amazon Linux 2 ova. You must use cloud-init via it’s nocloud datasource

To get Amazon Linux 2 running on VMware create the following files and package them as an iso mounted to the VM on boot. cloud-init will do the work.

meta-data

local-hostname: amazonlinux.onprem

# eth0 is the default network interface enabled in the image.
network-interfaces: |
  auto eth0
  iface eth0 inet dhcp

network-interfaces format

How is the network interface getting configured? It amazes me that cloud-init use is so widespread given the poor documentation.

AWS decided to use a deprecated Legacy ENI method to configure the network in their example documentation When configuring with Legacy ENI cloud-init it will parse the value of netowrk-interfaces to the configuration below using _ifaces_to_net_config_data Where you can pass most things defined in man 5 interfaces.

The source code to cloud-init should give you an idea of the possible values. This gets converted to a V1 type config which is documented

{
    "version": 1,
    "config": [
        {
            "subnets": [{"control": "auto", "type": "dhcp", "_orig_eni_name": "eth0"}],
            "type": "physical",
            "name": "eth0",
        }
    ],
}

user-data

users:
- default

- name: brent
    ssh-authorized-keys:
            - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDxkZv3YtjJn2Ld0ZE7/zpI0OvUqrPBhacxZ8nzl9GqAwWwIx60alYDtUvAP6K1HoiEmB2RSAxSUBRbkNSKoRLUzCbqFsS6+8qgyqInQLc4AXOzjPOzFY3VdFyDpBRe7RQrbljOlUfoyzgQaI+wC4ZNFvQkwv5ISJHNGe+yueVMpri/yQuNUZavLmRT3SKqzBeuWS402KZDMLWv5zBxekPJEg6PR1VFFPBZ57pnRtTfvnYLY1fuRybnz8wOLPQlnqLNzN2twTzV0BoQ+0NEkDDICDmMHWFxCroGCxUGogZQ+jrLPlxJEcQKurerEiJQ15ArE0ZETnRfjA31cWmfz0fl brent@DESKTOP-LMS29I3
    groups: sudo
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    plain_text_passwd: amazon
    lock_passwd: false

chpasswd:
list: |
    ec2-user:amazon

Then generate the iso image by stuffing the meta-data and user-data files into the root of the iso:

genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data

Comments

comments powered by Disqus