The trick is the ```host_aliases``` being optional. Puppet doesn't like when its specified and empty. So even in the heredoc, I'd have an if statement. The conditional would have to happen twice (once to build the alias list, once to decide to include it). 

I get splitting up the logic. But its probably going to look more like:

```
resource_name = aliases.shift

if (!aliases.empty?)
  aliases = aliases.map { |alias| "'" + alias + "'" }.join(", ")
  host_aliases="host_aliases => [#{aliases}],"
end

str = <<-MANIFEST
  host { '#{resource_name}':
    ip => '#{address}',
    #{host_aliases if (!aliases.empty?)}
  }  
MANIFEST
```

That still more readable to you?