0

I am able to create a host in AWX with the REST API but haven't found out how to associate that host to a group via the REST api. (The groups have already been created via the GUI). Wondering how to add the group to the host via the REST API. using python:

PAYLOAD = {
    'name': "myHost",
    'inventory': "myInventory",
    'description': "This is my awesome host."
    }

r = requests.post(url=host_URL, data=json.dumps(PAYLOAD), headers={'content-type': 'application/json'})
Alexander Witte
  • 195
  • 1
  • 11

1 Answers1

0

Never found out how to do this with the REST API. Did it easily enough with tower-cli

1) Find out what your group ids are:

tower-cli group list -a -i yourinventoryname

2) Add the host to the group:

tower-cli host associate --host 10.1.2.103 --group 4
Alexander Witte
  • 195
  • 1
  • 11