diff --git a/lib/ansible/modules/network/nxos/nxos_vtp_domain.py b/lib/ansible/modules/network/nxos/nxos_vtp_domain.py index 046cc8d5fc..e6e1352e16 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 73f0396738..e21ed47c4c 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 e4782eb7b5..33eeef07e9 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 ""