Here is a presentation I gave at GVSU on 7/20/16 about the basics of metasploit and automation using pymetasploit

The code for autopsexec is not public right now because it is a mess. I'll update this post when I fix it!