- name: Destroy lab instances in AWS
  hosts: localhost
  connection: local
  become: no
  gather_facts: no

  vars:
    ec2_exact_count: 0
    ec2_wait: no

  roles:
    - manage_ec2_instances

  post_tasks:
    - name: Cleanup local files
      shell: rm -f *.txt

- name: Destroy lab instances in AWS
  hosts: localhost
  connection: local
  become: no
  gather_facts: yes

  vars:
    ec2_exact_count: 0
    ec2_wait: no

  roles:
    - manage_ec2_instances

  post_tasks:
    - name: Find .txt files
      find:
        paths: "{{ ansible_env.PWD }}"
        patterns: '*.txt'
      register: files

    - name: Remove inventory files
      file:
        state: absent
        path: "{{ item }}"
      with_items: "{{ files.files }}"

Use modules for removing inventory files
Use modules for removing inventory files
