From fd88e8af53ed53e59300ff6afda6a24097eeda48 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Wed, 29 Jul 2015 17:49:37 +0200 Subject: [PATCH] fix error occurring with Debian Error was: AttributeError: 'SourcesList' object has no attribute 'repos_urls' --- lib/ansible/modules/packaging/os/apt_repository.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/packaging/os/apt_repository.py b/lib/ansible/modules/packaging/os/apt_repository.py index 71f78e2970c..750169325e3 100644 --- a/lib/ansible/modules/packaging/os/apt_repository.py +++ b/lib/ansible/modules/packaging/os/apt_repository.py @@ -360,6 +360,10 @@ class UbuntuSourcesList(SourcesList): if line.startswith('ppa:'): source, ppa_owner, ppa_name = self._expand_ppa(line) + if source in self.repos_urls: + # repository already exists + return + if self.add_ppa_signing_keys_callback is not None: info = self._get_ppa_info(ppa_owner, ppa_name) if not self._key_already_exists(info['signing_key_fingerprint']): @@ -445,13 +449,8 @@ def main(): sources_before = sourceslist.dump() - if repo.startswith('ppa:'): - expanded_repo = sourceslist._expand_ppa(repo)[0] - else: - expanded_repo = repo - try: - if state == 'present' and expanded_repo not in sourceslist.repos_urls: + if state == 'present': sourceslist.add_source(repo) elif state == 'absent': sourceslist.remove_source(repo)