Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mfaridi1394 opened this issue Jul 2, 2024 · 6 comments
Open

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

mfaridi1394 opened this issue Jul 2, 2024 · 6 comments

Comments

@mfaridi1394
Copy link

mfaridi1394 commented Jul 2, 2024

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
Copy link
Owner

The network configuration seems to be false.

You have network mentioned twice

@mfaridi1394
Copy link
Author

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: - qemu-guest-agent network: version: 2 renderer: networkd ethernets: enp3s0: 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 still I see these errors after build failed.
==> image.qemu.image: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey password], no supported methods remain ==> image.qemu.image: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey password], no supported methods remain

@shantanoo-desai
Copy link
Owner

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
Copy link
Author

mfaridi1394 commented Jul 3, 2024

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
Copy link
Owner

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants