1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
- hosts: localhost gather_facts: false tasks: - name: Add localhost to all group if no hosts are defined ansible.builtin.add_host: name: "localhost" ansible_connection: "local" when: groups['all'] | length == 0 tags: - always - hosts: all become: true tasks: - ansible.builtin.import_role: name: "host"