The experienced soldier, of more than 12 years' service, had been upset at leaving the job he loved, his defence counsel Tony Greig told the court.
He'd been drinking with his partner, when they had an argument and she called the police.
Officers were told that Ottley was drunk and had "immediate access to firearms", so the Armed Offenders Squad was dispatched.
The Explosive Ordinance Disposal Squad and Military Police were also called to the scene.
Ottley, whose firearms license had been revoked, was asleep when armed police arrived, and found the rifle hidden inside a sleeping bag in his bedroom, with bullets in its magazine.
Judge Alistair Garland today raised concerns that the gun appeared to have been kept loaded.
But Mr Greig said there were no bullets in the breach, and that his client - an experienced gun user who handled weapons every day in the Army, "routinely" kept it loaded.
Now that he was unemployed Ottley was keen to do any community work sentence in "double quick time", his lawyer said.
Mr Greig said he'd been discharged from the Army after a drink-driving conviction in February.
In sentencing him to 200 hours of community work, Judge Garland accepted that Ottley kept the gun for hunting purposes and "nothing sinister", but criticised him for his practice of keeping loaded guns in the house.
"You are Army-trained. You should know better than to have any firearms with any bullets at all in them in the home."
The judge ordered the destruction of the rifle, along with the ammunition which had not already been returned to the NZDF.
The NZDF today said it would not take any separate legal action against Ottley.
A spokeswoman stressed that the Army took the theft of property seriously, with several steps in place to ensure that strict sign-offs were followed when personnel were discharged from service.
It also had procedures to safeguard against the theft of ammunition used during training.
"Unfortunately, in this instance the former soldier in question has managed to obtain ammunition, despite the in-place procedures," said the NZDF spokeswoman.
"The NZDF regularly reviews its ammunition procedures to ensure it maintains best practices to enable good training balanced with security and safety requirements."