Refactor to reduce config in group_vars
This commit is contained in:
@@ -1,22 +1,29 @@
|
||||
---
|
||||
- name: Deploy quadlet app configs
|
||||
ansible.builtin.include_tasks: ../../deploy_files.yml
|
||||
- name: Load all quadlet app definitions
|
||||
ansible.builtin.set_fact:
|
||||
quadlets_apps: "{{ quadlets_apps | default([]) + [lookup('file', item.path) | from_yaml] }}"
|
||||
loop: "{{ lookup('ansible.builtin.find', role_path, patterns='*.yml', excludes='quadlets.yml').files }}"
|
||||
|
||||
- name: Deploy app configs from metadata
|
||||
ansible.builtin.template:
|
||||
content: "{{ item.1.template }}"
|
||||
dest: "{{ target_root }}/{{ item.1.path }}"
|
||||
mode: '0644'
|
||||
loop: "{{ quadlets_apps | subelements('configs', skip_missing=True) }}"
|
||||
vars:
|
||||
var_prefix: quadlets
|
||||
subdir: ''
|
||||
target_root: "{{ ansible_facts.env.HOME }}/.config"
|
||||
use_symlinks: false
|
||||
become_root: false
|
||||
when: quadlets_deploy_configs | default(false)
|
||||
is_root_config: "{{ item.0.metadata.user | default('home') in ['service', 'root'] }}"
|
||||
target_root: "{{ is_root_config | ternary('', ansible_facts.env.HOME) }}"
|
||||
become: "{{ is_root_config }}"
|
||||
when: item.1.template is defined
|
||||
|
||||
- name: Initialize quadlet specs
|
||||
ansible.builtin.set_fact:
|
||||
quadlets_all_specs: []
|
||||
|
||||
- name: Load all quadlet definitions
|
||||
- name: Extract quadlet specs from app definitions
|
||||
ansible.builtin.set_fact:
|
||||
quadlets_all_specs: "{{ quadlets_all_specs + (lookup('file', item.path) | from_yaml) }}"
|
||||
loop: "{{ lookup('ansible.builtin.find', role_path, patterns='quadlets.yml', recurse=yes).files }}"
|
||||
quadlets_all_specs: "{{ quadlets_all_specs + item.1 }}"
|
||||
loop: "{{ quadlets_apps | subelements('quadlets', skip_missing=True) }}"
|
||||
|
||||
- name: Build final quadlet specs with pod injection
|
||||
ansible.builtin.set_fact:
|
||||
|
||||
Reference in New Issue
Block a user