I have a packer configuration that provisions using chef-solo in AWS EC2. This works well. I have introduced berkshelf to manage 3rd party cookbooks and this isn't working as well.
I am working in a chef repo that has locally developed cookbooks, roles, data bags, etc. By introducing berks, I want to keep the cookbooks
directory clean, and put 3rd party cookbooks into vendor/cookbooks
(which is git excluded so keeps repos clean / minimizes chances of other devs adding / pushing berks-managed cookbooks in to vcs). So I added a shell-local provisioner before a chef-solo provisioner, which runs berks vendor vendor/cookbooks
and updated the chef-solo provisioner with cookbook_paths ["cookbooks","vendor/cookbooks"]
. My idea is that the shell-local would run before the chef-solo and both cookbook paths would be available.
However, when I run packer build, it fails fast trying to resolve the cookbook paths before the AWS builder even starts building, failing with reference to the non-existent vendor/cookbooks directory. Here is the packer provisioners segment:
"provisioners" : [
{
"type": "shell-local",
"command": "bundle install && bundle exec berks vendor vendor/cookbooks"
},
{
"type" : "chef-solo",
"cookbook_paths" : ["cookbooks","vendor/cookbooks"],
"environments_path" : "environments",
"roles_path" : "roles",
"run_list" : ["role[somerole]"]
}
],
When I run this, it fails:
amazon-ebs output will be in this color.
1 error(s) occurred:
* Bad cookbook path 'vendor/cookbooks': stat vendor/cookbooks: no such file or directory
Is there a mechanism in packer that will run the shell-local first before resolving the chef-solo provisioner? I'd like to avoid running berks in the builder (i.e. I want the cookbooks resolved by the host running packer), and would ideally like to have this run solely in packer as apposed to wrapper scripts that run berks first. I have resolved this for now by vendoring into cookbooks
, but would like to avoid this route if possible too.