Yes, it was immoral. Torture is always immoral.
Sometimes a lesser immoral act is necessary to prevent a greater one. Lesser of two weevils and all that.
But that an evil is lesser does not make it un-evil.
War, for example, is by definition evil. Yet sometimes it is necessary to prevent greater evil. But that simply does not ever make it good.
Wow, just wow. Calling the CIA agents immoral? What site are you on? Maybe the DU might suit you better....