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.

    - pkgs:
      - npp
      - chocolatey

- 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 }}:
- source: salt://helloworld/helloworld.txt

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


Homework <–palvelinten-hallinta-ict4tn022-3004-ti-ja-3002-to–loppukevat-2018-5p<
Windows salt help

Leave a Replay