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.modules.aptpkg does not handle parsing a cdrom repo line #62474

Closed
s0undt3ch opened this issue Aug 16, 2022 · 6 comments · Fixed by #62475
Closed

[BUG] salt.modules.aptpkg does not handle parsing a cdrom repo line #62474

s0undt3ch opened this issue Aug 16, 2022 · 6 comments · Fixed by #62475
Assignees
Labels
Bug broken, incorrect, or confusing behavior Sulfur v3006.0 release code name and version

Comments

@s0undt3ch
Copy link
Collaborator

Description
See title.

An example line is:

deb cdrom:[Debian GNU/Linux 11.4.0 _Bullseye_ - Official amd64 NETINST 20220709-10:31]/ stable main
Traceback (most recent call last):
  File "/vagrant/salt/state.py", line 2276, in call
    ret = self.states[cdata["full"]](
  File "/vagrant/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/vagrant/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/vagrant/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/vagrant/salt/loader/lazy.py", line 1276, in wrapper
    return f(*args, **kwargs)
  File "/vagrant/salt/states/pkgrepo.py", line 439, in managed
    pre = __salt__["pkg.get_repo"](repo=repo, **kwargs)
  File "/vagrant/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/vagrant/salt/loader/lazy.py", line 1228, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/vagrant/salt/loader/lazy.py", line 1243, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/vagrant/salt/modules/aptpkg.py", line 1972, in get_repo
    repos = list_repos()
  File "/vagrant/salt/modules/aptpkg.py", line 1918, in list_repos
    signedby = _get_opts(line=source.line)["signedby"].get("value", "")
  File "/vagrant/salt/modules/aptpkg.py", line 1743, in _get_opts
    ret[other_opt]["value"] = opt.split("=", 1)[1]
IndexError: list index out of range
@s0undt3ch s0undt3ch added Bug broken, incorrect, or confusing behavior needs-triage labels Aug 16, 2022
@s0undt3ch s0undt3ch self-assigned this Aug 16, 2022
@s0undt3ch s0undt3ch added this to the Sulphur v3006.0 milestone Aug 18, 2022
@s0undt3ch s0undt3ch added the Sulfur v3006.0 release code name and version label Aug 18, 2022
s0undt3ch added a commit to s0undt3ch/salt that referenced this issue Aug 18, 2022
@ldav1s
Copy link
Contributor

ldav1s commented Aug 27, 2022

This also happens for me on 3005 with this source line on Ubuntu 20.04 /etc/apt/sources.list:

# deb cdrom:[Kubuntu 20.04.3 LTS _Focal Fossa_ - Release amd64 (20210819.1)]/ focal main multiverse restricted universe

which under apt processing of this file means it's commented out.

$ salt-minion -V
Salt Version:
          Salt: 3005
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.7.3
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.10.1
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: 2.6.1
  pycryptodome: 3.6.1
        pygit2: Not Installed
        Python: 3.8.10 (default, Jun 22 2022, 20:18:18)
  python-gnupg: 0.4.5
        PyYAML: 5.3.1
         PyZMQ: 18.1.1
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.2
 
System Versions:
          dist: ubuntu 20.04 focal
        locale: utf-8
       machine: x86_64
       release: 5.11.0-46-generic
        system: Linux
       version: Ubuntu 20.04 focal

@ldav1s
Copy link
Contributor

ldav1s commented Aug 27, 2022

Don't see how #62475 accounts for this case where the line is disabled (in terms of SourceEntry) going through the list_repos path of calling _get_opts.

EDIT AFTER ACTUALLY TRYING A PIECE OF IT:

I tried just changing one regex in _get_opts like here, and it seemed to work out to fix this case.

Ch3LL pushed a commit to Ch3LL/salt that referenced this issue Aug 31, 2022
garethgreenaway pushed a commit that referenced this issue Sep 1, 2022
Fixes #62474

Signed-off-by: Pedro Algarvio <[email protected]>
@tbennett6421
Copy link

Greetings, I was impacted by this as well.
This could be useful for anyone else impacted:

I used the following state to apply a workaround.

# bugfix commented deb cdrom in /etc/apt/sources.list
# @link: https://github.com/saltstack/salt/issues/62474
deb-cdrom-bugfix:
  file.replace:
    - name: /etc/apt/sources.list
    - pattern: '^# deb cdrom:.*'
    - repl: ''
    - show_changes: true
    - ignore_if_missing: true

@dstensnes
Copy link

dstensnes commented Sep 9, 2022

So, this "signedby" problem in an essential package completely breaks server provisioning, which effectively means that none of the other salt modules matter. Waiting maybe a month for next release is out of the question for us, as is correcting the problem on a bunch of servers manually. We will spend this time converting to ansible instead. We have had it with saltstack.

@CrackerJackMack
Copy link

@tbennett6421 's fix works for me and is quite annoying to have to include this into our bootstrap process and highstates.

@rjc
Copy link
Contributor

rjc commented Sep 21, 2022

Greetings, I was impacted by this as well. This could be useful for anyone else impacted:

I used the following state to apply a workaround.

# bugfix commented deb cdrom in /etc/apt/sources.list
# @link: https://github.com/saltstack/salt/issues/62474
deb-cdrom-bugfix:
  file.replace:
    - name: /etc/apt/sources.list
    - pattern: '^# deb cdrom:.*'
    - repl: ''
    - show_changes: true
    - ignore_if_missing: true

This will only work for those who have the deb cdrom:[...] line commented out, though. I doubt many people use optical media for package installation but you never know - best to catch them all :^)

s0undt3ch added a commit to s0undt3ch/salt that referenced this issue Sep 29, 2022
garethgreenaway added a commit that referenced this issue Oct 7, 2022
* Fixed parsing CDROM apt sources

Fixes #62474

Signed-off-by: Pedro Algarvio <[email protected]>

* Deprecate `salt.modules.aptpkg.expand_repo_def()`

Fixes #62485

Signed-off-by: Pedro Algarvio <[email protected]>

* Update test_aptpkg.py

Need to import os

Signed-off-by: Pedro Algarvio <[email protected]>
Co-authored-by: Gareth J. Greenaway <[email protected]>
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 Sulfur v3006.0 release code name and version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants