Everything I wrote in this answer to another question of you applies here as well. But instead of calling
move_and_collide you would now set the rotation like this:
rotation = velocity.angle()
That's assuming your cannon's sprite (or whatever you use to indicate the direction) is facing right by default. Otherwise you'd need to add an offset. Furthermore this will rotate the cannon immediately, which might or might not be what you want.
If you want it to turn around slowly, try this instead:
var difference = abs(rotation - velocity.angle())
if velocity.angle() > rotation:
rotation += min(difference, 0.01)
rotation -= min(difference, 0.01)
Here 0.01 is the maximum value (in radians) your cannon will rotate in one frame.