3

I am working on a template located here. In the provision section I have:

"provisioners": [
  {
    "type": "shell-local",
    "command": "wget http://distfiles.gentoo.org/releases/amd64/autobuilds/{{user `stage3-date`}}/stage3-amd64-{{user `stage3-date`}}.tar.bz2"
  },
  {
    "type": "file",
    "source": "stage3-amd64-{{user `stage3-date`}}.tar.bz2",
    "destination": "/root"
  },
  {
    "destination": "/root",
    "source": "scripts/",
    "type": "file"
  },
  {
    "environment_vars": [
      "STAGE3={{user `stage3-date`}}"
    ],
    "type": "shell",
    "inline": ["cd /root", "chmod u+x provision.sh", "./provision.sh"]
  }
]

My goal is to download the stage3 when needed, perform an md5 check, and move it to /root on the vm but that is not happening. (For those not familiar with gentoo this is the actually install files that need to be unpacked to the chrooted hd). This is the output.

john@g1 gentoo-packer $ packer build -debug gentoo64.json 
Debug mode enabled. Builds will not be parallelized.
virtualbox-iso output will be in this color.

1 error(s) occurred:

* Bad source 'stage3-amd64-20150924.tar.bz2': stat stage3-amd64-20150924.tar.bz2: no such file or directory

It looks like packer is trying to run the "file" provisioners before "shell-local". Since packer is not going in the order of the provisioners array, is there any way to enforce order when the provisioners are run?

Note 1:

I'm pretty sure line 58 in the file provisioner is causing all of my issues. The files are checked when packer starts rather than when the provisioner runs. Since the file hasn't been downloaded yet it fails.

Community
  • 1
  • 1
John Mercier
  • 1,637
  • 3
  • 20
  • 44

1 Answers1

1

This isn't an answer as such, more potential guidance

From doc it says

For each of the definitions, Packer will run the provisioner for each of the configured builds. The provisioners will be run in the order they are defined within the template.

are you sure the file is available ? can you try the shell-local provisioner alone and make sure the file gets download

You can also try to force the destination of file with -P option on wget to make sure it is saved in valid directory and then re-read form there.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139