Preheat oven to 350 degrees F (175 degrees C). Grease 2 baking sheets.
Whisk together flour, baking powder, baking soda, cinnamon, nutmeg, allspice, and salt in a bowl.
Beat margarine, white sugar, and brown sugar with an electric mixer in a large bowl until smooth. Beat egg, molasses, and vanilla into butter mixture until blended. Stir flour mixture into butter mixture until dough forms; fold in oats and coconut until just combined.
Roll dough into 1 1/4-inch balls and place 2 inches apart on the prepared baking sheets.
Bake in the preheated oven until edges are lightly browned, about 12 minutes. Allow to cool on the baking sheet for 5 minutes; remove to cool completely on a wire rack.