Skip to content

[BUG] Unable to add users on junos via napalm #62170

Closed as not planned
Closed as not planned

Description

@orachimary

Description
Then applying netusers state as described there https://docs.saltproject.io/en/latest/ref/states/all/salt.states.netusers.html got following error:

  File "/usr/lib/python3.6/site-packages/salt/state.py", line 2180, in call
    *cdata["args"], **cdata["kwargs"]
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/contextvars/__init__.py", line 38, in run
    return callable(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1249, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/states/netusers.py", line 327, in managed
    expected_users = _expand_users(users, defaults)
  File "/usr/lib/python3.6/site-packages/salt/states/netusers.py", line 74, in _expand_users
    expected_users.update(device_users)
AttributeError: 'NoneType' object has no attribute 'update'

Also if i try set users thru salt.modules.napalm_users.set_users got next error

sudo salt 'router1' users.set_users '{"micrea":{}}'
router1:
    ----------
    comment:
        Local file source set_users does not exist
    out:
        None
    result:
        False
ERROR: Minions returned with non-zero exit code

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)

Juniper EX-3400

Please be as specific as possible and give set-up details.

  • on-prem machine
  • VM (Virtualbox, KVM, etc. please specify)
  • VM running on a cloud service, please be explicit and add details
  • container (Kubernetes, Docker, containerd, etc. please specify)
  • or a combination, please be explicit
  • jails if it is FreeBSD

Steps to Reproduce the behavior
users.sls

junos-users:
    netusers.managed:
         - users:
            admin:
                level: 15
                password: $1$knmhgPPv$g8745biu4rb.Zf.IT.F/U1
                sshkeys: []
            restricted:
                level: 1
                password: $1$j34j5k4b$4d5SVjTiz1l.Zf.IT.F/K7

/srv/pillar/juniper.sls

proxy:
  proxytype: napalm
  driver: junos
  ip: xx.xx.xx.xx
  username: user
  password: passwd

Expected behavior
Add/remove users from juniper config

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.)
Salt Version:
          Salt: 3004.1
 
Dependency Versions:
          cffi: 1.11.5
      cherrypy: unknown
      dateutil: 2.6.1
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.10.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.14
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.8 (default, Apr 12 2022, 06:55:39)
  python-gnupg: Not Installed
        PyYAML: 3.12
         PyZMQ: 19.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: rocky 8.5 Green Obsidian
        locale: UTF-8
       machine: x86_64
       release: 4.18.0-348.7.1.el8_5.x86_64
        system: Linux
       version: Rocky Linux 8.5 Green Obsidian

Additional context
Add any other context about the problem here.

Activity

  1. added
    bug
    on Jun 15, 2022
  2. welcome commented on Jun 15, 2022

    @welcome

    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 [email protected]. We’re glad you’ve joined our community and look forward to doing awesome things with you!

  3. orachimary commented on Jun 15, 2022

    @orachimary
    Author

    if replace common_users parameter in /usr/lib/python3.6/site-packages/salt/states/netusers.py

    def _expand_users(device_users, common_users):
    
      # common_users is None
        """Creates a longer list of accepted users on the device."""
        common_users = {}
        expected_users = copy.deepcopy(common_users)
        expected_users.update(device_users)
    
        return expected_users
    

    from None to empty dict

    ----------
              ID: junos-users
        Function: netusers.managed
          Result: False
         Comment: Cannot configure new users: Local file source set_users does not existCannot remove users: Local file source delete_users does not exist
         Started: 09:55:18.028058
        Duration: 751.266 ms
         Changes:   
                  ----------
                  added:
                      ----------
                      admin:
                          ----------
                          level:
                              15
                          password:
                              <passwordHash>
                          sshkeys:
                      restricted:
                          ----------
                          level:
                              1
                          password:
                              <passwordHash>
                  removed:
                      ----------
                      another_user:
                          ----------
                          level:
                              15
                          password:
                              <passwordHash>
                          sshkeys:
                      root:
                          ----------
                          level:
                              20
                          password:
                              <passwordHash>
                          sshkeys:
                  updated:
                      ----------
    
    Summary for router1
    ------------
    Succeeded: 0 (changed=1)
    Failed:    1
    ------------
    Total states run:     1
    Total run time: 751.266 ms
    ERROR: Minions returned with non-zero exit code
    
  4. Slime90 commented on Jun 7, 2023

    @Slime90

    @mirceaulinic can you take a look at this? It has been plaguing me on Arista as well for over a year, with the exact same behavior on all revisions up to the 3005.1 which I am currently testing.

  5. added
    severity-low
    on Oct 16, 2026
  6. dwoz commented on Oct 16, 2026

    @dwoz
    Contributor

    Thanks for the original report. This issue has been open for more than three years without recent activity and carries a severity label below severity-high. As part of a backlog cleanup, we're closing older low- and medium-severity issues so triage can focus on reports against currently supported releases.

    Closing isn't a judgement that the problem wasn't real — only that the codebase has moved through several releases since this was filed, and much of the surrounding code has changed.

    If you — or anyone else — can still reproduce this on the 3008.x LTS release, please leave a comment with a reproduction and a maintainer will reopen. The original reporter can also reopen directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Proxy-Minionbugneeds-triageseverity-lowstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions