Prime Minister Justin Trudeau will apologize Tuesday to members of the LGBT community for actions the government took against thousands of workers in the Canadian military and public service in the Cold War era.

From the 1950s to the 1990s, thousands of federal workers were fired because of their sexuality as part of a "national security" purge.

Some gay members of the Canadian Armed Forces were also discharged for what was termed "psychopathic personality with abnormal sexuality."

In June 2016, LGBT advocacy group Egale Canada released a report detailing the systemic discrimination and issued a number of recommendations, including that a formal apology be issued by Ottawa.

On November 28, the Government will offer a formal apology to LGBTQ2 Canadians in the House - for the persecution & injustices they have suffered, and to advance together on the path to equality & inclusion. —@JustinTrudeau

It was announced in May that Trudeau promised to apologize, and the prime minister set the date of the apology for Nov. 28.

Ottawa also announced Monday that the government will earmark over $100 million to compensate LGBT civil servants whose careers were sidelined or ended because of their sexuality.

Here's a look at some of things for which he will be apologizing:

'Fruit machines'

Many pointed to the Cold War as the reason for the discrimination against LGBT individuals, with the RCMP and the military fearing gay and lesbian members could be open to blackmail by the Soviet Union.

"They were convinced that people could be blackmailed into selling secrets... that was the official party line adopted from McCarthyism in the States," Barry Deeprose, a prominent LGBT activist, told CBC in 2005.

An RCMP unit was tasked with rooting out homosexual public workers, including diplomat John Wendell Holmes, who admitted his homosexuality and was quietly removed from public service in 1960 after being grilled by the Mounties.

The Canadian government went so far as to commission a Carleton University professor to develop a homosexuality test — a so-called "fruit machine."

In one test, subjects were shown pornographic images while cameras took pictures of their pupils to see if they dilated — the idea being that if their eyes dilated while looking at images of the same sex, it suggested excitement and therefore a same-sex attraction.

Government commissioned 'Fruit Machine' in 1960s to detect homosexuals 6:34

The machine was used by the federal government throughout the 1960s, until the Defence Research Board — which was later folded into the Department of National Defence — pulled funding in 1967.

By the 1960s, the RCMP had a database of 9,000 "expected" lesbians and gay men working across the federal government.

Sanctions for their sexuality included dismissal, demotion, denial of opportunities for promotion, being forced to live a double life and other forms of systemic discrimination, according to the 2016 Egale Canada report.

Canadians share their views of homosexuality on the streets of Vancouver in 1959 0:35

A class action lawsuit was filed in November 2016 against the Trudeau government in both Ontario and Quebec over the firings.

"It is absolutely unacceptable what some members of the Canadian Armed Forces went through," Defence Minister Harjit Sajjan at the time.

"Discrimination of any kind — whether it's sexual orientation, gender, ethnicity — is absolutely unacceptable and will be stamped out."

'No place for the state in the bedrooms'

In 1969, the House of Commons voted 149-55 to pass an omnibus bill that, among other things, decriminalized homosexuality and allowed abortions under certain conditions.

"The view we take here is that there's no place for the state in the bedrooms of the nation," Pierre Trudeau, then Canada's acting justice minister, said in 1967 when he first introduced the bill.

"I think what's done in private between two consenting adults doesn't concern the Criminal Code [of Canada]," he said.

Trudeau defends the sexual practices of Canadians, uttering the statement that made him famous. 2:21

Former prime minister and then-PC MP John Diefenbaker slammed the bill.

"I cannot understand why matters like legalizing adult homosexuality or extending the field of abortion will raise the moral standards of any nation," he said.

Quebec became the first province to include sexual orientation in its Human Rights Code in 1977, making it illegal to discriminate in housing, public accommodation and employment based on sexual orientation.

The Canadian Human Rights Commission recommended sexual orientation be added to the Canadian Human Rights Act in 1979, but that didn't happen until 1996.

Discrimination persisted for decades

Despite homosexuality being removed from the Criminal Code, discrimination against LGBT military and public service members persisted for decades, particularly in the military.

A military directive specifically banning homosexuality in the ranks was passed in an overhaul of the system in 1976.

​It wasn't until the mid-1980s that members were required to consent to being discharged because of their sexuality. Those that did not agree were allowed to remain, but had career limitations put in place.

In August 1992, the Ontario Court of Appeals ruled that the failure to include sexual orientation in the Canadian Human Rights Act was discriminatory. The ban on LGBT individuals in the military was lifted in November that year.

In October 2016, the House of Commons defence committee voted unanimously for the Liberal government to order the military ombudsman to amend the service records of LGBT ex-military members who were given dishonourable discharges because of their sexual orientation.

Canada's military ombudsman estimated that such an order would affect up to 1,200 service members.​