fix : ensX network interface index

This commit is contained in:
Antoine 2020-11-13 16:09:22 +01:00
parent 37743f6637
commit 7361a3442a
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
6 changed files with 17 additions and 23 deletions

View File

@ -15,10 +15,10 @@ exec-debian:
docker-compose exec debian_packer bash
test-debian:
./run-image.sh debian
./run-image.sh ./image/assets/output_qcow2/debian_packer.qcow2
test-gentoo:
./run-image.sh gentoo
./run-image.sh ./image/assets/output_qcow2/gentoo_packer.qcow2
down:
docker-compose down

View File

@ -4,7 +4,6 @@ services:
gentoo_packer:
image: ${REGISTRY_URL}/${IMAGE_NAME}:${VERSION}
privileged: true
network_mode: "host"
environment:
- SOURCE_NAME=qemu.gentoo
- SSH_LIVE_USERNAME=root
@ -16,15 +15,12 @@ services:
volumes:
- "./image/assets:/packer"
- "./image/cache:/packer-cache"
#ports:
# - "5900:5900/udp"
# - "2222:2229"
# - "10082:10082"
ports:
- "5900:5900"
debian_packer:
image: ${REGISTRY_URL}/${IMAGE_NAME}:${VERSION}
privileged: true
network_mode: "host"
environment:
- SOURCE_NAME=qemu.debian
- SSH_LIVE_USERNAME=debian
@ -36,11 +32,5 @@ services:
volumes:
- "./image/assets:/packer"
- "./image/cache:/packer-cache"
#ports:
# - "5900:5900/udp"
# - "2222:2229"
# - "10082:10082"
# entrypoint: "bash -c"
# command: "'while sleep 3600; do :; done'"
# stdin_open: true
# tty: true
ports:
- "5900:5900"

View File

@ -5,7 +5,7 @@ grub_timeout: 1
network_config:
src: "interfaces.j2"
dest: "/etc/network/interfaces"
nic_name: "ens4"
nic_name: "ens3"
initial_package:
- vim

View File

@ -25,20 +25,24 @@ source "qemu" "debian" {
http_port_min = 10082
host_port_min = 2229
host_port_max = 2229
vnc_bind_address = "0.0.0.0"
vnc_port_min = 5900
vnc_port_max = 5900
iso_checksum = "${var.iso_checksum}"
iso_url = "${var.iso_url}"
memory = 2048
net_device = "virtio-net"
output_directory = "output_qcow2"
// Warning -device order impact network interface naming index ensX
qemuargs = [
["-boot", "b"],
["-device", "virtio-rng-pci"]
["-device", "virtio-net,netdev=user.0"],
["-netdev", "user,id=user.0,hostfwd=tcp::{{ .SSHHostPort }}-:22"],
["-device", "virtio-rng-pci"],
]
shutdown_command = "sudo /sbin/shutdown -hP now"
ssh_password = "${var.ssh_password}"
ssh_username = "${var.ssh_username}"
ssh_wait_timeout = "900m"
vm_name = "debian_packer.qcow2"
vnc_port_max = "5900"
vnc_port_min = "5900"
}

View File

@ -10,7 +10,7 @@ SSH_PUB=$(cat ./id_rsa_qemu.pub)
export PACKER_LOG=1; packer build --only="$SOURCE_NAME" \
-var ssh_username="$SSH_LIVE_USERNAME" \
-var ssh_password="$SSH_LIVE_PASSWORD" \
-var ansible_extra_vars="$ANSIBLE_EXTRA_VARS ssh_pub=$SSH_PUB" \
-var ansible_extra_vars="$ANSIBLE_EXTRA_VARS ssh_pub='$SSH_PUB'" \
-var ansible_provisioning_playbook="$ANSIBLE_PLAYBOOK" \
-var iso_checksum="$ISO_CHECKSUM" \
-var iso_url="$ISO_URL" \

View File

@ -1,6 +1,6 @@
#!/bin/bash
# pass debian or gentoo as first parameter
# pass qcow2 image path as first parameter
if [ "$#" -lt 1 ]; then
exit 1
fi
@ -9,7 +9,7 @@ fi
qemu-system-x86_64 \
-boot order=d -m 1024 \
-smp cpus=1,sockets=2,maxcpus=2 \
-drive "file=./image/assets/output_qcow2/$1_packer.qcow2,format=qcow2,index=1" \
-drive "file=$1,format=qcow2,index=1" \
-net nic,model=virtio \
-net user,hostfwd=tcp::5556-:22