[test last]

This commit is contained in:
2025-11-11 17:39:20 +01:00
parent 7228f927a3
commit 79d8bfaacf

View File

@@ -32,24 +32,20 @@
# msg: "{{ bw_client_id }}" # msg: "{{ bw_client_id }}"
# # delegate_to: localhost # # delegate_to: localhost
# #! fin test # #! fin test
- name: Check if bw is installed # - name: Check if bw is installed
command: which bw # command: which bw
register: bw_check # register: bw_check
ignore_errors: yes # ignore_errors: yes
delegate_to: localhost # delegate_to: localhost
changed_when: false # changed_when: false
- name: Install Bitwarden CLI - name: Install Bitwarden CLI
block: ansible.builtin.command:
- name: bitwarden token session cmd: "{{ item }}"
ansible.builtin.command: delegate_to: localhost
cmd: "{{ item }}" loop:
delegate_to: localhost - apk add --no-cache nodejs npm
loop: - npm install -g @bitwarden/cli
- apk add --no-cache nodejs npm
- npm install -g @bitwarden/cli
when: bw_check.rc != 0
- name: bitwarden token session - name: bitwarden token session
ansible.builtin.command: ansible.builtin.command:
@@ -57,13 +53,23 @@
environment: environment:
BW_CLIENTID: "{{ bw_client_id }}" BW_CLIENTID: "{{ bw_client_id }}"
BW_CLIENTSECRET: "{{ bw_client_secret }}" BW_CLIENTSECRET: "{{ bw_client_secret }}"
BW_PASSWORD: "{{ bw_client_password }}"
loop: loop:
- bw config server {{ vaultwarden_url }} - bw config server {{ vaultwarden_url }}
- bw login --apikey - bw login --apikey
- bw unlock {{ bw_client_password }} --raw - bw unlock --passwordenv BW_PASSWORD --raw
delegate_to: localhost delegate_to: localhost
register: bw_session_result register: bw_session_result
- name: Set BW_SESSION as environment variable globally
ansible.builtin.set_fact:
bw_session: "{{ bw_session_result.results[-1].stdout | trim }}"
no_log: true
- name: Return all secrets from a path
ansible.builtin.debug: "{{ bw_session }}"
- name: Utiliser le lookup - name: Utiliser le lookup
ansible.builtin.debug: ansible.builtin.debug:
msg: "{{ lookup('community.general.bitwarden', 'Token full access gitea', field='password') }}" msg: "{{ lookup('community.general.bitwarden', 'Token full access gitea', field='password') }}"