How to update the package cache only once per playbook run?

1,950 views
Skip to first unread message

David Reagan

unread,
Jul 22, 2013, 2:55:59 PM7/22/13
to ansible...@googlegroups.com
Every time I install a package, I want to make sure I have the latest version. That means I need to run apt-get update, or it's equivalent, before I install the package. Currently I have an 'apt update_cache=yes" task running before every package install. That results in multiple 'apt-get update' calls. Is there a good way to make that only happen once per ```ansible-playbook --sudo /etc/ansible/webservices.yml``` ? 

Would ```state=latest``` update the cache only once per run? 

Would that work with other package management modules, like yum?

Michael DeHaan

unread,
Jul 22, 2013, 3:00:14 PM7/22/13
to ansible...@googlegroups.com
I would just put in a common role, but see also the 'cache_valid_time' option on the apt module.







--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

David Reagan

unread,
Jul 22, 2013, 4:52:43 PM7/22/13
to ansible...@googlegroups.com
Thanks, 'cache_valid_time' helps.

Though, sticking it in the common role is probably the better idea... :)
Reply all
Reply to author
Forward
0 new messages