Hello everybody,
I am using Ansible 2.3.1.1 with Jenkins. I have encountered the following issue - my playbook which uses variables from aws dynamic inventory becomes extremely slow. The most interesting case that if I copy this playbook outside my jenkins workspace and run it in any other directory the execution speed is OK. In order to test it I moved out all variable files from workspace directory /group_vars/all, as a result the execution speed for this playbook inside workspace become OK too. Then I put variable files back to /group_vars/all one by one and test execution time. Each additional file in the folder augments the execution time for each task iteration. Also when I put one file which has reference to removed file variable Ansible throwed an error.
I can conclude that Ansible evaluates all variables in the /group_vars/all for each tasks and for each iteration of the task before run despite it is not actually used. But according to the documentation Ansible uses lazy evaluation method, so I can not understand why this issue occurs and how it could be fixed. Could someone shed the light on it?
the playbook is the following:
- hosts: “127.0.0.1”
tasks:
- name: print something
debug:
var: hostvars["{{item}}"]['ec2_vpc_id']
with_items: "{{groups['some_tag']}}"
Regards.