Use salt to install software under Windows

Source: Internet
Author: User
Tags scalar yaml parser using git saltstack


Can crossing Web documents, my English is poor, translation is not good, understanding

In 2015.8.0 and later, the Windows software repository cache was compiled on the salt minion

The saltstack Windows Software Resource Library provides a package manager and software repository similar to those provided by Yum and apt on Linux. The repository can use the Setup program on a remote Windows system to install the software.

In many senses, the operation are similar to that of the other package managers salt is aware of:

The and pkg.installed similar states work on Windows.

The and pkg.install similar module functions work on Windows.

and Yum's difference

1, the repository metadata (SLS file) is hosted by salt or git.

2, the package can be downloaded from the Salt repository, the Git repository, or the HTTP (s) or FTP URL.

3, dependencies between packages need to be managed manually.

Previous requirements were: Gitpython 0.3 or later, or Pygit2 0.20.3 with Libgit 0.20.0 or later installed on salt mast. The Windows package definition is downloaded and updated using Git.

By default, salt does not distribute the SLS files that are used to install Windows packages, and you need to run the following command to initialize the repository on your salt host:

Salt-run Winrepo.update_git_repos

Run on each of the pkg.refresh_db your Windows minions to synchronize the package repository.

Salt-g ' os : Windows ' pkg.refresh_db

Next, you can install Windows software

Show Installed PackagesSalt-g ' OS: Windows ' pkg.list_pkgs

You can use the Salt pkg module to query the available version of the package Salt winminion pkg.list_available Firefox

Install the latest version of Firefox salt winminion pkg.install ' Firefox '

Uninstalling Windows software

Uninstalling software using the PKG module

Salt winminion pkg.remove firefoxsalt winminion pkg.purge Firefox


pkg.purgeJust executes on pkg.remove Windows. At some-the-installer-to- pkg.purge remove all configs and settings-software packages that s Upport that option

Repository Location

Salt maintains a repository of SLS files to install a large number of Windows packages:

    • 2015.8.0 and later versions:HTTPS://
    • Previous version:

By default, these repositories are mirrored to /srv/salt/win/repo-ng and the /srv/salt/win/repo .

by setting winrepo_dir_ng and the winrepo_dir option, You can change this location in the master configuration file .

Maintaining WINDOWS REPO definitions in GIT repositories

Can be hosted in one or more git repositories, and the default repository is hosted on GitHub by Saltstack. These include software definition files for various open source software projects. These software definition files are .sls files. There are two default repositories: salt-winrepo and salt-winrepo-ng . salt-winrepo A software definition file that contains an older version (2015.8.0). salt-winrepo-ng is for newer minions (2015.8.0 and newer).

Each software definition file contains all the information required by the salt to install the software, including the HTTP or FTP location of the installer files, required commands for silent installation, etc., anyone is welcome to send a pull request to this repo to ad D new Package definitions. The repos can browsed Here:salt-winrepo Salt-winrepo-ng


The newer software definition files is run through the salt ' s parser which allows for the use of Jinja.

by modifying or extending winrepo_remotes and the winrepo_remotes_ng option, Configure the master server to search for those git repositories defined by the package .


winrepo_remoteswas called in win_gitrepos Salt versions earlier than 2015.8.0

package definition by running winrepo.update_git_repos runner is removed from the online repository . This command runs on the primary server:

  Salt-run Winrepo.update_git_repos

This would pull down the software definition files for older minions ( salt-winrepo ) and new Minions ( salt-winrepo-ng ). They is stored in the file_roots under win/repo/salt-winrepo and win/repo-ng/salt-winrepo-ng respectively.


If you have custom software definition files that are not maintained in the repository, you should store these files in win/repo older versions and win/repo-ng Newer versions of the version. The reason for this is that the content win/repo/salt-winrepo and cleanup are done win/repo-ng/salt-winrepo-ng on each run winrepo.update_git_repos .

Additionally, when you run winrepo.genrepo and the pkg.refresh_db all of the content below win/repo and the win/repo-ng , including all subdirectories, for creating msgpack files

The next step (if you had older minions) is to create the Msgpack file for the repo ( winrepo.p ). This is do by running the winrepo.genrepo runner. This was also run on the master:

Salt-run Winrepo.genrepo


If you have a 2015.8.0 and newer minions, you do not longer need to run on the salt-run winrepo.genrepo master.

Finally, you need to run the pkg.refresh_db command to flush the Minion database . This also runs on master:

Salt ' * ' pkg.refresh_db

on older minions (older than 2015.8.0) This would copy the WINREPO.P file down to the minion. On newer minions (2015.8.0 and newer) this would copy all the software definition files (. sls) to the Minion and then Create the Msgpack file (WINREPO.P ) locally. The reason this was done locally was because the jinja needs to be parsed using the Minion ' s grains.

each time you modify a software definition file on the master server, either by running , modify an existing file, or create your own file, you need to refresh the database on Minion, for older minions, which means running and then salt-run winrepo.genrepo salt ‘*‘ pkg.refresh_db . For newer minions (2015.8.0 and newer) it is just salt ‘*‘ pkg.refresh_db .


if this winrepo.genrepo or pkg.refresh_db failed, then in a software definition file, this could be a jinja problem. This causes the operation to stop. You need to repair the syntax to successfully create the Msgpack file.

to disable one of the repo, set it [] a blank list in the primary configuration . For example, to disable winrepo_remotes Setting the following in the master configuration file:winrepo_remotes:[]

Create a package definition SLS file

The package definition file is a Yaml file that contains all the information you need to install a software using a salt. It defines information about the package, including the version, the full name, the installer and the flags required to uninstall the program, whether to use the Windows Task Scheduler to install the package, and how to find the installation package.

Look at this example of Firefox:

Firefox:' 17.0.1 ':Installer:' Salt://win/repo/firefox/english/firefox Setup 17.0.1.exe 'Full_name:Mozilla Firefox 17.0.1 (x86 en-US)Locale:en_USReboot:FalseInstall_flags:'-ms 'Uninstaller:'%programfiles (x86)%/mozilla Firefox/uninstall/helper.exe 'Uninstall_flags:'/S '' 16.0.2 ':Installer:' Salt://win/repo/firefox/english/firefox Setup 16.0.2.exe 'Full_name:Mozilla Firefox 16.0.2 (x86 en-US)Locale:en_USReboot:FalseInstall_flags:'-ms 'Uninstaller:'%programfiles (x86)%/mozilla Firefox/uninstall/helper.exe 'Uninstall_flags:'/S '' 15.0.1 ':Installer:' Salt://win/repo/firefox/english/firefox Setup 15.0.1.exe ' full_name: mozilla Firefox 15.0.1 (x86 en-US) locale: en_US reboot: False install_flags:  '-ms ' uninstaller:  '%programfiles (x86)%/Mozilla< Span Class= "NV" > firefox/uninstall/helper.exe ' uninstall_ Flags:  '/s '         

Each software definition file begins with the software's package name. as shown in the example abovefirefox . the next line indents two spaces and contains the version you want to define. as shown in the example above, a software definition file can define multiple versions of the same software. the lines after this version are indented two spaces and contain all the information that is required to install the package.


package name and full_name all other packages in the software repository must be unique.

The version line is the version of the package that you want to install. Use it when you need to install a specific version of a software.


The version must be enclosed in quotation marks, or the YAML parser will delete the trailing 0.

Use salt to install software under Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.