18 February 2016

Salt: Control a Windows Minion

Install the Windows Client

or from the file list:
https://repo.saltstack.com/windows/

NB: minion config is here by default:
C:\salt\conf\minion

On the Server

Create the 'top' file:
  1. Create a 'top.sls' file:
    vi /srv/salt/top.sls
  2. Add in the declarations the environment:
    base:
      '*':
        - global
        - salt.minion
      'os:Windows':
        - match: grain
        - windows
This tells salt that for the environment called base all minions will have state files /srv/salt/global.sls and /srv/salt/salt/minion.sls applied to them.

All systems that match the 'grain' of Windows all Minions will have the state file /srv/salt/windows.sls or /srv/salt/windows/init.sls applied to them.

Package Manager

See also the official documentation 'Windows Package Manager'
  1. Initialize the repository on your Salt master:
    salt-run winrepo.update_git_repos
  2. Run pkg.refresh_db on each of your Windows minions to synchronize the package repository:
    salt -G 'os:windows' pkg.refresh_db
  3. Show Installed packages:
    salt -G 'os:windows' pkg.list_pkgs

Use Chocolatey in a State

vi /srv/salt/windows.sls
chocolatey:
  module.run:
    - name: chocolatey.bootstrap

firefox:
  module.run:
    - unless: # command to check if firefox is already installed
    - name: chocolatey.install
    - m_name: firefox
    - require:
      - module: chocolatey

No comments:

Post a Comment