salt: Salt cannot find git on Windows, so "git.latest" is broken

Description of Issue/Question

The Windows “Local System account” runs using a very limited PATH. The default installation of git is not on that path. The default installation of Salt runs on the “Local System account”. The Salt “git” execution module does not have a contingency method of locating git.exe. Therefore, git.latest does not work on a stock Windows system.

Setup

The problem can be easily demonstrated using a virtual Salt network, as found in salt-bevy. This can be done on any Linux, Windows or MacOS workstation with enough RAM to hold the VMs. You need never actually log in to the Windows VM. Should you choose to do so, the password for user vagrant is “vagrant”.

Steps to Reproduce Issue

  • Clone salt-bevy into a directory of your choice.
  • cd <that directory>
  • Type ./join-bevy (or just join-bevy on Windows) The script will create /etc/salt-bevy_my_settings.conf and /srv/pillar/01_bevy_settings.sls on your workstation. (On the C: drive if you are running Windows)
  • answer “Yes” to the query Will the Bevy Master be a VM guest of this machine? (Default values should suffice for most other selections. You will need to supply a Linux user name, but a Windows user name is not needed. No Salt Minion is needed on your workstation.)
  • Start the Salt Master. vagrant up bevymaster
  • Start a Windows machine. vagrant up win16 Windows is very slow starting and the installation scripts may time out, so you may need to repeat the vagrant up win16 command, or do a vagrant provision win16 once or twice. You know it’s done when you see the output from a highstate. The highstate will install git.
  • Log in to the Salt master. vagrant ssh bevymaster
  • Send commands to the minion to show the problem
vernoncole@bevymaster:~$ sudo salt win16 cmd.run "git --version" runas=vagrant password=vagrant
win16:
    git version 2.17.0.windows.1
vernoncole@bevymaster:~$ sudo salt win16 cmd.run "git --version"
win16:
    'git' is not recognized as an internal or external command,
    operable program or batch file.
ERROR: Minions returned with non-zero exit code
vernoncole@bevymaster:~$ sudo salt win16 cmd.run "where git" runas=vagrant password=vagrant
win16:
    C:\Program Files\Git\cmd\git.exe
vernoncole@bevymaster:~$ sudo salt win16 cmd.run "where git"
win16:
    INFO: Could not find files for the given pattern(s).
ERROR: Minions returned with non-zero exit code
vernoncole@bevymaster:~$ sudo salt win16 state.apply developer.install_salt_source
win16:
----------
          ID: C:\Users\kf7xm\projects/salt
    Function: git.latest
        Name: https://github.com/saltstack/salt.git
      Result: False
     Comment: State 'git.latest' was not found in SLS 'developer.install_salt_source'
              Reason: 'git' __virtual__ returned False

The state in question is in salt-bevy/bevy_srv/salt/developer/install_salt_source.sls

{{ projects_root }}/salt:
  git.latest:
    - name: https://github.com/saltstack/salt.git
    - target: {{ projects_root }}/salt
    - rev: develop
    - branch: develop

The installation of git was performed in salt-bevy/bevy_srv/salt/common.sls with the master having been set up by salt-bevy/bevy_srv/salt/bevy_master/local_windows_repository.sls

Versions Report

vernoncole@bevymaster:~$ sudo salt \* test.version
bevymaster:
    2018.3.0
win16:
    2018.3.0
vernoncole@bevymaster:~$ sudo salt win16 test.versions_report
win16:
    Salt Version:
               Salt: 2018.3.0

    Dependency Versions:
               cffi: 1.10.0
           cherrypy: 10.2.1
           dateutil: 2.6.1
          docker-py: Not Installed
              gitdb: 2.0.3
          gitpython: Not Installed
              ioflo: Not Installed
             Jinja2: 2.10
            libgit2: 0.27.1
            libnacl: 1.6.1
           M2Crypto: Not Installed
               Mako: 1.0.7
       msgpack-pure: Not Installed
     msgpack-python: 0.4.8
       mysql-python: Not Installed
          pycparser: 2.18
           pycrypto: 2.6.1
       pycryptodome: Not Installed
             pygit2: 0.27.1
             Python: 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)]
       python-gnupg: 0.4.1
             PyYAML: 3.12
              PyZMQ: 16.0.3
               RAET: Not Installed
              smmap: 2.0.3
            timelib: 0.2.4
            Tornado: 4.5.2
                ZMQ: 4.1.6

    System Versions:
               dist:
             locale: cp1252
            machine: AMD64
            release: 2016Server
             system: Windows
            version: 2016Server 10.0.14393  Multiprocessor Free

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

This is still an issue. One resolution could be that Salt tries to run Git from the default install directory in Program Files rather than just relying on it being in the system path.