diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_domain.py b/lib/ansible/modules/network/nxos/nxos_vtp_domain.py index 046cc8d5fcf..e6e1352e166 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_domain.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_domain.py @@ -149,10 +149,13 @@ def get_vtp_config(module): def get_vtp_password(module): command = 'show vtp password' body = execute_show_command(command, module)[0] - password = body['passwd'] - if password: - return str(password) - else: + try: + password = body['passwd'] + if password: + return str(password) + else: + return "" + except TypeError: return "" diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_password.py b/lib/ansible/modules/network/nxos/nxos_vtp_password.py index 73f03967387..e21ed47c4c0 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_password.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_password.py @@ -180,10 +180,13 @@ def get_vtp_config(module): def get_vtp_password(module): command = 'show vtp password' body = execute_show_command(command, module)[0] - password = body['passwd'] - if password: - return str(password) - else: + try: + password = body['passwd'] + if password: + return str(password) + else: + return "" + except TypeError: return "" diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_version.py b/lib/ansible/modules/network/nxos/nxos_vtp_version.py index e4782eb7b51..33eeef07e94 100644 --- a/lib/ansible/modules/network/nxos/nxos_vtp_version.py +++ b/lib/ansible/modules/network/nxos/nxos_vtp_version.py @@ -147,10 +147,13 @@ def get_vtp_config(module): def get_vtp_password(module): command = 'show vtp password' body = execute_show_command(command, module)[0] - password = body['passwd'] - if password: - return str(password) - else: + try: + password = body['passwd'] + if password: + return str(password) + else: + return "" + except TypeError: return ""