This saying is quoted in the name of the Chafetz Chaim on multiple websites:
Here's a video in which Rabbi Ovadyah Yosef zt"l says it in his name (from 19:14). And the story is likewise told in this book about Rav Ovadyah's sayings and in this article by Rabbi Shlomo Aviner. His version is thus:
"פעם נכנס החפץ חיים לישיבת ראדין, כולם תלמידי חכמים, הטו אזנם לשמוע. רבותי! אומר לכם מעשה: נפוליאון, זה היה מצביא גדול של צרפת, היה קיסר של צרפת. נפוליאון פעם אחת עשה מסדר עם החיילים שלו. עמד ואמר כך: חיילים, תשמעו! כל מי שאינו שואף להיות גנרל - אין מקומו פה, שילך, הוא גם לא חייל. חייל זה רק לשאוף, לעלות, להתקדם, מחיל אל חיל עד שיהיה גנרל. ואני אומר לכם רבותי! מי שלא שואף להיות גדול הדור - שילך מכאן, אין מקומו כאן."
Translation: "One day the Chafetz Chaim entered the yeshiva in Radin, all of them [the students] were talmidei chachamim, and they turned to listen. "Gentlemen! I shall tell you a story: Napoleon, he was a great general of France; he was the emperor of France. Napoleon once organized a line-up of his soldiers. He stood and said: "Soldiers, Listen! Whoever doesn't aspire to be a general - his place is not here, he should go, he won't even be a simple soldier. Being a soldier means aspiring to rise, to move forward, from rank to rank until he becomes a general." And I say to you gentlemen! Whoever doesn't aspire to be the Gedol Hador - he should leave, his place is not here."
Here and here it's said that the story came from the book Olat Shlomo part 2, pg. 501. There's such a book on Hebrewbooks, but the quote doesn't appear to be in it (nor does it have 501 pages), so presumably it's a different Olat Shlomo.
[Most of the following sources can be found on Otzar Hachochmah and a couple also on Hebrewbooks (as linked)]
In the book Vayehi Binso'ah Ha'aron in memory of Rabbi Avraham Shapira, pg. 63, it's also brought in the name of the Chafetz Chaim. In the book Yalkut Avrech by R' Avraham Kohen, he quotes the book Meir Einei Yisrael where it says that the author heard from "a famous talmid chacham" who heard from Rabbi Eliyahu Duschnitzer who heard said he heard it from the Chafetz Chaim. Rabbi Abba Kleinerman in Kovetz Gilyonot 5778 Vakyikra 3 wrote that he heard from Rabbi Yechezkel Sarna, a student of the Saba of Slobodka, that the Chafetz Chaim would say this.
In Imrei Shefer on Pirkei Avot by Rabbi Shmuel Pinchasi, he brings it in the name of the Saba of Slobodka (pg. 158). Rabbi Yosef Kanwitz's son also brings it in the name of the Saba, in the book about his father, Divrei Yosef, pg. 3. So too in the publication of the Youths of Agudat Yisrael Diglenu, Issue 339. In the book Bnei Chayil by R' Gold he brings it in the name of Rabbi Akiva Eiger. Rabbi Yehudah Segal in Dorshei Hashem and in Reshit Ha'avodah brings it in the name of Rabbi Eliyahu Duschnitzer, who was a student of the Chafetz Chaim and later a rabbi in his yeshiva in Radin. In Nazar Hayah Shmuel, pg. 72, it is said in the name of Rabbi Moshe Sholzinger that Rabbi Yisrael of Salant said this.