Fixes #4979 Check for the correct context when inside the inventory_hostnames plugin