Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] salt-ssh file.managed NameError: name '__context__' is not defined #60199

Open
kebre001 opened this issue May 17, 2021 · 1 comment
Open
Labels
Bug broken, incorrect, or confusing behavior Loader Salt-SSH severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
Milestone

Comments

@kebre001
Copy link

kebre001 commented May 17, 2021

Description
Im doing a simple test with salt-ssh to push ntp configuration to a FreeBSD(13) system.
My state that has a file.managed section to update /etc/ntp.conf fails with below error.

File "/var/tmp/.f_59bdb0_salt/pyall/salt/modules/file.py", line 4272, in source_list
                  if contextkey in __context__:
              NameError: name '__context__' is not defined

Full error / state run is at the end.
I have not done any more testing since I don't understand this error at all.
(Same issue for other file.managed)

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info).
state file:

/etc/ntp.conf:
  file.managed:
    - name: /etc/ntp.conf
    - source: salt://templates/ntp/ntp_freebsd.j2
    - template: jinja

ntpd:
  service.running:
    - enable: True

file template:

{% set ntp = pillar["ntp"] -%}
{{ salt['slsutil.banner']() }}
# Don't forget to enable ntpd in /etc/rc.conf with:
# ntpd_enable="YES"

tos minclock 3 maxclock 6

restrict default limited kod nomodify notrap noquery nopeer
restrict source  limited kod nomodify notrap noquery

restrict 127.0.0.1
restrict ::1

{% for server in ntp["internal_servers"] -%}
server {{ server }}
{% endfor %}

leapfile "/var/db/ntpd.leap-seconds.list"

Steps to Reproduce the behavior
(Include debug logs if possible and relevant)
salt-ssh pbf-f.swe state.apply states.pbf.ntp
(Tested with salt-sproxy also)

Expected behavior
A clear and concise description of what you expected to happen.
I expected Salt to render my template and apply it.

Screenshots
If applicable, add screenshots to help explain your problem.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

Since its salt-ssh the minion gets a thin 3003 client?

Salt Version:
          Salt: 3003

Dependency Versions:
          cffi: 1.14.5
      cherrypy: unknown
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: 0.6.4
     gitpython: 1.0.1
        Jinja2: 2.11.3
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.20
      pycrypto: Not Installed
  pycryptodome: 3.10.1
        pygit2: Not Installed
        Python: 3.6.8 (default, Nov 16 2020, 16:55:22)
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 22.0.3
         smmap: 0.9.0
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: centos 7 Core
        locale: UTF-8
       machine: x86_64
       release: 4.4.196-1.el7.elrepo.x86_64
        system: Linux
       version: CentOS Linux 7 Core

Additional context
Add any other context about the problem here.
The full error:

pbf-f.swe:
----------
          ID: /etc/ntp.conf
    Function: file.managed
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/var/tmp/.f_59bdb0_salt/pyall/salt/state.py", line 2172, in call
                  *cdata["args"], **cdata["kwargs"]
                File "/var/tmp/.f_59bdb0_salt/pyall/salt/loader.py", line 1235, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/var/tmp/.f_59bdb0_salt/pyall/salt/loader.py", line 2268, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/var/tmp/.f_59bdb0_salt/py3/contextvars/__init__.py", line 38, in run
                  return callable(*args, **kwargs)
                File "/var/tmp/.f_59bdb0_salt/pyall/salt/loader.py", line 2283, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/var/tmp/.f_59bdb0_salt/pyall/salt/loader.py", line 2316, in wrapper
                  return f(*args, **kwargs)
                File "/var/tmp/.f_59bdb0_salt/pyall/salt/states/file.py", line 3054, in managed
                  source, source_hash = __salt__["file.source_list"](source, source_hash, __env__)
                File "/var/tmp/.f_59bdb0_salt/pyall/salt/loader.py", line 1235, in __call__
                  return self.loader.run(run_func, *args, **kwargs)
                File "/var/tmp/.f_59bdb0_salt/pyall/salt/loader.py", line 2268, in run
                  return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
                File "/var/tmp/.f_59bdb0_salt/py3/contextvars/__init__.py", line 38, in run
                  return callable(*args, **kwargs)
                File "/var/tmp/.f_59bdb0_salt/pyall/salt/loader.py", line 2283, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/var/tmp/.f_59bdb0_salt/pyall/salt/modules/file.py", line 4272, in source_list
                  if contextkey in __context__:
              NameError: name '__context__' is not defined
     Started: 12:18:31.880344
    Duration: 62.684 ms
     Changes:
----------
          ID: ntpd
    Function: service.running
      Result: True
     Comment: The service ntpd is already running
     Started: 12:18:31.952440
    Duration: 86.088 ms
     Changes:

Summary for pbf-f.swe
------------
Succeeded: 1
Failed:    1
------------
Total states run:     2
Total run time: 148.772 ms
@kebre001 kebre001 added Bug broken, incorrect, or confusing behavior needs-triage labels May 17, 2021
@welcome
Copy link

welcome bot commented May 17, 2021

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

@OrangeDog OrangeDog added Salt-SSH severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around Loader and removed needs-triage labels May 17, 2021
@OrangeDog OrangeDog added this to the Approved milestone May 17, 2021
@sagetherage sagetherage added this to Severity-Medium in Salt-SSH May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Loader Salt-SSH severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
Salt-SSH
  
Severity-Medium
Development

No branches or pull requests

2 participants