On 2022-07-04 (Mon) 15:14, Glen Huang wrote:
Thanks for the quick reply. On Monday, July 4, 2022 at 3:11:39 PM UTC+8 [email protected] wrote: At the end you use that to decide if an apt task should be run thatupdates the cache.I wonder where the "end" should be? Since each role's tasks contain both adding the sources.list and installing packages. It seems a task at the playbook can only either update the apt cache before all addings or after all installings.
If that is the case (each of the roles adds a sources.list.d file, and install packages), then I don't think this is possible, as the roles are run sequentially.
I would then change each role to conditionally do 'apt-get update' depending on whether a file was dropped in /etc/apt/sources.list.d.
But, adding files to /etc/apt/sources.list.d sounds like a legacy approach. Perhaps this is already old code?
Ideally you'd just use a single apt_repository task, which has a conditional update_cache option built-in:
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_repository_module.html#parameter-update_cache -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d08d539c-64f1-a57d-a8e4-67f264ee7e79%40gmail.com.
OpenPGP_0x266713D4E6EF488D.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature
