Ansible provisioning failing
singhkgautam opened this issue · comments
Awesome packer utility. Saved me lot of time and effort.
Getting following error while building packer box:
Build 'virtualbox-iso' errored: Error uploading main playbook: Error uploading ansible/main.yml: scp: /tmp/packer-provisioner-ansible-local/58dddd8a-18f2-0b20-6803-c516a46e93d9: No such file or directory
Do I need to install Ansible on host machine?
That looks like a different error :-/
I do have Ansible installed on my Mac, but I think that Packer builds things inside the VM it sets up... see hashicorp/packer#3782 as well. And also, make sure you're running the latest version of Packer.
Thanks for quick response. Yes I am using the latest version of packer 0.12.3.
In the logs I am seeing following:
virtualbox-iso: Creating directory: \tmp\packer-provisioner-ansible-local\58ddea47-9080-3f89-00b8-4439cfc40030
So seems like script is creating the directory but with backslash (\) instead of (/). Is this the problem? If yes, how to fix it?
I just rebuilt the image again tonight, and it seems to be working okay for me (I forgot to check for what directory it created though).
Are you doing this on a Mac or Windows?
Hey,
I have the same issue in windows using packer v1.0.
[1;31mBuild 'virtualbox' errored: Error uploading main playbook: Error uploading C:\Users\Someone\development\spider\packer/ansible/base.yml: scp: /tmp/packer-provisioner-ansible-local/59113803-e514-6a24-6d13-de12e584c28f: No such file or directory�[0m
==> Some builds didn't complete successfully and had errors:
--> virtualbox: Error uploading main playbook: Error uploading C:\Users\Someone\development\spider\packer/ansible/base.yml: scp: /tmp/packer-provisioner-ansible-local/59113803-e514-6a24-6d13-de12e584c28f: No such file or directory
@nathanblogs - In that case, it looks like it's not finding the directory where it's trying to copy the file... maybe there's an issue with VirtualBox synced folders on Windows with Packer or something?
I was running into a similar issue, and it seems a workaround is to use the "staging_directory" option in the ansible-local packer provisioner (https://www.packer.io/docs/provisioners/ansible-local.html#staging_directory).
I used something like this:
{
"provisioners": [
...
{
"type": "shell",
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/create-ansible-staging-directory.sh"
},
{
"type": "ansible-local",
"playbook_file": "ansible/main.yml",
"staging_directory": "/path/to/staging/directory"
},
...
I haven't had any issues with this for the past year, with many builds on a few different Macs, so I'm going to close this out; if you run into the same issue as @daveschoutens, see the workaround he posted above.
I would defer any similar issues to the Packer issue queue, as it sounds like it could be an upstream issue with the way the box is generated and the file is copied in.