Add secret loading from tofu state and infisical

This commit is contained in:
Tobias Reisinger 2026-11-01 14:20:34 +01:00
commit b88054c97e
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE

View file

@ -0,0 +1,40 @@
- name: Login to Infisical
infisical.vault.login:
url: "https://app.infisical.com"
auth_method: universal_auth
universal_auth_client_id: "{{ lookup('env', 'INFISICAL_UNIVERSAL_AUTH_CLIENT_ID') }}"
universal_auth_client_secret: "{{ lookup('env', 'INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET') }}"
register: infisical_login
delegate_to: localhost
check_mode: false
- name: Read all secrets as dictionary
infisical.vault.read_secrets:
login_data: "{{ infisical_login.login_data }}"
project_id: "{{ lookup('env', 'TF_VAR_infisical_workspace_id') }}"
env_slug: "prod"
path: "/ansible"
as_dict: false
register: secrets
delegate_to: localhost
check_mode: false
- name: Export secrets as vars
ansible.builtin.set_fact:
"{{ item.key }}": "{{ item.value }}"
loop: "{{ secrets.secrets }}"
loop_control:
label: "{{ item.key }}"
no_log: true
- name: Load the opentofu output
set_fact:
opentofu: "{{ opentofu | default({}) | combine({ item.key: item.value.value }) }}"
loop: "{{ lookup('cloud.terraform.tf_output', binary_path='bin/tofu') | dict2items }}"
loop_control:
label: "{{ item.key }}"
no_log: true
- name: Set variables from opentofu output
ansible.builtin.set_fact:
all_services: "{{ opentofu.services }}"