how to ensure Parallels tools installation is completed

Discussion in 'Parallels Provider for Vagrant' started by dch, Feb 2, 2016.

  1. dch

    dch Bit poster

    I'm using Parallels tools auto installation as part of a vagrant & packer build to generate an image for the rest of the team to use.

    The parallels tool installer conflicts with our custom provisioning script and one of them always fails, depending on who gets to run apt first.

    How can I ensure that parallels installer has completed before ours starts? For example is there a specific file I can check for that is at the end of the installation? Ideally I could force the installer to run as a synchronous task and not async.

    FWIW I have this in vagrant:

      config.vm.provider "parallels" do |prl| = FQDN
        prl.use_linked_clone = true
        prl.update_guest_tools = true
  2. dch

    dch Bit poster

    For the moment, I've added the very unsophisticated:

    # ensure provisioners like parallels tools have already finished
    echo "waiting for apt lock to finish"
    sleep 10
    while [ -f /var/lib/dpkg/lock ]
      printf "."
      sleep 5
    echo "apt lock gone, proceeding."
  3. Hm, it sounds weird. In both of Packer and Vagrant, the step of Parallels Tools update/installation is a separated action, which runs before the provisioning step, so they should not be running simultaneously.
    So, let's clarify some details about your case:
    Does it happen during "packer build", or "vagrant up", or both?
    How does your provisioning scripts are triggered? Is it an appropriate step of "packer build", or "provisioner" section in your Vagrantfile, or some custom solution running automatically on the VM boot?
    Last edited by a moderator: Feb 2, 2016
  4. dch

    dch Bit poster

  5. dch

    dch Bit poster

    and here's the packer logs. From a timing perspective the "Uploading Parallels" happens within 2-3 seconds of script/ starting. In fact I need these steps to be the other way around, and also with a way to wait for parallels install to finish before the other starts to run.

    ==> parallels-iso: Starting HTTP server on port 8081
    ==> parallels-iso: Creating virtual machine...
    ==> parallels-iso: Applying default settings...
    ==> parallels-iso: Creating hard drive...
    ==> parallels-iso: Setting the boot order...
    ==> parallels-iso: Attaching ISO to the default CD/DVD ROM device...
    ==> parallels-iso: Executing custom prlctl commands...
      parallels-iso: Executing: prlctl set debian-sid --memsize 384
      parallels-iso: Executing: prlctl set debian-sid --cpus 1
    ==> parallels-iso: Starting the virtual machine...
    ==> parallels-iso: Waiting 10s for boot...
    ==> parallels-iso: Host IP for the Parallels machine:
    ==> parallels-iso: Typing the boot command...
    ==> parallels-iso: Waiting for SSH to become available...
    ==> parallels-iso: Connected to SSH!
    ==> parallels-iso: Uploading Parallels version info (11.1.2)
    ==> parallels-iso: Uploading Parallels Tools for 'lin' to path: 'prl-tools-lin.iso'
    ==> parallels-iso: Uploading ansible/templates => /tmp
    ==> parallels-iso: Provisioning with shell script: script/
      parallels-iso: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
      parallels-iso: E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
    ==> parallels-iso: Unregistering virtual machine...
    ==> parallels-iso: Deleting output directory...
    Build 'parallels-iso' errored: Script exited with non-zero exit status: 100
    ==> Some builds didn't complete successfully and had errors:
    --> parallels-iso: Script exited with non-zero exit status: 100
    ==> Builds finished but no artifacts were created.
    full logs available from `PACKER_LOG=info packer build -only=parallels-iso -force debian-sid.json |& tee /ramdisk/packer.log`
    Last edited: Feb 2, 2016
  6. In your case there are no concurrent access to the dpkg. Moreover - Parallels Tools process hasn't been started.
    The error is exactly about file permission. The reason is that packer runs provisioning scripts under regular user ("vagrant"), not by root.
    I've send a pull-request to your repo just to show the way how this error could be fixed:
  7. dch

    dch Bit poster

    perfect - I've applied this to the main repo and things are looking excellent. <3 sending a PR :)
  8. dch

    dch Bit poster

    As I'll remove the test repo, here's the patch for others to read in future:

    From c27fd56e967c867caf173149094e04057df75dfc Mon Sep 17 00:00:00 2001
    From: Mikhail Zholobov <>
    Date: Tue, 2 Feb 2016 23:45:49 +0200
    Subject: [PATCH 1/2] Fix script provisioner for parallels-iso builder
    debian-sid.json | 10 ++--------
    1 file changed, 2 insertions(+), 8 deletions(-)
    diff --git a/debian-sid.json b/debian-sid.json
    index 66f1036..3062507 100755
    --- a/debian-sid.json
    +++ b/debian-sid.json
    @@ -92,6 +92,7 @@
    "iso_checksum_type": "sha256",
    "iso_url": "",
    "parallels_tools_flavor": "lin",
    + "parallels_tools_guest_path": "/var/tmp/prl-tools-lin.iso",
    "prlctl": [
    @@ -122,14 +123,7 @@
    "destination": "/tmp"
    - "override": {
    - "virtualbox-iso": {
    - "execute_command": "echo 'vagrant'|{{.Vars}} sudo -E -S bash '{{.Path}}'"
    - },
    - "vmware-iso": {
    - "execute_command": "echo 'vagrant'|{{.Vars}} sudo -E -S bash '{{.Path}}'"
    - }
    - },
    + "execute_command": "echo 'vagrant'|{{.Vars}} sudo -E -S bash '{{.Path}}'",
    "scripts": [
    From bd63516721b727039cb1bbc38dd0c80a79273ffb Mon Sep 17 00:00:00 2001
    From: Mikhail Zholobov <>
    Date: Tue, 2 Feb 2016 23:47:09 +0200
    Subject: [PATCH 2/2] Install Parallels Tools
    script/ | 9 +++++++++
    1 file changed, 9 insertions(+)
    diff --git a/script/ b/script/
    index d7fe23a..58627c9 100755
    --- a/script/
    +++ b/script/
    @@ -23,4 +23,13 @@ elif [ $PACKER_BUILDER_TYPE == 'virtualbox-iso' ]; then
    sh /mnt/ --nox11
    umount /mnt
    rm /var/tmp/VBoxGuestAdditions_${VBOX_VERSION}.iso
    +elif [ $PACKER_BUILDER_TYPE == 'parallels-iso' ]; then
    + echo "Installing Parallels Tools"
    + mkdir -p /tmp/parallels
    + mount -o loop /var/tmp/prl-tools-lin.iso /tmp/parallels
    + /tmp/parallels/install --install-unattended-with-deps
    + umount /tmp/parallels
    + rm -rf /tmp/parallels
    + rm -f /var/tmp/prl-tools-lin.iso

Share This Page