He also served as the U.S. ambassador to Iraq in 2004 and 2005 .