NOTE: You can support VyOS development by using the official VyOS AMI from the marketplace: https://aws.amazon.com/marketplace/pp/B074KJK4WC (starting from $50/year).
The official AMIs are built with these exact scripts so if you build one for yourself, your own AMI will be functionally identical to the official ones.
VyOS images built with default make iso
options do not include EC2 autoconfiguration mechanism).
To make an image suitable for an AMI, do this instead:
./configure
sudo make AWS
The build scripts are based on ansible and awscli.
To install and configure awscli, follow the user guide: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html Make sure the python modules boto, botocore, and boto3 also gets installed.
Ansible is available from the repositories on most Linux distributions.
These scripts and playbooks should work on any Linux system, or, theoretically, on any system supported by ansible and awscli.
docker run -it -v $(pwd):/mount -w /mount --name ubuntu2404-ansible-8-3-0 ubuntu:noble
apt install python3-full python3-pip python3-virtualenv libffi-dev openssh-client
virtualenv env
source env/bin/activate
pip install -r requirements.txt
# https://vyos.net/get/nightly-builds/
VYOS_ISO_NAME=1.5-rolling-202405121403
VYOS_ISO_FILE=vyos-${VYOS_ISO_NAME}-amd64.iso
wget -O playbooks/files/${VYOS_ISO_FILE} https://github.com/vyos/vyos-rolling-nightly-builds/releases/download/${VYOS_ISO_NAME}/${VYOS_ISO_FILE}
./vyos-build-ami ${VYOS_ISO_FILE}
Now there's a catch, I can't figure out a working config.boot file (playbooks/templates/config.boot.default.ec2) . So task "name: Copy the default config for EC2 to the installed image" is commented out and you need to manually set the ssh key after you launch the VyOs instance :
- after launching the EC2 t3.* instance, open the EC2 Instance Connect (supported only with t3 type, not t2 type)
- wait a bit for the console to show up (could take a minute or even more) and login as vyos/vyos
- you need to set 3 things:
configure
set interfaces ethernet eth0 address 'dhcp'
set system login user vyos authentication public-keys ec2 key '...'
set system login user vyos authentication public-keys ec2 type 'ssh-rsa'
- start ssh:
sudo su -
service ssh start
Now you should be able to ssh to VyOs using your ssh key
The baseline code now supports only VyOS >=1.2.0. If you want to build an AMI from VyOS 1.1.x, check out the 1.1.x tag.
Since there is no easy way to upload a disk image to AWS directly, the playbooks create a Debian Jessie instance and run a sequence of commands to create an EBS disk and unpack the VyOS image to it, emulating the installation procedure.
NOTE: If playbook fails, it leaves behind a t2.micro instance, an SSH key pair names "vyos-build-ami", and a security group also named "vyos-build-ami". If you want to restart the process from the beginning, remove those by hand.
Sometimes playbook tasks fail through no one's fault, for example, SSH timeouts if an instance takes too long to create.
Note that AMI name is fixed, and registering the AMI will fail if you try to run the playbooks when you already have one in your account. De-register the old one first.
These scripts are available under the MIT license. See the LICENSE file for more info.
build-ami playbooks were originally written by hydrajump (https://github.com/hydrajump) and are now maintained by the VyOS team.