Making Ansible module template more robust

Mostly just results in better error messages. It also added new
dependency on json (core package) or simplejson for older versions of
Python.