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

wants to merge 1 commit into
base: devel


None yet
3 participants
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



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

  • Feature Pull Request

apt_repository module


the question "apt-get update only for a specific repository" has been answered on 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"    

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


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

This comment has been minimized.

Copy link

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.