Ammo Baron has three attacks: ramming with the tank, which stops at the crates, firing a fast black cannonball, and firing a slow red bouncing cannonball. Hit the red cannonball back to knock the Baron out of the tank, then run up and attack him until he recovers.
There's two safe spots from his attacks. One is crouching on top of the crates against the edge of the screen, but to completely remove the human element, move left from the start in front of the crates. Nothing can hit you here, and you can still hit the red cannonball back.