Add secret loading from tofu state and infisical
This commit is contained in:
parent
a46646ae5f
commit
b88054c97e
1 changed files with 48 additions and 0 deletions
40
playbooks/tasks/load-secrets.yml
Normal file
40
playbooks/tasks/load-secrets.yml
Normal 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 }}"
|
||||
Loading…
Reference in a new issue