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

    Messages:
    9
    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:

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

    dch Bit poster

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

    Code:
    # ensure provisioners like parallels tools have already finished
    echo "waiting for apt lock to finish"
    sleep 10
    while [ -f /var/lib/dpkg/lock ]
      do
      printf "."
      sleep 5
    done
    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

    Messages:
    9
  5. dch

    dch Bit poster

    Messages:
    9
    and here's the packer logs. From a timing perspective the "Uploading Parallels" happens within 2-3 seconds of script/unstable.sh 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.

    Code:
    ==> 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: 10.0.0.2
    ==> 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/unstable.sh
      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 https://gist.github.com/dch/15e43742edd835258da2 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:
    https://github.com/dch/prls/pull/1
     
  7. dch

    dch Bit poster

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

    dch Bit poster

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

    Code:
    From c27fd56e967c867caf173149094e04057df75dfc Mon Sep 17 00:00:00 2001
    From: Mikhail Zholobov <@gmail.com>
    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": "http://cdimage.debian.org/debian-cd/8.3.0/amd64/iso-cd/debian-8.3.0-amd64-netinst.iso",
    "parallels_tools_flavor": "lin",
    + "parallels_tools_guest_path": "/var/tmp/prl-tools-lin.iso",
    "prlctl": [
    [
    "set",
    @@ -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": [
    "script/unstable.sh",
    "script/base.sh",
    
    From bd63516721b727039cb1bbc38dd0c80a79273ffb Mon Sep 17 00:00:00 2001
    From: Mikhail Zholobov <@gmail.com>
    Date: Tue, 2 Feb 2016 23:47:09 +0200
    Subject: [PATCH 2/2] vmtools.sh: Install Parallels Tools
    
    ---
    script/vmtools.sh | 9 +++++++++
    1 file changed, 9 insertions(+)
    
    diff --git a/script/vmtools.sh b/script/vmtools.sh
    index d7fe23a..58627c9 100755
    --- a/script/vmtools.sh
    +++ b/script/vmtools.sh
    @@ -23,4 +23,13 @@ elif [ $PACKER_BUILDER_TYPE == 'virtualbox-iso' ]; then
    sh /mnt/VBoxLinuxAdditions.run --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
    fi
    
     

Share This Page