On Premise Amazon Linux 2

From Michael's Information Zone
Jump to navigation Jump to search

Purpose

Very excited about this, no longer will I need to pay for dev hosting.

Process

Syntax and formatting very important for building the seed ISO.[1]

  • For building a basic instance that is very similar to what you get when creating a standard instance on AWS
  • Create the user-data file, and place the following into it. NOTE: I am telling the instance to keep the networking information from the meta-data file.
#cloud-config
# vim:syntax=yaml
users:
- default
chpasswd:
  list: |
    ec2-user:TempP@ss1
write_files:
 -  path: /etc/cloud/cloud.cfg.d/80_disable_network_after_firstboot.cfg
    content: |
     network:
       config: disabled
  • Create the meta-data file and enter the following. Make sure to enter your own settings. So far I have not been able to get the instance to keep the gateway settings, but it takes the netmask and ip address.
local-hostname: amazonlinux.onprem
network-interfaces: |
 iface eth0 inet static
 address xxx.xxx.xxx.xxx
 network xxx.xxx.xxx.0
 netmask xxx.xxx.xxx.0
 broadcast xxx.xxx.xxx.255
 gateway xxx.xxx.xx1
  • Create the ISO. I am doing this from a Fedora 28 workstation
genisoimage -output seed.iso -V cidata -joliet -rock user-data meta-data

I: -input-charset not specified, using utf-8 (detected in locale settings)
Total translation table size: 0
Total rockridge attributes bytes: 331
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used 0
183 extents written (0 MB)
  • I then uploaded the ISO to my ISO datastore using VMware vsphere.
  • Download the OVA file, then upload to VMware.
  • Clone this machine, and only work with the clones. If you make a mistake you must destroy the VM and start over. Cloudinit takes no prisoners.
  • Attach the seed.iso image to the new VM, make sure it is connected, then start the VM. At this point you can confirm the settings took by
  1. Checking the hostname is not localhost.
  2. Logging in using the credentials you set in the user-data file. Username would be ec2-user.
  3. Checking that the IP address is set correctly.
  • At this point you should be able to remove the seed ISO, then reboot to ensure the network settings took. Then you can do normal network script configs to make everything work as expected.
  • https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html#amazon-linux-2-virtual-machine-download