Your puppy has a fecalith, which is dried poop stuck in the hair around the anus. This results in slowed, incomplete or no passage of stool. The backup of food material in the GI tract then leads to the vomiting. Removal of the fecalith is the first step. This can sometimes be done by massaging the mass under a stream of warm water (sink or bath spray handle is easiest.) Once the fecalith is removed poop is usually passed soon, if not an enema can be required. The formation of a fecalith many times is just an accident and keeping the hair around the anus trimmed can prevent it from happening again. Sometimes there can be infections involving the GI tract that are a contributing factor so having your puppy checked by a veterinarian is a good idea, even if you remove the fecalith.