hashicorp / packer-plugin-salt

This Packer provisioner has been archived due to it no longer being maintained. Users are encouraged to use the shell or shell-local provisioner to run the provisioning tools made available by this plugin. If interested in maintaining this plugin please reach out to us at packer@hashicorp.com.
https://www.packer.io/docs/provisioners/salt-masterless
Mozilla Public License 2.0
2 stars 5 forks source link

Add flag in salt-masterless provisioner to allow custom grains syncing #22

Open hc-github-team-packer opened 2 years ago

hc-github-team-packer commented 2 years ago

This issue was originally opened by @ldormoy in https://github.com/hashicorp/packer/issues/6961 and has been migrated to this repository. The original issue description is below.


I use Saltstack with the https://github.com/saltstack/salt-contrib/blob/master/grains/ec2_info.py script to generate ec2-related grains.

When using salt-masterless, the command to use to generate these custom grains would be something like:

sudo salt-call --local saltutil.sync_grains
[...]
[INFO    ] Syncing grains for environment 'base'
[INFO    ] Loading cache from salt://_grains, for base)
[INFO    ] Caching directory '_grains/' for environment 'base'
[INFO    ] Fetching file from saltenv 'base', ** done ** '_grains/ec2_info.py'
[INFO    ] Copying '/var/cache/salt/minion/files/base/_grains/ec2_info.py' to '/var/cache/salt/minion/extmods/grains/ec2_info.py'
local:
    - grains.ec2_info

This has to be done BEFORE calling state.highstate, as otherwise packer fails with the following error:

[ERROR   ] Rendering exception occurred: Jinja variable 'dict object' has no attribute 'ec2'

Problem: Saltstack is bootstrapped by the salt-masterless provisioner, so there is no way to simply manually run the sync command. It would involve using a file provisioner to sync the salt codebase, then a shell provisioner to manually bootstrap and configure saltstack and then run the salt-call sync command.

Solution: add a flag to allow grains syncing directly in the salt-masterless provisioner.

nywilken commented 2 years ago

With the archival of this repository all open issues will be marked as read-only. If you wish to further discuss this plugin or any of its open issues we invite you to open a discussion on the Packer community forum.

More details on the plugin archiving process for this provisioner can be found on the Plans to Archive Unmaintained Packer Provisioner Plugins blog post.