12 factor apps like podcast api use a .env file, add a way to modify such files such as:
fab production set_env:ENV_VAR,ENV_VALUE
if the env exists, then replace if not, then append. http://docs.fabfile.org/en/1.11/api/contrib/files.html
Something like this should work:
if fabric.contrib.files.contains().failed:
fabric.contrib.files.append()
else:
fabric.contrib.files.sed()
maybe use if fabric.contrib.files.sed().failed: directly