Need help --- Provisioning with shell doesn't work ( virtualbox-iso )

293 views
Skip to first unread message

Roy Yu

unread,
Sep 18, 2014, 7:53:54 PM9/18/14
to packe...@googlegroups.com
Hi all,

I'm a newbie in packer, I have setup the template json file and the preseed.cfg file, and everything seems fine when I build it.

But until this point
==> virtualbox-iso: Waiting 10s for boot...
==> virtualbox-iso: Typing the boot command...
==> virtualbox-iso: Waiting for SSH to become available...
==> virtualbox-iso: Connected to SSH!
==> virtualbox-iso: Uploading VirtualBox version info (4.3.16)
==> virtualbox-iso: Uploading VirtualBox guest additions ISO...
==> virtualbox-iso: Provisioning with shell script: /var/folders/qg/brspvqw91v198n7x68g4bh6mxxg36v/T/packer-shell203194274

what I saw on the screen is the virtualbox image in the ssh prompt, is that expected??  Looks like it hangs there, so I just manually type the user name and password to login.  But when I login, none of my software defined in shell provisioner are installed.  

Am I missing a step here?

Thanks

Roy Yu

unread,
Sep 19, 2014, 11:57:39 AM9/19/14
to packe...@googlegroups.com
Some more detail, I do a packer debug and I have attached my screenshot of what looks like and what message output at that time.

The symtom is the vbox screen just halt there  ( I see the pointer is blinking though )

And the message is as below

2014/09/19 08:52:35 packer-builder-virtualbox-iso: 2014/09/19 08:52:35 [DEBUG] Uploading script.sh: perms=C0644 size=332
2014/09/19 08:52:35 packer-builder-virtualbox-iso: 2014/09/19 08:52:35 SCP session complete, closing stdin pipe.
2014/09/19 08:52:35 packer-builder-virtualbox-iso: 2014/09/19 08:52:35 Waiting for SSH session to complete.
2014/09/19 08:52:35 packer-builder-virtualbox-iso: 2014/09/19 08:52:35 scp stderr (length 26): Sink: C0644 332 script.sh
2014/09/19 08:52:35 packer-builder-virtualbox-iso: 2014/09/19 08:52:35 opening new ssh session
2014/09/19 08:52:35 packer-builder-virtualbox-iso: 2014/09/19 08:52:35 starting remote command: chmod 0777 /tmp/script.sh
2014/09/19 08:52:35 packer-builder-virtualbox-iso: 2014/09/19 08:52:35 remote command exited with '0': chmod 0777 /tmp/script.sh
2014/09/19 08:52:35 packer-builder-virtualbox-iso: 2014/09/19 08:52:35 [INFO] RPC endpoint: Communicator ended with: 0
2014/09/19 08:52:35 [INFO] RPC client: Communicator ended with: 0
2014/09/19 08:52:35 [INFO] RPC endpoint: Communicator ended with: 0
2014/09/19 08:52:35 packer-command-build: 2014/09/19 08:52:35 [INFO] RPC client: Communicator ended with: 0
2014/09/19 08:52:35 packer-command-build: 2014/09/19 08:52:35 [INFO] RPC endpoint: Communicator ended with: 0
2014/09/19 08:52:35 [INFO] RPC client: Communicator ended with: 0
2014/09/19 08:52:35 [INFO] RPC endpoint: Communicator ended with: 0
2014/09/19 08:52:35 packer-provisioner-shell: 2014/09/19 08:52:35 [INFO] RPC client: Communicator ended with: 0
2014/09/19 08:52:35 packer-builder-virtualbox-iso: 2014/09/19 08:52:35 opening new ssh session
2014/09/19 08:52:35 packer-builder-virtualbox-iso: 2014/09/19 08:52:35 starting remote command: chmod +x /tmp/script.sh; PACKER_BUILD_NAME=virtualbox-iso PACKER_BUILDER_TYPE=virtualbox-iso /tmp/script.sh
Screen Shot 2014-09-19 at 8.53.45 AM.png

Roy Yu

unread,
Sep 19, 2014, 12:21:17 PM9/19/14
to packe...@googlegroups.com
Btw, this is my provisioner section

 46     "provisioners": [{
 47         "type": "shell",
 48         "inline": [
 49             "sleep 30",
 50             "sudo apt-get install -y imagemagick",
 51             "sudo apt-get install -y python-software-properties", 
 52             "sudo apt-add-repository -y ppa:chris-lea/node.js",
 53             "sudo apt-get update -y -qq > /dev/null",
 54             "sudo apt-get upgrade -y -qq > /dev/null",
 55             "sudo apt-get install -y build-essential",
 56             "sudo apt-get install -y -q curl wget vim",
 57             "sudo apt-get install -y nodejs",
 58             "sudo apt-get install -y git-core"
 59         ]
 60     }]

Am I missing stuff here?

Thanks

Alvaro Miranda Aguilera

unread,
Sep 20, 2014, 9:22:11 PM9/20/14
to packe...@googlegroups.com
can you share the full packer json template ?

your project template should have a shutdown command with user/pass to use and then a post processor task

--
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roy Yu

unread,
Sep 22, 2014, 11:50:55 PM9/22/14
to packe...@googlegroups.com
Hi Alvaro,

Here is my json template, let me know if I'm missing a step, thanks.   

{
    "variables": {
        "ssh_name": "developer",
        "ssh_pass": "developer",
        "hostname": "dev-box-test-001"
    },

    "builders": [{
        "type": "virtualbox-iso",
        "guest_os_type": "Ubuntu_64",

        "vboxmanage": [
            ["modifyvm", "{{.Name}}", "--vram", "32"]
        ],

        "disk_size" : 10000,

        "iso_checksum": "e83adb9af4ec0a039e6a5c6e145a34de",
        "iso_checksum_type": "md5",

        "http_directory" : "http",
        "http_port_min" : 9001,
        "http_port_max" : 9001,

        "ssh_username": "{{user `ssh_name`}}",
        "ssh_password": "{{user `ssh_pass`}}",
        "ssh_wait_timeout": "20m",

        "shutdown_command": "echo {{user `ssh_pass`}} | sudo -S shutdown -P now",

        "boot_command" : [
            "<esc><esc><enter><wait>",
            "/install/vmlinuz noapic ",
            "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
            "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
            "hostname={{user `hostname`}} ",
            "fb=false debconf/frontend=noninteractive <wait>",
            "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
            "keyboard-configuration/variant=USA console-setup/ask_detect=false ",
            "initrd=/install/initrd.gz -- <enter><wait>"
        ],
        "boot_wait": "4s"
    }],

    "provisioners": [
        {
            "scripts": [
                "scripts/setup.sh"
            ],
            "type": "shell"
        }
     ]
}
Reply all
Reply to author
Forward
0 new messages