I am able to create inventories, groups and hosts. However I am unable to 
associate the hosts to a group.

http://docs.ansible.com/ansible-tower/latest/html/towerapi/host_list.html

The ansible documentation for creating hosts doesn't mention how to link 
the hosts with a group

http://docs.ansible.com/ansible-tower/latest/html/towerapi/group_list.html

The documentation for creating a group also doesn't specify any variables 
to specify hosts under it.

main.yml

- name: Create a group in Ansible Tower Inventory
  uri:
    url: https://***tower_ip***/api/v2/groups/
    method: POST
    user: admin
    password: password
    body: "{{ lookup('file','Inven4-Group2.json') }}"
    force_basic_auth: yes
    status_code: 201
    body_format: json
    validate_certs: False
  register: Inventory-creation-result

- name: Create a host in Ansible Tower Inventory
  uri:
    url: https://***tower_ip***/api/v2/hosts/
    method: POST
    user: admin
    password: password
    body: "{{ lookup('file','Inven4-Group1-Host1.json') }}"
    force_basic_auth: yes
    status_code: 201
    body_format: json
    validate_certs: False
  register: Host-creation-result

Inven4-Group1-Host1.json

{"name": "Inven4-Group1-Host1", "inventory": 4}

Inven4-Group1.json

{"name": "Inven4-Group1", "inventory": 4}

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f5fd507f-612d-4317-a0f8-18a624fdb081%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to