From e29a62d87fd9ae7c4acaad31809b5b7f6581fd3b Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 4 Mar 2019 20:39:17 +0000 Subject: [PATCH] Filter setup-repos loop before include_tasks Ansible task execution can be a bit slow - so the noop case where we don't end up doing anything can still be costly. Instead, put the when on the loop call, which will apply to each iteration of the loop, not running the loop itself. This way we should only include_tasks if we need to. In order for the utility playbook to keep working, we also run all of the iterations of the loop if gitea_always_update is true. This will make a sync run take a long time but be comprehensive. Change-Id: Ib60c736d46d8253e603de097eb80bc84b3366310 --- playbooks/roles/gitea-git-repos/tasks/main.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/playbooks/roles/gitea-git-repos/tasks/main.yaml b/playbooks/roles/gitea-git-repos/tasks/main.yaml index 7d05c3b6f0..d356e9c8a8 100644 --- a/playbooks/roles/gitea-git-repos/tasks/main.yaml +++ b/playbooks/roles/gitea-git-repos/tasks/main.yaml @@ -41,3 +41,4 @@ loop_control: loop_var: project include_tasks: 'setup-repo.yaml' + when: gitea_always_update or project.project not in gitea_repos