From charlesreid1

No edit summary
No edit summary
Line 1: Line 1:
there is now a convenient cache_valid_time parameter for the apt module:
=apt tasks=


Example:
==apt cache - but not always==
Only run "update_cache=yes" if the last one is more than more than 3600 seconds ago
 
the apt cache is the local version of the package database. if this hasn't been updated in a while it will be out of sync with the latest version of the package database from the web.
 
<code>apt-get update</code> fixes this problem, but it can be time-consuming to run apt-get update every time you do anything with the playbook.
 
apt tasks now accept a <code>cache_valid_time</code> parameter for the apt module that specifies how many seconds old the cache should be to update it.
 
To make this setting 1 hour, set to 3600 s:


<pre>
<pre>
Line 12: Line 19:
From:
From:
http://www.ansibleworks.com/docs/modules.html
http://www.ansibleworks.com/docs/modules.html


=Flags=
=Flags=


{{AnsibleFlag}}
{{AnsibleFlag}}

Revision as of 06:31, 8 December 2018

apt tasks

apt cache - but not always

the apt cache is the local version of the package database. if this hasn't been updated in a while it will be out of sync with the latest version of the package database from the web.

apt-get update fixes this problem, but it can be time-consuming to run apt-get update every time you do anything with the playbook.

apt tasks now accept a cache_valid_time parameter for the apt module that specifies how many seconds old the cache should be to update it.

To make this setting 1 hour, set to 3600 s:

task:
 - name: update apt cache 
    apt: update_cache=yes cache_valid_time=3600

From: http://www.ansibleworks.com/docs/modules.html

Flags