How to Add a Groups to host Using the awx API?.
I have a groups( example- group_myproduct) that contains the common variables, I want to add the groups, group_myproduct to a host . How can I achieve this ?
How to Add a Groups to host Using the awx API?.
I have a groups( example- group_myproduct) that contains the common variables, I want to add the groups, group_myproduct to a host . How can I achieve this ?
I resolved it, I used the API
/api/v2/groups/{id}/hosts/
Details:
Step -1
http://localhost/api/v2/groups/
{
“name”: “testGroup”,
“description”: “”,
“inventory”: inventory_id,
“variables”: "group_var1: 9 "
}
Step -2
Get the group_id from the above API, Use the below api
http://localhost/api/v2/groups/{group_id}/hosts/
{
“name”: “host1”,
“description”: “”,
“enabled”: true,
“instance_id”: “”,
“variables”: “locahost_var1: 10”,
“inventory”: inventory_id
}
Note that inventory_id should be same for both API