I’m trying to ascertain the best way to update my Ansible roles prior to running them in Foreman. I’m hoping to find an automatic way of syncing my roles from GitHub prior to each task run.
My initial thought was that I could configure the “Ansible Roles - Ansible Default” job template with a pre-task that runs on my foreman-server and makes use of the ansible ‘git’ module, but I’m a little stuck. I was specifically looking for a way to only update just those roles that are about to be used, and I’m also hoping to accomplish this without user input while running the task. I’m wondering if it’s possible to make use of a variable (like maybe @host.all_ansible_roles.present?) to update the roles on my foreman-server before running those roles on all the target hosts.
If anybody has done something like this, I would love to know how you accomplished it!