Hi,
I have a couple of roles that add files to sources.list.d, and then install packages. Is it somehow possible to run the apt module to update apt index after ALL roles have added the files but before installing packages? I have tried a few approaches, none seems ideal:
1. Not making roles adding sources.list file, but instead put them in a central folder and use pre_tasks to add files and run apt before running roles.
This means if a role is not included, the corresponding sources.list file is still added.
2. Split each role into two roles, where one is for adding sources.list, the other installing packages.
With this approach, I use two loops, each in a separate playbook task, where the first loop includes roles that add sources.list files, and then apt module is run, and finally the second loop includes roles that install packages.
This forces me to explicitly list all roles needed (including dependencies) in a variable.
I wonder if there exist an elegant solution to run apt only once for all roles?
Regards,
Glen