apt_repository: PEP8 compliancy and documentation changes (#33429)

* apt_repository: PEP8 compliancy and documentation changes

This PR includes:
- PEP8 compliancy changes
- Documentation changes

* Fix merge issue
pull/33527/head
Dag Wieers 7 years ago committed by GitHub
parent c4ef5bb922
commit fbfeeff6bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,21 +1,19 @@
#!/usr/bin/python
# encoding: utf-8
# (c) 2012, Matt Wright <matt@nobien.net>
# (c) 2013, Alexander Saltanov <asd@mokote.com>
# (c) 2014, Rutger Spiertz <rutger@kumina.nl>
#
# Copyright: (c) 2012, Matt Wright <matt@nobien.net>
# Copyright: (c) 2013, Alexander Saltanov <asd@mokote.com>
# Copyright: (c) 2014, Rutger Spiertz <rutger@kumina.nl>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'core'}
DOCUMENTATION = '''
---
module: apt_repository
@ -27,50 +25,44 @@ notes:
- This module supports Debian Squeeze (version 6) as well as its successors.
options:
repo:
required: true
default: none
description:
- A source string for the repository.
required: true
state:
required: false
choices: [ "absent", "present" ]
default: "present"
description:
- A source string state.
choices: [ absent, present ]
default: "present"
mode:
required: false
default: 0644
description:
- The octal mode for newly created files in sources.list.d
default: 0644
version_added: "1.6"
update_cache:
description:
- Run the equivalent of C(apt-get update) when a change occurs. Cache updates are run after making changes.
required: false
type: bool
default: "yes"
choices: [ "yes", "no" ]
validate_certs:
version_added: '1.8'
description:
- If C(no), SSL certificates for the target repo will not be validated. This should only be used
on personally controlled sites using self-signed certificates.
required: false
type: bool
default: 'yes'
choices: ['yes', 'no']
version_added: '1.8'
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
version_added: '2.1'
codename:
version_added: '2.3'
description:
- Override the distribution codename to use for PPA repositories.
Should usually only be set when working with a PPA on a non-Ubuntu target (e.g. Debian or Mint)
required: false
author: "Alexander Saltanov (@sashka)"
version_added: '2.3'
author:
- Alexander Saltanov (@sashka)
version_added: "0.7"
requirements:
- python-apt (python 2)
@ -87,7 +79,7 @@ EXAMPLES = '''
- apt_repository:
repo: deb http://dl.google.com/linux/chrome/deb/ stable main
state: present
filename: 'google-chrome'
filename: google-chrome
# Add source repository into sources list.
- apt_repository:
@ -102,12 +94,12 @@ EXAMPLES = '''
# Add nginx stable repository from PPA and install its signing key.
# On Ubuntu target:
- apt_repository:
repo: 'ppa:nginx/stable'
repo: ppa:nginx/stable
# On Debian target
- apt_repository:
repo: 'ppa:nginx/stable'
codename: 'trusty'
codename: trusty
'''
import glob
@ -233,7 +225,7 @@ class SourcesList(object):
# Check for another "#" in the line and treat a part after it as a comment.
i = line.find('#')
if i > 0:
comment = line[i+1:].strip()
comment = line[i + 1:].strip()
line = line[:i]
# Split a source into substring to make sure that it is source spec.
@ -479,15 +471,15 @@ def get_add_ppa_signing_key_callback(module):
def main():
module = AnsibleModule(
argument_spec=dict(
repo=dict(required=True),
state=dict(choices=['present', 'absent'], default='present'),
mode=dict(required=False, type='raw'),
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'),
codename = dict(required=False),
repo=dict(type='str', required=True),
state=dict(type='str', default='present', choices=['absent', 'present']),
mode=dict(type='raw'),
update_cache=dict(type='bool', default=True, aliases=['update-cache']),
filename=dict(type='str'),
# This should not be needed, but exists as a failsafe
install_python_apt=dict(type='bool', default=True),
validate_certs=dict(type='bool', default=True),
codename=dict(type='str'),
),
supports_check_mode=True,
)
@ -507,8 +499,7 @@ def main():
module.fail_json(msg='%s is not installed, and install_python_apt is False' % PYTHON_APT)
if isinstance(distro, aptsources_distro.Distribution):
sourceslist = UbuntuSourcesList(module,
add_ppa_signing_keys_callback=get_add_ppa_signing_key_callback(module))
sourceslist = UbuntuSourcesList(module, add_ppa_signing_keys_callback=get_add_ppa_signing_key_callback(module))
else:
module.fail_json(msg='Module apt_repository is not supported on target.')

@ -258,7 +258,6 @@ lib/ansible/modules/packaging/language/gem.py
lib/ansible/modules/packaging/language/maven_artifact.py
lib/ansible/modules/packaging/language/pear.py
lib/ansible/modules/packaging/os/apk.py
lib/ansible/modules/packaging/os/apt_repository.py
lib/ansible/modules/packaging/os/dpkg_selections.py
lib/ansible/modules/packaging/os/homebrew.py
lib/ansible/modules/packaging/os/homebrew_cask.py

Loading…
Cancel
Save