Extract Template from metasploit_model_module_ancestor write_template

MSP-9228

Extract arguments passed to Metasploit::Model::Spec::Template.new in the
:metasploit_model_module_ancestor factory's write_template into a new
Metasploit::Model::Module::Ancestor::Spec::Template that only requires
a module_ancestor to be passed, so that the template can be rewritten
after build has returned and the associations are modified.
Validate module_ancestor if real_pathname is nil for templates

MSP-9228

Push the logic used in metasploit_model_module_ancestor write_template,
which validates module_ancestor to derive real_pathname into
Metasploit::Model::Module::Ancestor::Spec::Template#destination_pathname
so users of the Template don't have to remember to do that.
Metasploit::Model::Module::Ancestor::Spec::Template.write

MSP-9228

Move entirety of :metasploit_model_module_ancestor write_template into
class method so it can be called easily after build returns to
regenerate the template after modifying associations.