Break this big chunk to more methods or callbacks and place them to models could help with understanding. E.g. `@deployment.hostgroup.name = @deployment.name` can be in callback.