Skip to content

Commit 577d0e4

Browse files
mgedminabadger
authored andcommitted
apt_repository: check for enabled repositories correctly
Fixes #20754. Details: UbuntuSourcesList.add_source() had a quick check for PPAs being already present in the source lists. The check was looking for the PPAs URL to be present in self.repo_urls, which should contain all valid and enabled repositories. The enabled check in repo_urls was incorrect. It was checking the tuple's 2nd item (which means "valid") and ignoring the 3rd item (which means "enabled"). self.files contains tuples (line_number, valid, enabled, source_line, comment_text). Ideally it would be using named tuples instead of indexing, to avoid bugs like that, but Python 2.4 didn't have named tuples, so we can't do that (yet).
1 parent f16ee28 commit 577d0e4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/ansible/modules/packaging/os/apt_repository.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,11 @@ def repos_urls(self):
458458
_repositories = []
459459
for parsed_repos in self.files.values():
460460
for parsed_repo in parsed_repos:
461-
enabled = parsed_repo[1]
461+
valid = parsed_repo[1]
462+
enabled = parsed_repo[2]
462463
source_line = parsed_repo[3]
463464

464-
if not enabled:
465+
if not valid or not enabled:
465466
continue
466467

467468
if source_line.startswith('ppa:'):

0 commit comments

Comments
 (0)