GithubHelp home page GithubHelp logo

packer-proxmox-ubuntu's People

Contributors

aracloud avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

packer-proxmox-ubuntu's Issues

Stuck at palce, Waiting for SSH to become available

I am stuck here at this step:
If i login to Proxmox gui web interface, i can see the vm is created and power up and showing below message in the console:

image

I used my own iso file: ubuntu.20.10-live-server-amd64.iso
VM is created with name "ubuntu-2004-tmpl".
One question, In this process do we need to provide user input like keyboard preference language or its automatically installed ready os ?

proxmox: output will be in this color.

==> proxmox: Creating VM
==> proxmox: Starting VM
==> proxmox: Waiting 5s for boot
==> proxmox: Typing the boot command
==> proxmox: Waiting for SSH to become available...

variables.json:

{
	"proxmox_host": "xxx.xx.0.250",
	"proxmox_node_name": "homeserver",
	"proxmox_api_user": "xxxx@pam",
	"proxmox_api_password": "xxxxx",

	"template_name": "ubuntu-2004-tmpl",
	"template_description": "Ubuntu 20.04 by packer",

	"ssh_fullname": "ubuntu",
	"ssh_password": "ubuntu",
	"ssh_username": "ubuntu",

	"hostname": "ubuntu-20-04",
	"vmid": "101",
	"locale": "en_US",
	"cores": "1",
	"sockets": "1",
	"memory": "1024",
	"disk_size": "10G",
        "datastore": "local-lvm", 
	"datastore_type": "lvmthin",
	"iso": "local:iso/ubuntu-20.10-live-server-amd64.iso"
}

packer.json:

{
  "sensitive-variables": ["proxmox_pass", "ssh_password" ],

  "builders": [
    {
      "type": "proxmox",
      "proxmox_url": "https://{{user `proxmox_host`}}:8006/api2/json",
      "insecure_skip_tls_verify": true,
      "username": "{{user `proxmox_api_user`}}",
      "password": "{{user `proxmox_api_password`}}",

      "vm_id": "{{ user `vmid` }}",
      "vm_name": "{{user `template_name`}}",
      "template_description": "{{ user `template_description` }}",

      "node": "{{user `proxmox_node_name`}}",
      "cores": "{{ user `cores` }}",
      "sockets": "{{ user `sockets` }}",
      "memory": "{{ user `memory` }}",
      "os": "l26",

      "network_adapters": [
        {
          "model": "virtio",
          "bridge": "vmbr0"
        }
      ],

      "disks": [
        {
          "type": "scsi",
          "disk_size": "{{ user `disk_size`}}",
          "storage_pool": "{{user `datastore`}}",
          "storage_pool_type": "{{user `datastore_type`}}",
          "format": "raw",
          "cache_mode": "writeback"
        }
      ],

      "ssh_timeout": "30m",
      "ssh_handshake_attempts": "100",
      "ssh_password": "{{ user `ssh_password` }}",
      "ssh_username": "{{ user `ssh_username` }}",

      "qemu_agent": true,
      "unmount_iso": true,

      "iso_file": "{{user `iso`}}",


      "boot_wait": "5s",
      "boot_command": [
        "<esc><wait><esc><wait><f6><wait><esc><wait>",
        "<bs><bs><bs><bs><bs>",
        "autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ ",
        "--- <enter>"
      ]
    }
  ],

  "provisioners": [
    {
      "type": "shell",
      "scripts": [ "./script.sh" ]
    }
  ]
}

script.sh:

#!/bin/bash -eux

date > provision.txt

# defined my software stack needed
sudo apt -y update
sudo apt -y upgrade
sudo apt -y install \
software-properties-common \
net-tools \
cloud-initramfs-growroot \
docker \
docker-compose \
ntpdate \
mlocate

cat <<EOF > ~/hostset.sh
#!/bin/bash

cd /home/ubuntu

# set hostname to what dhcp has configured for that MAC/IP
# and hostset.done file does not exist (one time execution)
if [ ! -f hostset.done ]
then
    myip=\$(ifconfig ens18 |grep netmask |cut -d " " -f 10)
    myhostname=\$(nslookup \$myip |grep "name ="|sed 's/^.*name = //' |cut -d "." -f 1)
    echo \$myhostname > hostname
    sudo mv hostname /etc/hostname
    sudo sed -i s/ubuntu-20-04/\$myhostname/g /etc/hosts
    touch hostset.done
    sudo reboot
fi
EOF

cat <<EOF | sudo tee -a /etc/crontab
@reboot root /usr/bin/sh /home/ubuntu/hostset.sh 
EOF

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.