Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apt_repository should update only the new repository #53670

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
3 participants
@bugrasan
Copy link

bugrasan commented Mar 12, 2019

when adding new repository to apt (with apt_repository module), and set update_cache to true, the apt update should update just the new repo added instead all repos

822a7e1

SUMMARY

this will create a slight performance gain since apt cache update would not need to update all repository sources, especially while adding multiple sources.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

apt_repository module

ADDITIONAL INFORMATION

the question "apt-get update only for a specific repository" has been answered on askubuntu.com with following code sniplet:

update-repo() {
    for source in "$@"; do
        sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/${source}" \
        -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"    
    done
}

this is the same behaviour that python-apt bindings are using to update the cache in cache.update() function, however due to the following line with os.path.abspath

                apt_pkg.config.set("Dir::Etc::sourcelist",
                                   os.path.abspath(sources_list))

we need to provide the absolute path of the new repo file.

Therefore please review the code if there is a better way to add the absolute path and filename within ansible.

Additionally while removing a repository we don't need to update the apt sources cache again, apt seems to be intelligent enough to handle this properly.

when adding new repository to apt, and set update_cache to true, the …
…apt update should update just the new repo added instead all repos
@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Mar 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.