Fix problem with undef override_hostname

If override_hostname is not defined it uses the default of undef, but the logic in the template doesn't work as expected. I've added a failing rspec test first, which I will fix in another commit.