# SPDX-License-Identifier: MIT
- name: 'Copy non-templated bash include files'
  loop_control:
    label: 'Non-templated file ''{{ item | basename }}'''
  loop: '{{ lookup(''ansible.builtin.fileglob'', ''root/.config/bash/bashrc-includes.d/system_'' + ansible_facts[''system''] | lower + ''_*'', ''root/.config/bash/bashrc-includes.d/os_family_'' + ansible_facts[''os_family''] | lower + ''_*'', wantlist=True) }}'
  ansible.builtin.copy:
    src: '{{ item }}'
    dest: '{% if local_account != ''root'' %}/home{% endif %}/{{ local_account }}/.config/bash/bashrc-includes.d/'
    owner: '{{ local_account }}'
    group: '{{ local_account }}'

- name: 'Copy templated bash include files'
  loop_control:
    label: 'Templated file ''{{ item | basename }}'' --> ''{{ item | basename | regex_search(''.+?(?=\.j2)'') }}'''
  loop: '{{ lookup(''ansible.builtin.fileglob'', ''../templates/root/.config/bash/bashrc-includes.d/system_'' + ansible_facts[''system''] | lower + ''_*.j2'', ''../templates/root/.config/bash/bashrc-includes.d/os_family_'' + ansible_facts[''os_family''] | lower + ''_*.j2'', wantlist=True) }}'
  ansible.builtin.template:
    src: '{{ item }}'
    dest: '{% if local_account != ''root'' %}/home{% endif %}/{{ local_account }}/.config/bash/bashrc-includes.d/{{ item | basename | regex_search(''.+?(?=\.j2)'') }}'
    owner: '{{ local_account }}'
    group: '{{ local_account }}'