Perepare Linux
For me I perfer to Debian linux
Install docker
- Install docker
1 2 3 4 5 6 7 8 9 10apt 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
1apt install -y git-core
Git Repository
git pull
1 2git clone https://github.com/vyos/vyos-vm-images.git cd vyos-vm-imagescommit download-iso on qemu.yaml
- Edit
qemu.yml1vi qemu.yml - commit
- download-iso1 2 3- install-packages # - download-iso - mount-iso
- Edit
Change vyos_qemu_img path from
/tmptotmp1vi qemu.ymlChange
1vyos_qemu_img: "/tmp/vyos-{{ vyos_version }}{{ ci_tag | default() }}-{{vyos_disk_size}}G-qemu.qcow2"to:
1vyos_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 3mkdir 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
1make
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
1docker run --rm -it --privileged -v $(pwd):/vm-build -v $(pwd)/images:/images -w /vm-build vyos-vm-images:latest bashBuild qcow2 image
1 2 3 4 5 6 7 8ansible-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.ymladdmode: a+x1 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 definedBuild 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=true1 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
