'execute a command on the lxd host'

def exec_command(self, cmd, in_data=None, sudoable=True):

    super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
    self._display.vvv(u'EXEC    {0}'.format(cmd), host=self._host)
    local_cmd = [self._lxc_cmd, 'exec', self._host, '--', self._play_context.executable, '-c', cmd]
    local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
    in_data = to_bytes(in_data, errors='surrogate_or_strict', nonstring='passthru')
    process = Popen(local_cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    (stdout, stderr) = process.communicate(in_data)
    stdout = to_text(stdout)
    stderr = to_text(stderr)
    if (stderr == 'error:    Container    is    not    running.\n'):
        raise AnsibleConnectionFailure(('container    not    running:    %s' % self._host))
    if (stderr == 'error:    not    found\n'):
        raise AnsibleConnectionFailure(('container    not    found:    %s' % self._host))
    return (process.returncode, stdout, stderr)
