@ -1148,6 +1148,18 @@ class DnfModule(YumDnf):
self . module . exit_json ( * * response )
self . module . exit_json ( * * response )
else :
else :
response [ ' changed ' ] = True
response [ ' changed ' ] = True
# If packages got installed/removed, add them to the results.
# We do this early so we can use it for both check_mode and not.
if self . download_only :
install_action = ' Downloaded '
else :
install_action = ' Installed '
for package in self . base . transaction . install_set :
response [ ' results ' ] . append ( " {0} : {1} " . format ( install_action , package ) )
for package in self . base . transaction . remove_set :
response [ ' results ' ] . append ( " Removed: {0} " . format ( package ) )
if failure_response [ ' failures ' ] :
if failure_response [ ' failures ' ] :
failure_response [ ' msg ' ] = ' Failed to install some of the specified packages '
failure_response [ ' msg ' ] = ' Failed to install some of the specified packages '
self . module . fail_json ( * * failure_response )
self . module . fail_json ( * * failure_response )
@ -1188,15 +1200,11 @@ class DnfModule(YumDnf):
self . module . fail_json ( msg )
self . module . fail_json ( msg )
if self . download_only :
if self . download_only :
for package in self . base . transaction . install_set :
# No further work left to do, and the results were already updated above.
response [ ' results ' ] . append ( " Downloaded: {0} " . format ( package ) )
# Just return them.
self . module . exit_json ( * * response )
self . module . exit_json ( * * response )
else :
else :
self . base . do_transaction ( )
self . base . do_transaction ( )
for package in self . base . transaction . install_set :
response [ ' results ' ] . append ( " Installed: {0} " . format ( package ) )
for package in self . base . transaction . remove_set :
response [ ' results ' ] . append ( " Removed: {0} " . format ( package ) )
if failure_response [ ' failures ' ] :
if failure_response [ ' failures ' ] :
failure_response [ ' msg ' ] = ' Failed to install some of the specified packages '
failure_response [ ' msg ' ] = ' Failed to install some of the specified packages '