From ba7ba7adc37da383f8a21bdec1e2551c4365a023 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Fri, 7 Apr 2017 15:32:10 +0200 Subject: [PATCH] Check for proper response key on eos_banner map_config_to_obj (#23399) If we run the task with 'login' banner, the 'show banner' command will return a dict containing key 'loginBanner'. However for motd, it will just return 'motd'. Yay naming consistency! --- lib/ansible/modules/network/eos/eos_banner.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/eos/eos_banner.py b/lib/ansible/modules/network/eos/eos_banner.py index 66a11bfc9ea..f07e108a50b 100644 --- a/lib/ansible/modules/network/eos/eos_banner.py +++ b/lib/ansible/modules/network/eos/eos_banner.py @@ -121,8 +121,12 @@ def map_config_to_obj(module): else: # On EAPI we need to extract the banner text from dict key # 'loginBanner' - if isinstance(output[0], dict) and 'loginBanner' in output[0].keys(): - obj['text'] = output[0]['loginBanner'].strip('\n') + if module.params['banner'] == 'login': + banner_response_key = 'loginBanner' + else: + banner_response_key = 'motd' + if isinstance(output[0], dict) and banner_response_key in output[0].keys(): + obj['text'] = output[0][banner_response_key].strip('\n') obj['state'] = 'present' return obj