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}