mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix apt_repository so that it does not modify the mode of existing repositories
This commit is contained in:
parent
1f6c177da0
commit
9ecd06fb47
1 changed files with 6 additions and 2 deletions
|
@ -126,6 +126,8 @@ class InvalidSource(Exception):
|
|||
class SourcesList(object):
|
||||
def __init__(self):
|
||||
self.files = {} # group sources by file
|
||||
# Repositories that we're adding -- used to implement mode param
|
||||
self.new_repos = set()
|
||||
self.default_file = self._apt_cfg_file('Dir::Etc::sourcelist')
|
||||
|
||||
# read sources.list if it exists
|
||||
|
@ -257,6 +259,7 @@ class SourcesList(object):
|
|||
module.atomic_move(tmp_path, filename)
|
||||
|
||||
# allow the user to override the default mode
|
||||
if filename in self.new_repos:
|
||||
this_mode = module.params['mode']
|
||||
module.set_mode_if_different(filename, this_mode, False)
|
||||
else:
|
||||
|
@ -300,6 +303,7 @@ class SourcesList(object):
|
|||
|
||||
files = self.files[file]
|
||||
files.append((len(files), True, True, source_new, comment_new))
|
||||
self.new_repos.add(file)
|
||||
|
||||
def add_source(self, line, comment='', file=None):
|
||||
source = self._parse(line, raise_if_invalid_or_disabled=True)[2]
|
||||
|
|
Loading…
Reference in a new issue