shantanoo-desai / packer-ubuntu-server-uefi

Packer Templates for creating Ubuntu Live Server Images with Packer + QEMU + Autoinstall (cloud-init)
Apache License 2.0
29 stars 13 forks source link

I put network config in user-data file build stop #20

Open mfaridi1394 opened 3 days ago

mfaridi1394 commented 3 days ago

I want add network config to build and right now user-data is like this

#cloud-config
autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: us
  ssh:
    install-server: true
    allow-pw: true
  packages:
    - qemu-guest-agent
  network:
    network:
        version: 2
        ethernets:
            ens192:
                dhcp4: true
  user-data:
    preserve_hostname: false
    hostname: packerubuntu
    package_upgrade: true
    timezone: Europe/Berlin
    chpasswd:
      expire: true
      list:
        - user1:packerubuntu
    users:
      - name: admin
        passwd: $6$xyz$74AlwKA3Z5n2L6ujMzm/zQXHCluA4SRc2mBfO2/O5uUc2yM2n2tnbBMi/IVRLJuKwfjrLZjAT7agVfiK7arSy/
        groups: [adm, cdrom, dip, plugdev, lxd, sudo]
        lock-passwd: false
        sudo: ALL=(ALL) NOPASSWD:ALL
        shell: /bin/bash
      - name: user1
        plain_text_passwd: packerubuntu
        lock-passwd: false
        shell: /bin/bash

but when I run make command for build ubuntu 22.04, I see these and building is stopped

==> custom_build.qemu.custom_image: Retrieving ISO
==> custom_build.qemu.custom_image: Trying https://releases.ubuntu.com/jammy/ubuntu-22.04.4-live-server-amd64.iso
==> custom_build.qemu.custom_image: Trying https://releases.ubuntu.com/jammy/ubuntu-22.04.4-live-server-amd64.iso?checksum=sha256%3A45f873de9f8cb637345d6e66a583762730bbea30277ef7b32c9c3bd6700a32b2
==> custom_build.qemu.custom_image: https://releases.ubuntu.com/jammy/ubuntu-22.04.4-live-server-amd64.iso?checksum=sha256%3A45f873de9f8cb637345d6e66a583762730bbea30277ef7b32c9c3bd6700a32b2 => /home/mostafa/.cache/packer/67a67612e798509328c9ee5490f7388971ed878b.iso
==> custom_build.qemu.custom_image: Starting HTTP server on port 8532
==> custom_build.qemu.custom_image: Found port for communicator (SSH, WinRM, etc): 3907.
==> custom_build.qemu.custom_image: Creating temporary RSA SSH key for instance...
==> custom_build.qemu.custom_image: Looking for available port between 5900 and 6000 on 127.0.0.1
==> custom_build.qemu.custom_image: Starting VM, booting from CD-ROM
    custom_build.qemu.custom_image: The VM will be run headless, without a GUI. If you want to
    custom_build.qemu.custom_image: view the screen of the VM, connect via VNC without a password to
    custom_build.qemu.custom_image: vnc://127.0.0.1:5927
==> custom_build.qemu.custom_image: Waiting 5s for boot...
==> custom_build.qemu.custom_image: Connecting to VM via VNC (127.0.0.1:5927)
==> custom_build.qemu.custom_image: Typing the boot commands over VNC...
    custom_build.qemu.custom_image: Not using a NetBridge -- skipping StepWaitGuestAddress
==> custom_build.qemu.custom_image: Using SSH communicator to connect: 127.0.0.1
==> custom_build.qemu.custom_image: Waiting for SSH to become available...
shantanoo-desai commented 3 days ago

The network configuration seems to be false.

You have network mentioned twice

mfaridi1394 commented 3 days ago

The network configuration seems to be false.

You have network mentioned twice

I change it to these `#cloud-config autoinstall: version: 1 locale: en_US keyboard: layout: us ssh: install-server: true allow-pw: true packages:

shantanoo-desai commented 2 days ago

It will take time to build and image so the messages you see are normal. it takes about 20 - 40 minutes to build an image. If packer fails it will provide a complete log of why it failed and it will return you back to the terminal shell.

mfaridi1394 commented 2 days ago

It will take time to build and image so the messages you see are normal. it takes about 20 - 40 minutes to build an image. If packer fails it will provide a complete log of why it failed and it will return you back to the terminal shell.

I use your code to build this image I do not change username and password everything is like your code , only I add network config and I see those errors I posted in three comments above, I think config for network setting is wrong or bad place. without network config building image start after 5 min and it build Ubuntu image quickly.

shantanoo-desai commented 2 days ago

You can do this:

  1. Build the initial image without network settings
  2. Use the image built from Step 1 to add the files for network configuration in the image and then start using this image.

I have not been able to figure out where the problem lies but you need to do that research. I will keep this issue open and post something here if I find a solution

mfaridi1394 commented 2 days ago

You can do this:

1. Build the initial image without network settings

2. Use the image built from Step 1 to add the files for network configuration in the image and then start using this image.

I have not been able to figure out where the problem lies but you need to do that research. I will keep this issue open and post something here if I find a solution

I want make more than 50 ubuntu image by this code and this so hard and get time I config network on these VMs manually