Environment variables in dynamic inventory won't work, f.e.
"ansible_ssh_private_key_file": $HOME/.ssh/key.pem"
If the dynamic inventory server side passes $HOME
for example, replace the variable in the client code (Python):
json_input.replace("$HOME", os.environ.get("HOME"))