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

State ssh_auth.absent does not work with source file #63434

Open
deyanx opened this issue Jan 8, 2023 · 3 comments
Open

State ssh_auth.absent does not work with source file #63434

deyanx opened this issue Jan 8, 2023 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage State-Module

Comments

@deyanx
Copy link

deyanx commented Jan 8, 2023

Description of Issue

State ssh_auth.absent does not work with source file

SLS file example

xxxxxxx:
  ssh_auth.absent:
    - user: xxxxxxx
    - source: salt://sudo/files/xxxxxxx.rsa.pub-remove

If I do ssh_auth.absent state for the same key with -name and -enc parameters, without -source file it works properly. Same source file was used to add this key before with ssh_auth.present function which confirms that file is in correct authorized_keys format.

Reported error

          ID: xxxxxxx
    Function: ssh_auth.absent
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python3.6/site-packages/salt/state.py", line 2277, 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 1228, 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 1243, in _run_as
                  return _func_or_method(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/loader/lazy.py", line 1276, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python3.6/site-packages/salt/states/ssh_auth.py", line 464, in absent
                  key = key.rstrip().split("\n")
              AttributeError: 'bool' object has no attribute 'rstrip'
     Started: 14:21:05.560949
    Duration: 17.931 ms
     Changes:

Versions Report

Salt Version:
          Salt: 3005.1

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      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: Not Installed
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.8 (default, Nov  9 2022, 09:57:34)
  python-gnupg: Not Installed
        PyYAML: 3.12
         PyZMQ: 20.0.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: almalinux 8.7 Stone Smilodon
        locale: UTF-8
       machine: x86_64
       release: 4.18.0-348.20.1.el8_5.x86_64
        system: Linux
       version: AlmaLinux 8.7 Stone Smilodon
@OrangeDog OrangeDog added Bug broken, incorrect, or confusing behavior needs-triage labels Jan 9, 2023
@OrangeDog
Copy link
Contributor

IMO the source argument should just be removed, as it makes no sense to provide it to absent.
It looks like someone just copy-pasted the arguments from present.

@deyanx
Copy link
Author

deyanx commented Jan 9, 2023

No, I believe it should also work with source file, as in my example, but it have a bug.
It completely make sense to me. If key can be added from file we should be able to also remove it with same source file.

@OrangeDog
Copy link
Contributor

I guess yes, if the target file has more keys, and the source file lists only the ones to remove.

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 needs-triage State-Module
Projects
None yet
Development

No branches or pull requests

2 participants