diff --git a/lib/ansible/plugins/lookup/hashi_vault.py b/lib/ansible/plugins/lookup/hashi_vault.py index b9f2004eb8..24bad88dfc 100644 --- a/lib/ansible/plugins/lookup/hashi_vault.py +++ b/lib/ansible/plugins/lookup/hashi_vault.py @@ -122,6 +122,8 @@ class HashiVault: else: self.secret_field = '' + self.verify = self.boolean_or_cacert(kwargs.get('validate_certs', True), kwargs.get('cacert', '')) + # If a particular backend is asked for (and its method exists) we call it, otherwise drop through to using # token auth. This means if a particular auth backend is requested and a token is also given, then we # ignore the token and attempt authentication against the specified backend. @@ -150,8 +152,6 @@ class HashiVault: if self.token is None: raise AnsibleError("No Vault Token specified") - self.verify = self.boolean_or_cacert(kwargs.get('validate_certs', True), kwargs.get('cacert', '')) - self.client = hvac.Client(url=self.url, token=self.token, verify=self.verify) if not self.client.is_authenticated():