While the Salt winrepo certainly fills a missing package management void for Windows systems, it is certainly challenging to work with. This documentation is intended to help use the winrepo with the salt testbed, specifically for development of winrepo package definitions.
The ideal development setup (achieved via the instructions below) allows for easily and quickly iterating on local definition files to work through syntax and logic errors before pushing to the git repository for the winrepo containing the definition.
The following steps will walk you through the initial setup of:
- local winrepo clone with definition SLS files stored on the saltmaster;
- winrepo shared to the winminion via the
primarymaster
's Salt filesystem.
There are a few important points to get this working properly:
!! CAUTION !! DO NOT RUN winrepo.update_git_repos!! This will potentially delete and overwrite your local winrepo!
-
These instructions assume you're using Salt version at or later than 2015.8.0 and will need some slight modifications to support earlier versions. Please see the SaltStack documentation for details on what modifications you might need to make.
-
These instructions assume you'll clone the winrepo you're testing (or to which you're adding a new or modifying an existing package definition) to a
salt/windows/win/repo-ng
directory from the root of this project, but you can choose a different directory; just make sure to modify theprimarymaster
'sfile_roots:base
andwinrepo_dir_ng
configurations appropriately.
- Clone your winrepo into the
salt/windows/win/repo-ng
directory of this testbed; - Update your master configuration based on the following example:
fileserver_backend:
- roots
file_roots:
base:
#
# This is necessary so that the saltmaster will
# serve /vagrant/salt/windows/win/repo-ng on the
# Salt FS as salt://win/repo-ng, which is where
# the winminion's default configuration will look
# for it.
#
- /vagrant/salt/windows/
#
# Unless you need packages from the official Saltstack winrepos,
# set yourself up to only use your local winrepo for easier
# development.
#
winrepo_remotes: []
winrepo_remotes_ng: []
#
# This is the magic, and mildly dangerous -- so long as you don't
# run `update_git_repos` your local changes won't be removed.
#
winrepo_dir_ng: /vagrant/salt/windows/win/repo-ng
Make sure to restart the salt-master service by running systemctl restart salt-master
from the primarymaster
- From the
primarymaster
: Update the winminion's package db:
salt winminion pkg.refresh_db
If everything went successfully, you should see some successes or failures. Failures likely mean you need to fix syntax errors in your package definitions, but are a good sign since they mean the Windows minion is able to pull down your local winrepo. You're in business either way, so nice work!
- Hack on your package definition within the winrepo;
- From the
primarymaster
, run thepkg.refresh_db
module to propogate your changes to the Windows minion and have it evaluate your definition's jinja:
salt winminion pkg.refresh_db
- If the above step had errors, try to correct them, re-running
salt winminion pkg.refresh_db
from theprimarymaster
as you go to check once you're changes are valid. - Once your
pkg.refresh_db
commands return success, confirm your package definition renders as expected:
salt winminion pkg.get_repo_data
- When ready, you can test out installation and removal of your package:
# test out installing your package from the winrepo
salt winminion pkg.install {{my_pkg}} {{pkg_version}}
# test out uninstalling your package from the winrepo
salt winminion pkg.remove {{my_pkg}}
# etc...
- When ready, commit and push your changes to your winrepo's git repository.
Once you've pushed your changes, it's a good idea to destroy your local test bed VMs via vagrant destroy
, re-create them, and test against your winrepo's git repository.
- update your
priamrymaster
's configuration to:- add your winrepo git repository's url to the
winrepo_remotes_ng
list; and - comment out the
winrepo_dir_ng
configuration to keep from overwriting your local winrepo clone;
- add your winrepo git repository's url to the
- restart the salt-master:
systemctl restart salt-master
; - have Salt clone your git repo:
salt-run winrepo.update_git_repos
- update the winminion's pkg db:
salt winminion pkg.refresh_db
- verify the packages can be managed as expected.