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