|
| 1 | +--- |
| 2 | +# Build proper dict variables for *_by_host configuration to avoid string literals |
| 3 | +# This fixes the bug where these variables would evaluate to malformed strings |
| 4 | +# like '{ }\n\n ' instead of empty dicts when conditions are false |
| 5 | + |
| 6 | +- name: Build static_dir_by_host dict |
| 7 | + set_fact: |
| 8 | + _galaxy_static_dir_by_host_dict: >- |
| 9 | + {{ |
| 10 | + _galaxy_static_dir_by_host_dict | default({}) | |
| 11 | + combine({ |
| 12 | + (subdomain.name ~ '.' ~ galaxy_themes_instance_domain): (galaxy_themes_static_path ~ '/static-' ~ subdomain.name ~ '/') |
| 13 | + }) |
| 14 | + }} |
| 15 | + loop: "{{ galaxy_themes_subdomains }}" |
| 16 | + loop_control: |
| 17 | + loop_var: subdomain |
| 18 | + when: galaxy_manage_subdomain_static |
| 19 | + |
| 20 | +- name: Add base domain to static_dir_by_host dict |
| 21 | + set_fact: |
| 22 | + _galaxy_static_dir_by_host_dict: >- |
| 23 | + {{ |
| 24 | + _galaxy_static_dir_by_host_dict | default({}) | |
| 25 | + combine({galaxy_themes_instance_domain: (galaxy_static_dir ~ '/')}) |
| 26 | + }} |
| 27 | + when: galaxy_manage_subdomain_static |
| 28 | + |
| 29 | +- name: Build static_images_dir_by_host dict |
| 30 | + set_fact: |
| 31 | + _galaxy_static_images_dir_by_host_dict: >- |
| 32 | + {{ |
| 33 | + _galaxy_static_images_dir_by_host_dict | default({}) | |
| 34 | + combine({ |
| 35 | + (subdomain.name ~ '.' ~ galaxy_themes_instance_domain): (galaxy_themes_static_path ~ '/static-' ~ subdomain.name ~ '/images') |
| 36 | + }) |
| 37 | + }} |
| 38 | + loop: "{{ galaxy_themes_subdomains }}" |
| 39 | + loop_control: |
| 40 | + loop_var: subdomain |
| 41 | + when: galaxy_manage_subdomain_static |
| 42 | + |
| 43 | +- name: Add base domain to static_images_dir_by_host dict |
| 44 | + set_fact: |
| 45 | + _galaxy_static_images_dir_by_host_dict: >- |
| 46 | + {{ |
| 47 | + _galaxy_static_images_dir_by_host_dict | default({}) | |
| 48 | + combine({galaxy_themes_instance_domain: (galaxy_static_dir ~ '/images')}) |
| 49 | + }} |
| 50 | + when: galaxy_manage_subdomain_static |
| 51 | + |
| 52 | +- name: Build static_welcome_html_by_host dict |
| 53 | + set_fact: |
| 54 | + _galaxy_static_welcome_html_by_host_dict: >- |
| 55 | + {{ |
| 56 | + _galaxy_static_welcome_html_by_host_dict | default({}) | |
| 57 | + combine({ |
| 58 | + (subdomain.name ~ '.' ~ galaxy_themes_instance_domain): (galaxy_themes_static_path ~ '/static-' ~ subdomain.name ~ '/welcome.html') |
| 59 | + }) |
| 60 | + }} |
| 61 | + loop: "{{ galaxy_themes_subdomains }}" |
| 62 | + loop_control: |
| 63 | + loop_var: subdomain |
| 64 | + when: galaxy_manage_subdomain_static |
| 65 | + |
| 66 | +- name: Add base domain to static_welcome_html_by_host dict |
| 67 | + set_fact: |
| 68 | + _galaxy_static_welcome_html_by_host_dict: >- |
| 69 | + {{ |
| 70 | + _galaxy_static_welcome_html_by_host_dict | default({}) | |
| 71 | + combine({galaxy_themes_instance_domain: (galaxy_static_dir ~ '/welcome.html')}) |
| 72 | + }} |
| 73 | + when: galaxy_manage_subdomain_static |
| 74 | + |
| 75 | +- name: Build static_scripts_dir_by_host dict |
| 76 | + set_fact: |
| 77 | + _galaxy_static_scripts_dir_by_host_dict: >- |
| 78 | + {{ |
| 79 | + _galaxy_static_scripts_dir_by_host_dict | default({}) | |
| 80 | + combine({ |
| 81 | + (subdomain.name ~ '.' ~ galaxy_themes_instance_domain): (galaxy_themes_static_path ~ '/static-' ~ subdomain.name ~ '/scripts') |
| 82 | + }) |
| 83 | + }} |
| 84 | + loop: "{{ galaxy_themes_subdomains }}" |
| 85 | + loop_control: |
| 86 | + loop_var: subdomain |
| 87 | + when: galaxy_manage_subdomain_static |
| 88 | + |
| 89 | +- name: Add base domain to static_scripts_dir_by_host dict |
| 90 | + set_fact: |
| 91 | + _galaxy_static_scripts_dir_by_host_dict: >- |
| 92 | + {{ |
| 93 | + _galaxy_static_scripts_dir_by_host_dict | default({}) | |
| 94 | + combine({galaxy_themes_instance_domain: (galaxy_static_dir ~ '/scripts')}) |
| 95 | + }} |
| 96 | + when: galaxy_manage_subdomain_static |
| 97 | + |
| 98 | +- name: Build static_favicon_dir_by_host dict |
| 99 | + set_fact: |
| 100 | + _galaxy_static_favicon_dir_by_host_dict: >- |
| 101 | + {{ |
| 102 | + _galaxy_static_favicon_dir_by_host_dict | default({}) | |
| 103 | + combine({ |
| 104 | + (subdomain.name ~ '.' ~ galaxy_themes_instance_domain): (galaxy_themes_static_path ~ '/static-' ~ subdomain.name) |
| 105 | + }) |
| 106 | + }} |
| 107 | + loop: "{{ galaxy_themes_subdomains }}" |
| 108 | + loop_control: |
| 109 | + loop_var: subdomain |
| 110 | + when: galaxy_manage_subdomain_static |
| 111 | + |
| 112 | +- name: Add base domain to static_favicon_dir_by_host dict |
| 113 | + set_fact: |
| 114 | + _galaxy_static_favicon_dir_by_host_dict: >- |
| 115 | + {{ |
| 116 | + _galaxy_static_favicon_dir_by_host_dict | default({}) | |
| 117 | + combine({galaxy_themes_instance_domain: galaxy_static_dir}) |
| 118 | + }} |
| 119 | + when: galaxy_manage_subdomain_static |
| 120 | + |
| 121 | +- name: Build static_robots_txt_by_host dict |
| 122 | + set_fact: |
| 123 | + _galaxy_static_robots_txt_by_host_dict: >- |
| 124 | + {{ |
| 125 | + _galaxy_static_robots_txt_by_host_dict | default({}) | |
| 126 | + combine({ |
| 127 | + (subdomain.name ~ '.' ~ galaxy_themes_instance_domain): (galaxy_themes_static_path ~ '/static-' ~ subdomain.name) |
| 128 | + }) |
| 129 | + }} |
| 130 | + loop: "{{ galaxy_themes_subdomains }}" |
| 131 | + loop_control: |
| 132 | + loop_var: subdomain |
| 133 | + when: galaxy_manage_subdomain_static |
| 134 | + |
| 135 | +- name: Add base domain to static_robots_txt_by_host dict |
| 136 | + set_fact: |
| 137 | + _galaxy_static_robots_txt_by_host_dict: >- |
| 138 | + {{ |
| 139 | + _galaxy_static_robots_txt_by_host_dict | default({}) | |
| 140 | + combine({galaxy_themes_instance_domain: galaxy_static_dir}) |
| 141 | + }} |
| 142 | + when: galaxy_manage_subdomain_static |
| 143 | + |
| 144 | +- name: Build themes_config_file_by_host dict for subdomains |
| 145 | + set_fact: |
| 146 | + _galaxy_themes_config_file_by_host_dict: >- |
| 147 | + {{ |
| 148 | + _galaxy_themes_config_file_by_host_dict | default({}) | |
| 149 | + combine({ |
| 150 | + (subdomain.name ~ '.' ~ galaxy_themes_instance_domain): ('themes_conf-' ~ subdomain.name ~ '.yml') |
| 151 | + }) |
| 152 | + }} |
| 153 | + loop: "{{ galaxy_themes_subdomains }}" |
| 154 | + loop_control: |
| 155 | + loop_var: subdomain |
| 156 | + when: |
| 157 | + - galaxy_manage_themes |
| 158 | + - galaxy_themes_subdomains | length > 0 |
| 159 | + - subdomain.theme is defined |
| 160 | + |
| 161 | +- name: Add base domain to themes_config_file_by_host dict |
| 162 | + set_fact: |
| 163 | + _galaxy_themes_config_file_by_host_dict: >- |
| 164 | + {{ |
| 165 | + _galaxy_themes_config_file_by_host_dict | default({}) | |
| 166 | + combine({galaxy_themes_instance_domain: (galaxy_config.galaxy.themes_config_file | default((galaxy_config_dir, 'themes_conf.yml') | path_join))}) |
| 167 | + }} |
| 168 | + when: |
| 169 | + - galaxy_manage_themes |
| 170 | + - galaxy_themes_subdomains | length > 0 |
| 171 | + |
| 172 | +- name: Build brand_by_host dict |
| 173 | + set_fact: |
| 174 | + _galaxy_brand_by_host_dict: >- |
| 175 | + {{ |
| 176 | + _galaxy_brand_by_host_dict | default({}) | |
| 177 | + combine({ |
| 178 | + (subdomain.name ~ '.' ~ galaxy_themes_instance_domain): (subdomain.name[0]|upper ~ subdomain.name[1:]) |
| 179 | + }) |
| 180 | + }} |
| 181 | + loop: "{{ galaxy_themes_subdomains }}" |
| 182 | + loop_control: |
| 183 | + loop_var: subdomain |
| 184 | + when: galaxy_auto_brand |
| 185 | + |
| 186 | +- name: Add base domain to brand_by_host dict |
| 187 | + set_fact: |
| 188 | + _galaxy_brand_by_host_dict: >- |
| 189 | + {{ |
| 190 | + _galaxy_brand_by_host_dict | default({}) | |
| 191 | + combine({galaxy_themes_instance_domain: galaxy_themes_instance_domain}) |
| 192 | + }} |
| 193 | + when: galaxy_auto_brand |
| 194 | + |
| 195 | +- name: Override galaxy_app_config_default with proper dict values |
| 196 | + set_fact: |
| 197 | + galaxy_app_config_default: >- |
| 198 | + {{ |
| 199 | + galaxy_app_config_default | |
| 200 | + combine({ |
| 201 | + 'static_dir_by_host': _galaxy_static_dir_by_host_dict | default({}), |
| 202 | + 'static_images_dir_by_host': _galaxy_static_images_dir_by_host_dict | default({}), |
| 203 | + 'static_welcome_html_by_host': _galaxy_static_welcome_html_by_host_dict | default({}), |
| 204 | + 'static_scripts_dir_by_host': _galaxy_static_scripts_dir_by_host_dict | default({}), |
| 205 | + 'static_favicon_dir_by_host': _galaxy_static_favicon_dir_by_host_dict | default({}), |
| 206 | + 'static_robots_txt_by_host': _galaxy_static_robots_txt_by_host_dict | default({}), |
| 207 | + 'themes_config_file_by_host': _galaxy_themes_config_file_by_host_dict | default({}), |
| 208 | + 'brand_by_host': _galaxy_brand_by_host_dict | default({}) |
| 209 | + }) |
| 210 | + }} |
0 commit comments