Git repository management for the Windows Software Repository has changed
in version 2015.8.0, and several master/minion config parameters have been
renamed to make their naming more consistent with each other.
pygit2/GitPython Support for Maintaining Git Repos
The winrepo.update_git_repos
runner (and the corresponding remote execution function
for standalone minions) now makes use
of the same underlying code used by the Git Fileserver Backend and Git External Pillar
to
maintain and update its local clones of git repositories. If a compatible
version of either pygit2 (0.20.3 and later) or GitPython (0.3.0 or later) is
installed, then Salt will use it instead of the old method (which invokes the
git.latest
state).
To minimize potential issues, it is a good idea to remove any winrepo git
repositories that were checked out by the old (pre-2015.8.0) winrepo code when
upgrading the master to 2015.8.0 or later, and run
winrepo.update_git_repos
to
clone them anew after the master is started.
Additional added features include the ability to access authenticated git
repositories (NOTE: pygit2 only), and to set per-remote config settings.
An example of this would be the following:
winrepo_remotes:
- https://github.com/saltstack/salt-winrepo.git
- git@github.com:myuser/myrepo.git:
- pubkey: /path/to/key.pub
- privkey: /path/to/key
- passphrase: myaw3s0m3pa$$phr4$3
- https://github.com/myuser/privaterepo.git:
- user: mygithubuser
- password: CorrectHorseBatteryStaple
Note
Per-remote configuration settings work in the same fashion as they do in
gitfs, with global parameters being overridden by their per-remote
counterparts (for instance, setting winrepo_passphrase
would
set a global passphrase for winrepo that would apply to all SSH-based
remotes, unless overridden by a passphrase
per-remote parameter).
See here for more a more in-depth
explanation of how per-remote configuration works in gitfs, the same
principles apply to winrepo.
There are a couple other changes in how Salt manages git repos using
pygit2/GitPython. First of all, a clean
argument has been added to the
winrepo.update_git_repos
runner, which (if set to True
) will tell the runner to dispose of
directories under the winrepo_dir
which are not explicitly
configured. This prevents the need to manually remove these directories when a
repo is removed from the config file. To clean these old directories, just pass
clean=True
, like so:
salt-run winrepo.update_git_repos clean=True
However, if a mix of git and non-git Windows Repo definition files are being
used, then this should not be used, as it will remove the directories
containing non-git definitions.
The other major change is that collisions between repo names are now detected,
and the winrepo.update_git_repos
runner will not proceed if any are
detected. Consider the following configuration:
winrepo_remotes:
- https://foo.com/bar/baz.git
- https://mydomain.tld/baz.git
- https://github.com/foobar/baz
The winrepo.update_git_repos
runner will refuse to update repos here, as all three of these repos would be
checked out to the same directory. To work around this, a per-remote parameter
called name
can be used to resolve these conflicts:
winrepo_remotes:
- https://foo.com/bar/baz.git
- https://mydomain.tld/baz.git:
- name: baz_junior
- https://github.com/foobar/baz:
- name: baz_the_third