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

How to use returned secrets #6

Open
xtream1101 opened this issue Sep 6, 2024 · 1 comment
Open

How to use returned secrets #6

xtream1101 opened this issue Sep 6, 2024 · 1 comment

Comments

@xtream1101
Copy link

I have having a hard time figuring out how to use the returned secrets because the format is not what I would expect them to be in.

Example:

- hosts: all

  vars:
    secrets: "{{ lookup('infisical.vault.read_secrets', project_id='<>', path='/', env_slug='prod') }}"
    mysecret: "{{ lookup('infisical.vault.read_secrets', project_id='<>', path='/', secret_name='mysecret', env_slug='prod') }}"

  tasks:
    - name: debug all secrets
      debug:
        var: secrets
        # [{"key": "mysecret", "value": "****"},{"key": "another_secret","value": "****"}]

    - name: debug my secret
      debug:
        var: mysecret
        # {"key": "mysecret", "value": "****"}

They are being returned as per the readme as seen in the comments under each debug, but when looking up all secrets in a path how are you expected to use that value?

Given the examples above, I would expect the lookup to return

secrets would be {"mysecret": "****", "another_secret": "****"}. That way you could just access secrets.mysecret, and mysecret would just be the secret value returned directly

If I am mis-understanding on how to use these values that are returned please let me know too.

@etoosamoe
Copy link

Hi! I'm using it like this:

gitlab_smtp_password: >-
  {{ lookup('infisical.vault.read_secrets',
    universal_auth_client_id=infisical_client_auth_id,
    universal_auth_client_secret=infisical_client_access_token,
    project_id=infisical_infra_project_id,
    path='/',
    env_slug='infra',
    secret_name='MAILGUN_SMTP_PASSWORD',
    url=infisical_url
  ) }}

Variables like infisical_client_auth_id or infisical_url I set up in group_vars in inventory.
And then, I use secrets in Jinja templates like "{{ gitlab_smtp_password.value }}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants