Perepare Linux
For me I perfer to Debian linux
Install docker
- Install docker
1 2 3 4 5 6 7 8 9 10
apt install -y wget curl cp /etc/apt/sources.list /etc/apt/sources.list-bak wget https://mirrors.ustc.edu.cn/repogen/conf/debian-https-4-bullseye -O /etc/apt/sources.list sudo apt install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io sudo systemctl start docker sudo systemctl enable docker
Install software
- Install git
1
apt install -y git-core
Git Repository
git pull
1 2
git clone https://github.com/vyos/vyos-vm-images.git cd vyos-vm-images
commit download-iso on qemu.yaml
- Edit
qemu.yml
1
vi qemu.yml
- commit
- download-iso
1 2 3
- install-packages # - download-iso - mount-iso
- Edit
Change vyos_qemu_img path from
/tmp
totmp
1
vi qemu.yml
Change
1
vyos_qemu_img: "/tmp/vyos-{{ vyos_version }}{{ ci_tag | default() }}-{{vyos_disk_size}}G-qemu.qcow2"
to:
1
vyos_qemu_img: "tmp/vyos-{{ vyos_version }}{{ ci_tag | default() }}-{{vyos_disk_size}}G-qemu.qcow2"
Download vyos iso file
- Build or copy iso image to local
1 2 3
mkdir tmp curl -fsSL https://xxxxxxx/vyos-1.3.6-amd64.iso -o tmp/vyos-1.3.6-amd64.iso ls /tmp/*.iso
Copy customized files into
- Copy file into files
1
make
Build qcow2 image
Run docker
1 2 3 4
#Downlaod dockerfile and run build environment in docker wget https://raw.githubusercontent.com/vyos/vyos-vm-images/current/Dockerfile # Build docker iamges docker build --tag vyos-vm-images:latest -f ./Dockerfile .
Run docker
1
docker run --rm -it --privileged -v $(pwd):/vm-build -v $(pwd)/images:/images -w /vm-build vyos-vm-images:latest bash
Build qcow2 image
1 2 3 4 5 6 7 8
ansible-playbook qemu.yml \ -e disk_size=2 \ -e iso_local=tmp/vyos-1.3.6-amd64.iso \ -e grub_console=serial \ -e cloud_init=true \ -e cloud_init_ds=NoCloud \ -e guest_agent=qemu \ -e enable_ssh=true
Build image with custome files
copy qcow2 file to files/custom_files
opt/vyatta/etc/config
stand for /config folder
Add file with x
excute permission
Edit
roles/copy-custom-files/tasks/main.yml
addmode: a+x
1 2 3 4 5 6 7 8
- name: Copy custom files to the system, preserving paths become: true copy: src: "files/custom_files/" dest: "{{ vyos_install_root }}" force: true mode: a+x when: custom_files is defined
Build qcow2 image with custom_files option
1 2 3 4 5 6 7 8 9 10
# 1.3.6 ansible-playbook qemu.yml \ -e disk_size=2 \ -e iso_local=tmp/vyos-1.3.6-amd64.iso \ -e grub_console=serial \ -e cloud_init=true \ -e cloud_init_ds=NoCloud \ -e guest_agent=qemu \ -e enable_ssh=true \ -e custom_files=true
1 2 3 4 5 6 7 8 9 10
# 1.4.0-eap1 ansible-playbook qemu.yml \ -e disk_size=2 \ -e iso_local=tmp/vyos-1.4.0-epa1-amd64.iso \ -e grub_console=serial \ -e cloud_init=true \ -e cloud_init_ds=NoCloud \ -e guest_agent=qemu \ -e enable_ssh=true \ -e custom_files=true