0

I know that apt update updates existing package-indexes on a supporting distro but not upgrading installed-packages (utilities) that were being installed based on these package-indexes (as apt upgrade upgrades the packages).

From the apt-get man:

update

update is used to resynchronize the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list. For example, when using a Debian archive, this command retrieves and scans the Packages.gz files, so that information about new and updated packages is available. An update should always be performed before an upgrade or dist-upgrade. Please be aware that the overall progress meter will be incorrect as the size of the package files cannot be known in advance.

I also know that Ansible has the apt module which includes this directive:

- name: update the apt package index i.e. apt-get update
  apt: update_cache=yes

The relevant Ansible docs say:

Run the equivalent of apt-get update before the operation. Can be run as part of the package installation or as a separate step.

I assume they say "equivalent" because Ansible translates "old" codes to their community-derived up2date equivalents (if the original codes themselves change).

But I still miss what caching has to do with anything here? To me the concept of caching in computing is making a copy of something far in a closer place, to save navigation when we need to use it, thus saving resources, but I still miss what it has to do with apt update or Ansible processing of apt update.

  • Maybe this should be migrated to DevOps stackexhcange - not sure. – JohnDoea Dec 11 '18 at 17:13
  • 1
    May I suggest for future questions that you focus on what you want to find out, rather than explaining what you think you already know (since that tends to sow confusion rather than help anything)? Your questions would be much better if they focused on a specific point (in this case, “What’s the cache implied by Ansible’s apt module’s update_cache parameter?”), instead of being “Tell me everything I need to know to understand ...” (which is how I understand your “I know ...”-based questions). – Stephen Kitt Dec 11 '18 at 17:32
  • Well, I don't want to be accused of XY problem or a an XY concept abuse charade (there are people bored enough to do just that)... Part of explaining what I'm trying to do is explaining what I know that was had to be done or why, I assume. – JohnDoea Dec 11 '18 at 17:34
  • Ansible questions will probably get more attention on serverfault.com. 165 questions tagged as ansible here, 874 questions there. – Teresa e Junior Dec 27 '18 at 15:53
2

apt maintains a local list of packages; that’s how it “knows” what packages are available, their dependencies etc. apt update updates these lists of packages by retrieving them from the repositories; it doesn’t upgrade any package.

That’s what the cache is: it is a local cache of the package information available from the repositories configured on the system. apt makes all its decisions based on this cache, so it must be kept up-to-date. An outdated cache can lead apt to miss updates or to fail to install a package altogether (because the version it wants is no longer available from the repositories).

update_cache=yes tells Ansible’s apt module to refresh the caches before applying whatever change is necessary (if any).

  • Wait, update_cache=yes tells Ansible’s apt module to refresh the caches before applying whatever change is necessary (if any).? Either the cache is updated or it isn't, right? So what do you mean by refresh the caches before applying whatever change is necessary (if any)? – JohnDoea Dec 11 '18 at 17:21
  • 2
    Either the cache is updated or it isn’t, yes. I’m talking about using update_cache along with another option (e.g. apt: - name: nginx - update_cache: yes to update the caches and install nginx); in that case, the cache is updated, but the other action might not result in a change (if the nginx package is already installed and up-to-date). – Stephen Kitt Dec 11 '18 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.