summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorverm666 <verm666@gmail.com>2015-06-25 10:56:29 -0700
committerMarc Abramowitz <marc@marc-abramowitz.com>2015-07-04 13:27:54 +0000
commit1749ccd41842d121f891cc7b4dc139b822f7d0bb (patch)
treeebaedfbd76ebf5351848a9c7ad541d056e1e90cd
parenta32d29ee387f44beceaf5b25ba8194ba30f5f997 (diff)
downloadansible-modules-core-1749ccd41842d121f891cc7b4dc139b822f7d0bb.tar.gz
This change is in response to issue #133.
The original problem is: apt_repository.py connect to launchpad on every playbook run. In this patch apt_repository.py checks if required repository already exists or not. If no - paa will be added, if yes - just skip actions.
-rw-r--r--packaging/os/apt_repository.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/packaging/os/apt_repository.py b/packaging/os/apt_repository.py
index 2ee5819f..53e51466 100644
--- a/packaging/os/apt_repository.py
+++ b/packaging/os/apt_repository.py
@@ -370,6 +370,25 @@ class UbuntuSourcesList(SourcesList):
source = self._parse(line, raise_if_invalid_or_disabled=True)[2]
self._remove_valid_source(source)
+ @property
+ def repos_urls(self):
+ _repositories = []
+ for parsed_repos in self.files.values():
+ for parsed_repo in parsed_repos:
+ enabled = parsed_repo[1]
+ source_line = parsed_repo[3]
+
+ if not enabled:
+ continue
+
+ if source_line.startswith('ppa:'):
+ source, ppa_owner, ppa_name = self._expand_ppa(i[3])
+ _repositories.append(source)
+ else:
+ _repositories.append(source_line)
+
+ return _repositories
+
def get_add_ppa_signing_key_callback(module):
def _run_command(command):
@@ -417,8 +436,13 @@ 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':
+ if state == 'present' and expanded_repo not in sourceslist.repos_urls:
sourceslist.add_source(repo)
elif state == 'absent':
sourceslist.remove_source(repo)