role-common-bash_convenience/tasks/delete_unneeded_bash_include_files.yml

16 lines
802 B
YAML

# SPDX-License-Identifier: MIT
- name: 'For local account ''{{ local_account }}'' get list of bash include files'
changed_when: false
register: 'bashcon_canonical_bashrc_includes_actual'
ansible.builtin.shell: |
ls -1 {% if local_account != 'root' %}/home{% endif %}/{{ local_account }}/.config/bash/bashrc-includes.d
- name: 'For local account ''{{ local_account }}'' delete unneeded bash include files'
when: 'item not in bashcon_canonical_bashrc_includes_desired'
loop_control:
label: 'If unneeded delete bashrc include file ''{{ item }}'''
loop: '{{ bashcon_canonical_bashrc_includes_actual.stdout_lines }}'
ansible.builtin.file:
path: '{% if local_account != ''root'' %}/home{% endif %}/{{ local_account }}/.config/bash/bashrc-includes.d/{{ item }}'
state: 'absent'