'log an error to std err for ansible-playbook to consume and exit'

def fail_with_error(self, err_msg, err_operation=None):

    if err_operation:
        err_msg = 'ERROR:    "{err_msg}",    while:    {err_operation}'.format(err_msg=err_msg, err_operation=err_operation)
    sys.stderr.write(err_msg)
    sys.exit(1)
