---
- name: Add a host to Ansible inventory
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Add new host to inventory
      add_host:
        name: "{{ hostname }}"
        groups: "{{ group | default('all') }}"
        ansible_host: "{{ ip }}"