pass check mode if no namespace
@@ -60,9 +60,6 @@ options:
description:
- name of the secret engine mount name.
default: azure
- subscription_id:
- description:
- - azure SPN subscription id
tenant_id:
description:
- azure SPN tenant id
@@ -89,7 +86,6 @@ EXAMPLES = '''
- hosts: localhost
tasks:
- hashivault_azure_auth_config:
- subscription_id: 1234
tenant_id: 5689-1234
client_id: 1012-1234
client_secret: 1314-1234
@@ -128,6 +124,7 @@ def hashivault_azure_auth_config(module):
mount_point = params.get('mount_point')
desired_state = dict()
current_state = dict()
+ enabled_methods = list()
# do not want a trailing slash in mount_point
if mount_point[-1]:
@@ -148,11 +145,17 @@ def hashivault_azure_auth_config(module):
desired_state['resource'] = params.get('resource')
desired_state['environment'] = params.get('environment')
- # check if engine is enabled
- if (mount_point + "/") not in client.sys.list_auth_methods()['data'].keys():
+ # check if mount exists
+ # if errors but check mode is enabled then pass as "changed"
+ # while this is technically incorrect, its more likely helpful than hurtful
+ try:
+ enabled_methods = client.sys.list_auth_methods()['data'].keys()
+ if (mount_point + "/") not in enabled_methods:
return {'failed': True, 'msg': 'auth mount is not enabled', 'rc': 1}
+ except:
+ if module.check_mode:
+ changed = True
- # check if any config exists
try:
current_state = client.auth.azure.read_config()
except:
