ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
14.06k stars 3.42k forks source link

Possible to move a host from one inventory to another #3784

Open AlanCoding opened 5 years ago

AlanCoding commented 5 years ago
ISSUE TYPE
SUMMARY

Using the API, a client can move a host from one inventory to another.

This leaves in place links to groups and inventory sources, pointing to the old inventory. This leaves the server in a very degenerate state.

ENVIRONMENT
STEPS TO REPRODUCE

Create 2 inventories.

Inside the first inventory, create a host and a group, make the host a child of the group.

Get the pk of the host and the pk of the second inventory

POST
/api/v2/inventories/<pk of second inventory>/hosts/
{"id": <pk of host in first inventory>}
EXPECTED RESULTS

400 you should not be able to do this action

You cannot perform this action as a PUT or PATCH on /api/v2/hosts/<pk of host in first inventory>

ACTUAL RESULTS

204 response code and host is now moved to 2nd inventory

ADDITIONAL INFORMATION

Even though the host is in the 2nd inventory, it remains a child of the group in the 1st inventory. What will the inventory given to ansible-playbook look like? 🤷‍♂

ryanpetrello commented 5 years ago

@wenottingham this seems notable enough that it needs attention.

wenottingham commented 5 years ago

How long has this worked? What permissions are required?