File tree 1 file changed +9
-19
lines changed
1 file changed +9
-19
lines changed Original file line number Diff line number Diff line change 17
17
- name : Generate .env content
18
18
vars :
19
19
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"
34
26
register : env_file_content
35
27
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
41
31
42
32
- name : Ensure the repository is up-to-date
43
33
ansible.builtin.shell : git pull
You can’t perform that action at this time.
0 commit comments