Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make themes structured data instead of read from file #219

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ galaxy_app_config_default:
{ {% if galaxy_manage_themes %}
'{{ galaxy_themes_instance_domain }}': '{{ galaxy_themes_conf_file_name }}',
{% for subdomain in galaxy_themes_subdomains %}
'{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': '{{ subdomain.name }}.yml',
'{{ subdomain.name }}.{{ galaxy_themes_instance_domain}}': 'themes_conf-{{ subdomain.name }}.yml',
{% endfor %}
{% endif %} }
brand_by_host: >
Expand Down
49 changes: 36 additions & 13 deletions tasks/themes.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
---
- name: Append themes_conf.yml to all files in galaxy/config/themes
ansible.builtin.blockinfile:
block: "{{ lookup('ansible.builtin.file', galaxy_themes_conf_path) }}"
path: "{{ galaxy_themes_ansible_file_path }}/{{ subdomain.name }}/themes/{{ subdomain.name }}.yml"
delegate_to: 127.0.0.1

- name: Copy themes files
ansible.builtin.copy:
src: "{{ galaxy_themes_ansible_file_path }}/{{ subdomain.name }}/themes/{{ subdomain.name }}.yml"
dest: "{{ galaxy_config_dir }}"
mode: '0644'
owner: "{{ __galaxy_privsep_user_name }}"
group: "{{ __galaxy_privsep_user_group }}"

- name: Themes setup
block:

- name: Default themes block
when: galaxy_themes is not defined
block:

- name: Load default themes if unset
ansible.builtin.slurp:
src: "{{ (galaxy_server_dir, 'lib/galaxy/config/sample/themes_conf.yml.sample') | path_join }}"
register: __galaxy_themes_config_slurp

- name: Set galaxy_themes
ansible.builtin.set_fact:
galaxy_themes: "{{ __galaxy_themes_config_slurp.content | b64decode | from_yaml }}"

- name: Write default themes config
ansible.builtin.copy:
content: "{{ galaxy_themes | to_yaml }}"
dest: "{{ galaxy_config_merged.themes_config_file | default((galaxy_config_dir, 'themes_conf.yml') | path_join) }}"
mode: "0644"

- name: Write subdomain themes configs
ansible.builtin.copy:
content: |
{% if item.theme is defined %}
{{ item.theme | to_yaml }}
{% endif %}
{{ galaxy_themes | to_yaml }}
dest: "{{ galaxy_config_dir }}/themes_conf-{{ item.name }}.yml"
mode: "0644"
loop: "{{ galaxy_themes_subdomains }}"

remote_user: "{{ galaxy_remote_users.privsep | default(__galaxy_remote_user) }}"
become: "{{ true if galaxy_become_users.privsep is defined else __galaxy_become }}"
become_user: "{{ galaxy_become_users.privsep | default(__galaxy_become_user) }}"
Loading