This is a minimal reproduction of an issue I am seeing when provisioning hosts with Saltstack and Packer. More specifically, running salt-call --local saltutil.sync_all in a script uploaded by packer does not function as expected (no files/modules are sync'd).
Note that saltutil.sync_all works fine on the new host when run manually from the shell directly.
- Download and install packer to your
$PATHfrom https://www.packer.io/downloads.html - Create a new directory and copy the
setup_salt.sh,base-host.json, andconfig.jsonfiles from this gist to that new directory - This build uses AWS, so you'll need an existing VPC and subnet. Grab the VPC and Subnet ID, and put those in
config.json. - Update
config.jsonwith an Access Key ID and Secret Key you can use. - Run
packer build -var-file=config.json build.json - If everything works, you'd see the
foobar.pyscript sync withsaltutil.sync_all, and you'll see salt run thefoobar.testmodule withhello testprinted to stdout. If it fails, you won't seefoobar.pysync'd, and you'll seeModule 'foobar' is not availableas output.