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 2 commits into
base: devel
Choose a base branch


Copy link

@bugrasan 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.

…apt update should update just the new repo added instead all repos
Copy link

@ansibot ansibot commented Mar 12, 2019

Copy link

@bcoca bcoca commented Oct 9, 2020

This seems to have been accidentally missed by triage process (bot took 'ci_verified' label as human having triaged the issue, not just the CI failure).

This PR needs a rebase, changelog and tests ... and of course, to pass CI.

Copy link

@aminvakil aminvakil commented Oct 9, 2020

What if the current repos have not been updated for long and the newly added repo needs a current version of dependencies which is not present in the out-dated package list on the remote server?

I think updating only the currently added repo may create a problem, am I right?

@ansibot ansibot removed the stale_ci label Dec 5, 2020
@ansibot ansibot added the pre_azp label Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants