In this case your CC&R's take precedence. CC&Rs can be more strict than law, but not less. If it were the other way around, (the CC&Rs said you could have chickens, City Code said "no") then the City Code would take precedence.
It all depends on how the law or ordinance is worded. If it is guaranteeing you a right (as compared with restricting unlimited rights), then it will take precedence.
In cases where a law is clearly designed to guarantee rights to those who live in HOAs that is usually clearly stated. This has ocurred in Arizona for erecting flagpoles and flying flags, installing solar panels, parking on the street or in the driveway, voting and hearing rights, etc. It is different for every state, and I doubt that most would specifically address poultry or other animals--there is simply not a large enough contingent to make it worth the legal effort of getting the laws written and passed. I think Michigan with its Right to Farm Act has the closest chance of actually addressing it, and I doubt even they would.