From 3ca2a472b7394886ba4390f6887e87d436e22380 Mon Sep 17 00:00:00 2001 From: Chewbaccalakis Date: Thu, 25 Jun 2026 12:42:02 -0700 Subject: [PATCH] updated to create api key and add to infisical --- ansible/plays/machine_setup/technitium.yml | 43 ++++++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/ansible/plays/machine_setup/technitium.yml b/ansible/plays/machine_setup/technitium.yml index f19798d..2f00731 100644 --- a/ansible/plays/machine_setup/technitium.yml +++ b/ansible/plays/machine_setup/technitium.yml @@ -136,7 +136,7 @@ when: dns_service_file.stat.exists - name: First-time service setup - when: not dns_service_file.stat.exists + #when: not dns_service_file.stat.exists #temp change block: - name: Create DNS log directory ansible.builtin.file: @@ -258,8 +258,43 @@ method: GET body_format: form-urlencoded body: - token: "{{ technitium_login.json.response.token }}" - pass: "{{ technitium_pass_raw.user_input }}" - no_log: true + token: "{{ technitium_login.json.token }}" + pass: admin + newPass: "{{ technitium_pass_raw.user_input }}" + no_log: false # temp change failed_when: technitium_change_pass.json.status != 'ok' register: technitium_change_pass + + - name: Create Terraform API token + ansible.builtin.uri: + url: "http://localhost:5380/api/user/createToken" + method: GET + body_format: form-urlencoded + body: + token: "{{ technitium_login.json.token }}" + tokenName: terraform + register: technitium_terraform_token + no_log: true + failed_when: technitium_terraform_token.json.status != 'ok' + + - name: Read secrets.tmpl to get Infisical connection details + ansible.builtin.slurp: + src: "{{ playbook_dir }}/../../../secrets.tmpl" + delegate_to: localhost + become: false + register: secrets_tmpl_raw + + - name: Parse Infisical project ID, env, and path from secrets.tmpl + ansible.builtin.set_fact: + infisical_params: >- + {{ (secrets_tmpl_raw.content | b64decode).split('\n')[0] | regex_findall('"([^"]+)"') }} + + - name: Store Terraform API token in Infisical + ansible.builtin.command: > + infisical secrets set TECHNITIUM_API_TOKEN="{{ technitium_terraform_token.json.token }}" + --projectId="{{ infisical_params[0] }}" + --env="{{ infisical_params[1] }}" + --path="{{ infisical_params[2] }}" + delegate_to: localhost + become: false + no_log: false # temp change