--- - name: Create inventory based on extra_vars hosts: all gather_facts: no become: no vars_files: - vars/defaults.yml vars: provision_host: "{{ tower_provision_host | default(ansible_play_hosts | join(',')) }}" tasks: - name: "Create in-memory inventory" add_host: name: "{{ item }}" groups: - remdiation delegate_to: localhost loop: "{{ provision_host.split(',') }}" # =========================================================================== # - name: Remove file from hosts hosts: remdiation gather_facts: no become: no vars_files: - vars/defaults.yml tasks: - name: "Remove file from {{ inventory_hostname }}" file: path : "{{ check_file }}" state : absent ...