Packer Build,构建ubuntu服务器时出错,虚拟框错误

时间:2015-08-08 06:53:30

标签: vagrant virtualbox ubuntu-14.04 packer devops

我正在使用打包器模板并尝试使用打包器,流浪汉和虚拟盒子来拍摄图像。当我运行我的包装模板时,使用以下命令:

packer build -only=virtualbox-iso application-server.json

(我的打包文件名为application-server.json)

它成功下载了所需的ubuntu-14.04.3-server-i386但无法启动虚拟机,但出现以下错误:

  virtualbox-iso: Executing custom VBoxManage commands...
  virtualbox-iso: Executing: modifyvm ubuntu-14.04.3-server-i386 --memo
  ry 1024
  virtualbox-iso: Executing: modifyvm ubuntu-14.04.3-server-i386 --cpus
    2
  virtualbox-iso: Starting the virtual machine...
  virtualbox-iso: Error starting VM: VBoxManage error:
  virtualbox-iso: Unregistering and deleting virtual machine...
  virtualbox-iso: Deleting output directory...
  Build 'virtualbox-iso' errored: Error starting VM: VBoxManage error: 

Some builds didn't complete successfully and had errors:
virtualbox-iso: Error starting VM: VBoxManage error:

Builds finished but no artifacts were created.

以下是我的包装工模板文件:

{
  "variables": {
      "PACKER_OS_FLAVOUR": "ubuntu",
      "PACKER_BOX_NAME": "ubuntu-14.04.3-server-i386",
      "AWS_ACCESS_KEY_ID": "{{env `AWS_ACCESS_KEY_ID`}}",
      "AWS_SECRET_ACCESS_KEY": "{{env `AWS_SECRET_ACCESS_KEY`}}"
    },
    "builders": [
      {
        "type": "virtualbox-iso",
        "boot_command": [
          "<esc><wait>",
          "<esc><wait>",
          "<enter><wait>",
          "/install/vmlinuz<wait>",
          " auto<wait>",
          " console-setup/ask_detect=false<wait>",
          " console-setup/layoutcode=us<wait>",
          " console-setup/modelcode=pc105<wait>",
          " debconf/frontend=noninteractive<wait>",
          " debian-installer=en_US<wait>",
          " fb=false<wait>",
          " initrd=/install/initrd.gz<wait>",
          " kbd-chooser/method=us<wait>",
          " keyboard-configuration/layout=USA<wait>",
          " keyboard-configuration/variant=USA<wait>",
          " locale=en_US<wait>",
          " netcfg/get_domain=vm<wait>",
          " netcfg/get_hostname=vagrant<wait>",
          " noapic<wait>",
          " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
          " -- <wait>",
          "<enter><wait>"
        ],
        "boot_wait": "10s",
        "headless": false,
        "disk_size": 10140,
        "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
        "guest_os_type": "Ubuntu",
        "http_directory": "http",
        "iso_checksum": "a5c02e25a8f6ab335269adb1a6c176edff075093b90854439b4a90fce9b31f28",
        "iso_checksum_type": "sha256",
        "iso_url": "http://releases.ubuntu.com/trusty/{{ user `PACKER_BOX_NAME` }}.iso",
        "shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now",
        "ssh_password": "vagrant",
        "ssh_port": 22,
        "ssh_username": "vagrant",
        "ssh_wait_timeout": "10000s",
        "vm_name": "{{ user `PACKER_BOX_NAME` }}",
        "vboxmanage": [
          ["modifyvm", "{{.Name}}", "--memory", "1024"],
          ["modifyvm", "{{.Name}}", "--cpus", "2"]
        ],
        "virtualbox_version_file": ".vbox_version"
      },
      {
        "type": "amazon-ebs",
        "access_key": "{{ user `AWS_ACCESS_KEY_ID` }}",
        "secret_key": "{{ user `AWS_SECRET_ACCESS_KEY` }}",
        "region": "us-east-1",
        "source_ami": "ami-10b68a78",
        "instance_type": "t1.micro",
        "ssh_username": "ubuntu",
        "ami_name": "packer-app-server {{timestamp}}"
      },
      {
        "type": "googlecompute",
        "account_file": "account.json",
        "project_id": "devops-intro-project",
        "source_image": "ubuntu-1404-trusty-v20150316",
        "zone": "us-central1-a",
        "image_name": "application-ubuntu-1404-{{timestamp}}",
        "machine_type": "n1-standard-1",
        "ssh_username": "ubuntu"
      }
  ],

  "provisioners": [
    {
      "type": "shell",
      "execute_command": "echo 'vagrant'|{{.Vars}} sudo -S -E bash '{{.Path}}'",
      "scripts": [
        "scripts/update.sh"
      ]
    },
    {
    "type": "shell",
    "only": ["virtualbox-iso"],
    "execute_command": "echo 'vagrant'|sudo -S -E bash '{{.Path}}'",
    "scripts": [
        "scripts/virtualbox.sh",
        "scripts/vagrant.sh"
      ]
    },
    {
      "type": "shell",
      "execute_command": "echo 'vagrant'|sudo -S -E bash '{{.Path}}'",
      "scripts": [
        "scripts/application.sh",
        "scripts/cleanup.sh"
      ]
    }
  ],
  "post-processors": [
    [
      {
        "type": "vagrant",
        "except": ["googlecompute"],
        "compression_level": "9",
        "output": "{{.Provider}}/{{ user `PACKER_BOX_NAME` }}-appserver_{{.Provider}}.box"
      }
    ]
  ]
}

1 个答案:

答案 0 :(得分:0)

不确定您的主机操作系统,但您可以打开PACKER_LOG变量以查看有关错误的更多信息

Windows上的CMD:设置PACKER_LOG = 1 Bash或任何其他shell:export PACKER_LOG = 1

然后运行打包器构建...并分享日志的要点。

阿尔瓦罗