From 9f622015f1367b9097bba2e81d096e52333d261e Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 15 Dec 2015 23:48:33 -0800 Subject: [PATCH] Added filename option to apt_repository module. --- packaging/os/apt_repository.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packaging/os/apt_repository.py b/packaging/os/apt_repository.py index 750169325e3..a44a8157d9a 100644 --- a/packaging/os/apt_repository.py +++ b/packaging/os/apt_repository.py @@ -63,6 +63,13 @@ options: required: false default: 'yes' choices: ['yes', 'no'] + filename: + version_added: '2.1' + description: + - Sets the name of the source list file in sources.list.d. + Defaults to a file name based on the repository source url. + The .list extension will be automatically added. + required: false author: "Alexander Saltanov (@sashka)" version_added: "0.7" requirements: [ python-apt ] @@ -72,6 +79,9 @@ EXAMPLES = ''' # Add specified repository into sources list. apt_repository: repo='deb http://archive.canonical.com/ubuntu hardy partner' state=present +# Add specified repository into sources list using specified filename. +apt_repository: repo='deb http://dl.google.com/linux/chrome/deb/ stable main' state=present filename='google-chrome' + # Add source repository into sources list. apt_repository: repo='deb-src http://archive.canonical.com/ubuntu hardy partner' state=present @@ -155,6 +165,9 @@ class SourcesList(object): def _suggest_filename(self, line): def _cleanup_filename(s): + filename = self.module.params['filename'] + if filename is not None: + return filename return '_'.join(re.sub('[^a-zA-Z0-9]', ' ', s).split()) def _strip_username_password(s): if '@' in s: @@ -420,6 +433,7 @@ def main(): state=dict(choices=['present', 'absent'], default='present'), mode=dict(required=False, default=0644), update_cache = dict(aliases=['update-cache'], type='bool', default='yes'), + filename=dict(required=False, default=None), # this should not be needed, but exists as a failsafe install_python_apt=dict(required=False, default="yes", type='bool'), validate_certs = dict(default='yes', type='bool'),