It won't work like that. The sed stuff is all inside single quotes. Just bind a name to the hostname value, and use Python interpolation to send it to the sed
function. You might even be able to use the env.host
setting. But an example of using this would look like this:
hostname = run("hostname -f")
fabric.contrib.files.sed(
'/etc/zabbix/zabbix_agentd.conf',
before='Hostname=localhost',
after='Hostname=%s' % hostname,
use_sudo=True, backup='')