From 40d9650f20133cd6942990df205300fec802511f Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 2 Apr 2020 11:06:12 -0500 Subject: [PATCH] Migrate apt_repo to community.general. Fixes #68637 (#68641) --- lib/ansible/config/routing.yml | 2 + lib/ansible/modules/packaging/os/apt_repo.py | 149 ------------------- test/sanity/ignore.txt | 1 - 3 files changed, 2 insertions(+), 150 deletions(-) delete mode 100644 lib/ansible/modules/packaging/os/apt_repo.py diff --git a/lib/ansible/config/routing.yml b/lib/ansible/config/routing.yml index 9fd5772efe9..742c097ed23 100644 --- a/lib/ansible/config/routing.yml +++ b/lib/ansible/config/routing.yml @@ -57,6 +57,8 @@ plugin_routing: redirect: frr.frr.frr_facts frr_bgp: redirect: frr.frr.frr_bgp + apt_repo: + redirect: community.general.apt_repo aws_acm_facts: redirect: community.aws.aws_acm_facts aws_kms_facts: diff --git a/lib/ansible/modules/packaging/os/apt_repo.py b/lib/ansible/modules/packaging/os/apt_repo.py deleted file mode 100644 index 7215006f0e3..00000000000 --- a/lib/ansible/modules/packaging/os/apt_repo.py +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# Copyright: (c) 2018, Mikhail Gordeev - -# 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_repo -short_description: Manage APT repositories via apt-repo -description: - - Manages APT repositories using apt-repo tool. - - See U(https://www.altlinux.org/Apt-repo) for details about apt-repo -notes: - - This module works on ALT based distros. - - Does NOT support checkmode, due to a limitation in apt-repo tool. -version_added: "2.8" -options: - repo: - description: - - Name of the repository to add or remove. - required: true - state: - description: - - Indicates the desired repository state. - choices: [ absent, present ] - default: present - remove_others: - description: - - Remove other then added repositories - - Used if I(state=present) - type: bool - default: 'no' - update: - description: - - Update the package database after changing repositories. - type: bool - default: 'no' -author: -- Mikhail Gordeev (@obirvalger) -''' - -EXAMPLES = ''' -- name: Remove all repositories - apt_repo: - repo: all - state: absent - -- name: Add repository `Sisysphus` and remove other repositories - apt_repo: - repo: Sisysphus - state: present - remove_others: yes - -- name: Add local repository `/space/ALT/Sisyphus` and update package cache - apt_repo: - repo: copy:///space/ALT/Sisyphus - state: present - update: yes -''' - -RETURN = ''' # ''' - -import os - -from ansible.module_utils.basic import AnsibleModule - -APT_REPO_PATH = "/usr/bin/apt-repo" - - -def apt_repo(module, *args): - """run apt-repo with args and return its output""" - # make args list to use in concatenation - args = list(args) - rc, out, err = module.run_command([APT_REPO_PATH] + args) - - if rc != 0: - module.fail_json(msg="'%s' failed: %s" % (' '.join(['apt-repo'] + args), err)) - - return out - - -def add_repo(module, repo): - """add a repository""" - apt_repo(module, 'add', repo) - - -def rm_repo(module, repo): - """remove a repository""" - apt_repo(module, 'rm', repo) - - -def set_repo(module, repo): - """add a repository and remove other repositories""" - # first add to validate repository - apt_repo(module, 'add', repo) - apt_repo(module, 'rm', 'all') - apt_repo(module, 'add', repo) - - -def update(module): - """update package cache""" - apt_repo(module, 'update') - - -def main(): - module = AnsibleModule( - argument_spec=dict( - repo=dict(type='str', required=True), - state=dict(type='str', default='present', choices=['absent', 'present']), - remove_others=dict(type='bool', default=False), - update=dict(type='bool', default=False), - ), - ) - - if not os.path.exists(APT_REPO_PATH): - module.fail_json(msg='cannot find /usr/bin/apt-repo') - - params = module.params - repo = params['repo'] - state = params['state'] - old_repositories = apt_repo(module) - - if state == 'present': - if params['remove_others']: - set_repo(module, repo) - else: - add_repo(module, repo) - elif state == 'absent': - rm_repo(module, repo) - - if params['update']: - update(module) - - new_repositories = apt_repo(module) - changed = old_repositories != new_repositories - module.exit_json(changed=changed, repo=repo, state=state) - - -if __name__ == '__main__': - main() diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index f26cc4552ab..c46acfbfb41 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -150,7 +150,6 @@ lib/ansible/modules/packaging/os/apt.py validate-modules:undocumented-parameter lib/ansible/modules/packaging/os/apt_key.py validate-modules:mutually_exclusive-unknown lib/ansible/modules/packaging/os/apt_key.py validate-modules:parameter-type-not-in-doc lib/ansible/modules/packaging/os/apt_key.py validate-modules:undocumented-parameter -lib/ansible/modules/packaging/os/apt_repo.py validate-modules:parameter-type-not-in-doc lib/ansible/modules/packaging/os/apt_repository.py validate-modules:doc-default-does-not-match-spec lib/ansible/modules/packaging/os/apt_repository.py validate-modules:parameter-invalid lib/ansible/modules/packaging/os/apt_repository.py validate-modules:parameter-type-not-in-doc