Skip to main content
1 of 3

The add_host task works as expected. For example (simplified a bit)

    - add_host:
        name: "{{ item }}"
        groups: cloned_group
      loop: [cm_1, cm_2, cm_3]

will create the inventory group cloned_group. Let's take a look

    - debug:
        var: groups.cloned_group

gives as expected

  groups.cloned_group:
  - cm_1
  - cm_2
  - cm_3

Example of a complete playbook for testing

- hosts: localhost

  tasks:

    - add_host:
        name: "{{ item }}"
        groups: cloned_group
      loop: [cm_1, cm_2, cm_3]

    - debug:
        var: groups.cloned_group