---
- name: Remove all aliases from user shell configuration files
  hosts: all
  become: yes
  gather_facts: false

  tasks:
    - name: Find all relevant shell configuration files
      find:
        paths: /home
        patterns: .bashrc, .bash_aliases, .profile
      register: shell_config_files

    - name: Remove aliases from shell configuration files
      replace:
        path: "{{ item.path }}"
        regexp: '^alias .*'
        replace: ''
      loop: "{{ shell_config_files.files }}"
      when: shell_config_files.files is defined

    - name: Remove functions from shell configuration files
      replace:
        path: "{{ item.path }}"
        regexp: '^function .*'
        replace: ''
      loop: "{{ shell_config_files.files }}"
      when: shell_config_files.files is defined

    - name: Display completion message
      debug:
        msg: "All aliases and functions have been removed from user shell configuration files."