saltstack / saltstack/salt

[BUG] Salt-Stack minions behind proxy and AD Authentication

Open
#66,272 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Salt-Stack minions behind proxy and AD Authentication
I have Salt-Master version 3006.7 on Ubuntu 22, and minions running on Windows behind a Squid Proxy using NTLMv2 Authentication integrated with Active Directory. The minios are running version 3006.6.
I can't install packages using "pkg.install", or apply states, becouse proxy auth failed.

Setup

State File created into /srv/salt/thefolder/minion_test.sls

minion-suc:
  proxy.managed:
    - name: 10.100.101.240
    - user: usrsalt
    - password: Th3.Passw0rd.Of.Salt
    - port: 8080
    - bypass_domains:
        - localhost
        - 127.0.0.1
  pkg.installed:
    - pkgs:
      - vlc

Salt master version 3006.7 running in VMware ESXi 7.
Salt minion version 3006.6 running on fisical machine "Windows 10"

Minion behind SQUID Proxy usin NTLM auth module with Active Directory

Steps to Reproduce the behavior
In the SALT-MASTER execute the command:

salt 'theminion' state.apply thefolder.minion_test

Output:
This is the output text obtained

 The minion function caused an exception: Traceback (most recent call last):
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\urllib3\connectionpool.py", line 712, in urlopen
        self._prepare_proxy(conn)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\urllib3\connectionpool.py", line 1012, in _prepare_proxy
        conn.connect()
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\urllib3\connection.py", line 374, in connect
        self._tunnel()
      File "C:\Program Files\Salt Project\Salt\lib\http\client.py", line 925, in _tunnel
        raise OSError(f"Tunnel connection failed: {code} {message.strip()}")
    OSError: Tunnel connection failed: 407 Proxy Authentication Required

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\requests\adapters.py", line 486, in send
        resp = conn.urlopen(
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\urllib3\connectionpool.py", line 799, in urlopen
        retries = retries.increment(
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\urllib3\util\retry.py", line 592, in increment
        raise MaxRetryError(_pool, url, error or ResponseError(cause))
    urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='get.videolan.org', port=443): Max retries exceeded with url: /vlc/3.0.18/win64/vlc-3.0.18-win64.exe (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\minion.py", line 1993, in _thread_return
        return_data = minion_instance._execute_job_function(
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\minion.py", line 1952, in _execute_job_function
        return_data = self.executors[fname](opts, data, func, args, kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 159, in __call__
        ret = self.loader.run(run_func, *args, **kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1245, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1260, in _run_as
        return _func_or_method(*args, **kwargs)
      File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\executors\direct_call.py", line 10, in execute
        return func(*args, **kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 159, in __call__
        ret = self.loader.run(run_func, *args, **kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1245, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1260, in _run_as
        return _func_or_method(*args, **kwargs)
      File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\modules\win_pkg.py", line 1708, in install
        cached_pkg = __salt__["cp.cache_file"](
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 159, in __call__
        ret = self.loader.run(run_func, *args, **kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1245, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\loader\lazy.py", line 1260, in _run_as
        return _func_or_method(*args, **kwargs)
      File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\modules\cp.py", line 552, in cache_file
        result = client.cache_file(
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\fileclient.py", line 192, in cache_file
        return self.get_url(
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\fileclient.py", line 792, in get_url
        query = salt.utils.http.query(
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\salt\utils\http.py", line 423, in query
        result = sess.request(method, url, params=params, data=data, **req_kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\requests\sessions.py", line 589, in request
        resp = self.send(prep, **send_kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\requests\sessions.py", line 703, in send
        r = adapter.send(request, **kwargs)
      File "C:\Program Files\Salt Project\Salt\lib\site-packages\requests\adapters.py", line 513, in send
        raise ProxyError(e, request=request)
    requests.exceptions.ProxyError: HTTPSConnectionPool(host='get.videolan.org', port=443): Max retries exceeded with url: /vlc/3.0.18/win64/vlc-3.0.18-win64.exe (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))

Expected behavior
The minion must download and install the application "vlc".

Versions Report

salt --versions-report from the SALT-MASTER Salt Version: Salt: 3006.7

Python Version:
Python: 3.10.13 (main, Feb 19 2024, 03:31:20) [GCC 11.2.0]

Dependency Versions:
cffi: 1.14.6
cherrypy: unknown
dateutil: 2.8.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.3
libgit2: Not Installed
looseversion: 1.0.2
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.2
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 22.0
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.4.8
PyYAML: 6.0.1
PyZMQ: 23.2.0
relenv: 0.15.1
smmap: Not Installed
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4

System Versions:
dist: ubuntu 22.04.3 jammy
locale: utf-8
machine: x86_64
release: 5.15.0-89-generic
system: Linux
version: Ubuntu 22.04.3 jammy

salt-call.exe --versions-report from the minion Salt Version: Salt: 3006.6

Python Version:
Python: 3.10.13 (heads/main:5600dd9, Nov 15 2023, 04:42:06) [MSC v.1937 64 bit (AMD64)]

Dependency Versions:
cffi: 1.14.6
cherrypy: 18.6.1
dateutil: 2.8.1
docker-py: Not Installed
gitdb: 4.0.7
gitpython: Not Installed
Jinja2: 3.1.3
libgit2: Not Installed
looseversion: 1.0.2
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.2
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 22.0
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.19.1
pygit2: Not Installed
python-gnupg: 0.4.8
PyYAML: 6.0.1
PyZMQ: 25.0.2
relenv: 0.14.2
smmap: 4.0.0
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4

System Versions:
dist:
locale: cp1252
machine: AMD64
release: 10
system: Windows
version: 10 10.0.19045 SP0 Multiprocessor Free

Additional context
I tryed several scenaries:

  • Using salt.states.proxy (https://docs.saltproject.io/en/latest/ref/states/all/salt.states.proxy.html)
  • Using state file with "proxy.managed", name, port, user, password configured.
  • Using state file with "proxy:", "environ.setenv", "HTTP_PROXY".
  • Setting proxy parameters into "C:\ProgramData\Salt Project\Salt\conf\minion" including "proxy_username" and "proxy_ password"
  • Configuring "Log On" with AD user in the windows service "salt-minion"

I also try to setup username using several syntaxs: "domain\username", "domain\\username" and "username" without domain portion.

Perhaps the "tornado" component, or python http client is not supporting NTLM???

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with salt/utils/http.py and salt/fileclient.py, following the request path from salt/modules/win_pkg.py during the reported state.apply command. Reproduce the Windows minion download through Squid with NTLM authentication and inspect the 407 failure. Done means pkg.install can download and install VLC through the configured authenticated proxy.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.