saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.16k stars 5.48k forks source link

windows: "Reason: 'ssh_known_hosts.present' is not available" but execution modules used by the state (ssh.check_known_host & ssh.set_known_host) succeed #55366

Open muddman opened 4 years ago

muddman commented 4 years ago

Description of Issue

salt.states.ssh_known_hosts.present is not available on Windows 10 and Windows Server 2019, however, ssh.check_known_host and ssh.set_known_host, which are used by the state on lines 139 and 163, both work in windows.

C:\salt\salt-call.bat state.highstate --retcode-passthrough --local --log-level=info

Stdout from the command:

local:
----------
          ID: github.com
    Function: ssh_known_hosts.present
      Result: False
     Comment: State 'ssh_known_hosts.present' was not found in SLS 'known_host'
              Reason: 'ssh_known_hosts.present' is not available.
     Changes:
----------
          ID: ssh.check_known_host.github.com
    Function: module.run
      Result: True
     Comment: ssh.check_known_host: add
     Started: 13:18:09.370000
    Duration: 32.0 ms
     Changes:
              ----------
              ssh.check_known_host:
                  add
----------
          ID: ssh.set_known_host.github.com
    Function: module.run
      Result: True
     Comment: ssh.set_known_host: Success
     Started: 13:18:09.402000
    Duration: 5233.0 ms
     Changes:
              ----------
              ssh.set_known_host:
                  ----------
                  new:
                      |_
                        ----------
                        enc:
                            ssh-rsa
                        fingerprint:
                            16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
                        hostname:
                            github.com
                        key:
                            AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
                  old:
                      None
                  status:
                      updated
----------
          ID: ssh.recheck_known_host.github.com
    Function: module.run
      Result: True
     Comment: ssh.check_known_host: exists
     Started: 13:18:14.635000
    Duration: 31.0 ms
     Changes:
              ----------
              ssh.check_known_host:
                  exists
----------
          ID: ssh.reset_known_host.github.com
    Function: module.run
      Result: True
     Comment: ssh.set_known_host: Success
     Started: 13:18:14.666000
    Duration: 16.0 ms
     Changes:
              ----------
              ssh.set_known_host:
                  ----------
                  keys:
                      - AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
                  status:
                      exists

Summary for local
------------
Succeeded: 4 (changed=4)
Failed:    1
------------
Total states run:     5
Total run time:   5.312 s

Setup

known_hosts.sls:

# STATE MODULE FAILS IN WINDOWS AND WORKS IN LINUX
github.com:
  ssh_known_hosts:
    - present
    - user: vagrant
    - fingerprint: 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
    - fingerprint_hash_type: md5
    - hash_known_hosts: False

# EXECUTION MODULES WORK IN BOTH WINDOWS and LINUX
ssh.check_known_host.github.com:
  module.run:
    - ssh.check_known_host:
      - user: vagrant
      - hostname: github.com
      - fingerprint: 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
      - fingerprint_hash_type: md5

ssh.set_known_host.github.com:
  module.run:
    - ssh.set_known_host:
      - user: vagrant
      - hostname: github.com
      - fingerprint: 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
      - fingerprint_hash_type: md5
      - hash_known_hosts: False

ssh.recheck_known_host.github.com:
  module.run:
    - ssh.check_known_host:
      - user: vagrant
      - hostname: github.com
      - fingerprint: 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
      - fingerprint_hash_type: md5

ssh.reset_known_host.github.com:
  module.run:
    - ssh.set_known_host:
      - user: vagrant
      - hostname: github.com
      - fingerprint: 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
      - fingerprint_hash_type: md5
      - hash_known_hosts: False

Steps to Reproduce Issue

  1. Remove existing known_host file: C:\Users\vagrant\.ssh\known_hosts
  2. Run highstate: vagrant provision or C:\salt\salt-call.bat state.highstate --retcode-passthrough --local --log-level=trace

The full trace level logs only show the following:

[DEBUG   ] Could not LazyLoad ssh_known_hosts.present: 'ssh_known_hosts.present' is not available.
[INFO    ] Running state [github.com] at time 14:57:26.369000
[DEBUG   ] Could not LazyLoad ssh_known_hosts.present: 'ssh_known_hosts.present' is not available.
[ERROR   ] State 'ssh_known_hosts.present' was not found in SLS 'known_host'
Reason: 'ssh_known_hosts.present' is not available.

Versions Report

Salt Version:
           Salt: 2019.2.2

Dependency Versions:
           cffi: 1.12.2
       cherrypy: 17.4.1
       dateutil: 2.8.0
      docker-py: Not Installed
          gitdb: 2.0.6
      gitpython: 2.1.10
          ioflo: Not Installed
         Jinja2: 2.10.1
        libgit2: Not Installed
        libnacl: 1.6.1
       M2Crypto: Not Installed
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: 2.19
       pycrypto: Not Installed
   pycryptodome: 3.8.1
         pygit2: Not Installed
         Python: 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)]
   python-gnupg: 0.4.4
         PyYAML: 3.13
          PyZMQ: 18.0.1
           RAET: Not Installed
          smmap: 2.0.5
        timelib: 0.2.4
        Tornado: 4.5.3
            ZMQ: 4.3.1

System Versions:
           dist:
         locale: cp1252
        machine: AMD64
        release: 10
         system: Windows
        version: 10 10.0.18362  Multiprocessor Free
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] commented 4 years ago

Thank you for updating this issue. It is no longer marked as stale.