Skip to content

Commit 1335f6c

Browse files
committedJan 1, 2025
testing
1 parent a58682c commit 1335f6c

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed
 

‎ansible/playbooks/deploy-docker.yml

+9-19
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,17 @@
1717
- name: Generate .env content
1818
vars:
1919
env_variables: "{{ secret_mapping[target_host]['env_variables'] | default({}) }}"
20-
ansible.builtin.shell: |
21-
#!/bin/bash
22-
echo "Generating .env for {{ target_host }} at {{ repo_path }}/.env"
23-
for var in "${!env_variables[@]}"; do
24-
secret_id="${env_variables[$var]}"
25-
if [ -n "$secret_id" ]; then
26-
value=$(bws secret get "$secret_id" | jq -r '.value')
27-
echo "$var=$value"
28-
else
29-
echo "$var="
30-
fi
31-
done
32-
args:
33-
executable: /bin/bash
20+
ansible.builtin.template:
21+
src: env_template.j2
22+
dest: "{{ repo_path }}/.env"
23+
24+
- name: Verify .env file content
25+
ansible.builtin.shell: cat "{{ repo_path }}/.env"
3426
register: env_file_content
3527

36-
- name: Write .env file to target host
37-
ansible.builtin.copy:
38-
dest: "{{ repo_path }}/.env"
39-
content: "{{ env_file_content.stdout }}"
40-
mode: '0644'
28+
- name: Display .env content
29+
ansible.builtin.debug:
30+
var: env_file_content.stdout_lines
4131

4232
- name: Ensure the repository is up-to-date
4333
ansible.builtin.shell: git pull

0 commit comments

Comments
 (0)