Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashi_vault: allow mount_point for approle auth #46352

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/ansible/plugins/lookup/hashi_vault.py
Expand Up @@ -181,10 +181,11 @@ def auth_ldap(self, **kwargs):
raise AnsibleError("Authentication method ldap requires a password")

mount_point = kwargs.get('mount_point')
if mount_point is None:
mount_point = 'ldap'

self.client.auth_ldap(username, password, mount_point)
if not mount_point:
self.client.auth_ldap(username, password)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to alter the default behavior of the module or is the mount_point = 'ldap' inferred by client.auth_ldap ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default mount_point will stay ldap.
This module is using hvac as library and ldap is the default mount point if not specified:

            DEFAULT_MOUNT_POINT = 'ldap'
...
            def login(self, username, password, use_token=True, mount_point=DEFAULT_MOUNT_POINT):

https://github.com/hvac/hvac/blob/5b42620ddac5474574eb98437d2645dade1824c1/hvac/api/auth_methods/ldap.py#L8
https://github.com/hvac/hvac/blob/5b42620ddac5474574eb98437d2645dade1824c1/hvac/api/auth_methods/ldap.py#L355

else:
self.client.auth_ldap(username, password, mount_point)

def boolean_or_cacert(self, validate_certs, cacert):
validate_certs = boolean(validate_certs, strict=False)
Expand All @@ -206,7 +207,12 @@ def auth_approle(self, **kwargs):
if secret_id is None:
raise AnsibleError("Authentication method app role requires a secret_id")

self.client.auth_approle(role_id, secret_id)
mount_point = kwargs.get('mount_point')

if not mount_point:
self.client.auth_approle(role_id, secret_id)
else:
self.client.auth_approle(role_id, secret_id, mount_point)


class LookupModule(LookupBase):
Expand Down