I think this needs quotes around #{host.hostgroup} in case the name has spaces in.. the link here was broken without them.