Windows salt minion

You can use salt to control windos mashines too, but only as minion, salt master is only for linux. You just install windows minion. Add your salt masters IP and give the minion ID. Then you need to accept the new minions inside master with

sudo salt-key -A

You can see your salt masters IP with “hostname -I” command

On master you need to add support for windows with

 sudo salt-run winrepo.update_git_repos
 sudo salt -G 'os:windows' pkg.refresh_db

Installing programs

Now you can install programs on windows with salt. This code will install notepad++, chocolatey and using chocolatey it will install autohotkey.

windows_apps:
  pkg.installed:
    - pkgs:
      - npp
      - chocolatey

choco:
  chocolatey.installed:
- name: autohotkey 

Coding with Jinja 2

This code will check if the minion is linux or windows and will put the helloworld.txt in differend directorys depending on it.

{% if "Windows" == grains ["os"] %}
{%  set hellofile = "C:\helloworld.txt" %}
{% else %}
{%  set hellofile = "/tmp/helloworld.txt" %} 
{% endif %}

{{ hellofile }}:
  file.managed:
- source: salt://helloworld/helloworld.txt

In this example the helloworld file resides in the same directory as the helloworld init.sls on the master.

Sources:

Homework <http://terokarvinen.com/2018/aikataulu–palvelinten-hallinta-ict4tn022-3004-ti-ja-3002-to–loppukevat-2018-5p<
Windows salt helphttp://terokarvinen.com/2018/control-windows-with-salt

Leave a Replay