How to construct an array variable containing results of an iterative ansible task? Use register. The referenced variable will contain a property results which is a list containing the combined outputs of the loop. https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_loops.html#registering-variables-with-a-loop [[ansible]]