<commit_before>---
## ---------------------------
## Move in configuration files
## ---------------------------
- name: find dotfiles to link to ~
  find:
    paths: files/home/
    recurse: yes
    excludes: "{{ dotfile_blacklist | default(omit) }}"
  register: home_files

- name: find templates to import to ~
  find:
    paths: templates/home/
    recurse: yes
    excludes: "{{ dotfile_blacklist | default(omit) }}"
  register: home_templates

- name: find dotfiles to link to /etc
  find:
    paths: files/etc/
    recurse: yes
    excludes: "{{ dotfile_blacklist | default(omit) }}"
  register: etc_files

- name: find templates to import to /etc
  find:
    paths: templates/etc/
    recurse: yes
    excludes: "{{ dotfile_blacklist | default(omit) }}"
  register: etc_templates

- name: find directories to create
  find:
    file_type: directory
    paths:
      - files/home/
      - templates/home/
    recurse: yes
  register: home_dirs

- name: ensure directories exist
  file:
    dest: "{{ ansible_user_dir }}/.{{ item.path | regex_replace('^(templates|files)/home/', '') }}"
    state: directory
  loop: "{{ home_dirs.files }}"
  # if a blacklist is defined, use it, otherwise create all directories
  when: directory_blacklist is not defined or item.path is not search(directory_blacklist | join('|'))

- name: link dotfiles to home directory
  file:
    src: "{{ item.path | realpath }}"
    dest: "{{ ansible_user_dir }}/.{{ item.path | relpath('files/home') }}"
    state: link
  loop: "{{ home_files.files }}"

- name: import dotfile templates to home directory
  template:
    src: "{{ item.path }}"
    dest: "{{ ansible_user_dir }}/.{{ item.path | relpath('templates/home') | splitext | first }}"
    backup: yes
    mode: "{{ item.mode }}"
  loop: "{{ home_templates.files }}"

- name: link dotfiles to etc directory
  become: yes
  file:
    src: "{{ item.path | realpath }}"
    dest: "/etc/{{ item.path | relpath('files/etc') }}"
    state: link
  loop: "{{ etc_files.files }}"

- name: import dotfile templates to etc directory
  become: yes
  template:
    src: "{{ item.path }}"
    dest: "/etc/{{ item.path | relpath('templates/etc') | splitext | first }}"
    backup: yes
  loop: "{{ etc_templates.files }}"

- name: link system files
  become: yes
  file:
    src: "{{ item.value }}"
    dest: "{{ item.key }}"
    state: link
    force: yes
  loop: "{{ symlinks | dict2items }}"
  when: ansible_distribution != 'MacOSX'<commit_msg>Combine tasks for finding files/templates<commit_after>---
## ---------------------------
## Move in configuration files
## ---------------------------
- name: find dotfiles to link to ~
  find:
    paths:
      - files/home/
      - templates/home/
    recurse: yes
    excludes: "{{ dotfile_blacklist | default(omit) }}"
  register: home_files

- name: find dotfiles to link to /etc
  find:
    paths:
      - files/etc/
      - templates/etc/
    recurse: yes
    excludes: "{{ dotfile_blacklist | default(omit) }}"
  register: etc_files

- name: find directories to create
  find:
    file_type: directory
    paths:
      - files/home/
      - templates/home/
    recurse: yes
  register: home_dirs

- name: ensure directories exist
  file:
    dest: "{{ ansible_user_dir }}/.{{ item.path | regex_replace('^(templates|files)/home/', '') }}"
    state: directory
  loop: "{{ home_dirs.files }}"
  loop_control:
    label: "{{ item.path }}"
  # if a blacklist is defined, use it, otherwise create all directories
  when: directory_blacklist is not defined or item.path is not search(directory_blacklist | join('|'))

- name: link dotfiles to home directory
  file:
    src: "{{ item.path | realpath }}"
    dest: "{{ ansible_user_dir }}/.{{ item.path | relpath('files/home') }}"
    state: link
  loop: "{{ home_files.files }}"
  loop_control:
    label: "{{ item.path }}"
  when: item.path | splitext | last != '.j2'

- name: import dotfile templates to home directory
  template:
    src: "{{ item.path }}"
    dest: "{{ ansible_user_dir }}/.{{ item.path | relpath('templates/home') | splitext | first }}"
    backup: yes
    mode: "{{ item.mode }}"
  loop: "{{ home_files.files }}"
  loop_control:
    label: "{{ item.path }}"
  when: item.path | splitext | last == '.j2'

- name: link dotfiles to etc directory
  become: yes
  file:
    src: "{{ item.path | realpath }}"
    dest: "/etc/{{ item.path | relpath('files/etc') }}"
    state: link
  loop: "{{ etc_files.files }}"
  loop_control:
    label: "{{ item.path }}"
  when: item.path | splitext | last != '.j2'

- name: import dotfile templates to etc directory
  become: yes
  template:
    src: "{{ item.path }}"
    dest: "/etc/{{ item.path | relpath('templates/etc') | splitext | first }}"
    backup: yes
  loop: "{{ etc_files.files }}"
  loop_control:
    label: "{{ item.path }}"
  when: item.path | splitext | last == '.j2'

- name: link system files
  become: yes
  file:
    src: "{{ item.value }}"
    dest: "{{ item.key }}"
    state: link
    force: yes
  loop: "{{ symlinks | dict2items }}"
  when: ansible_distribution != 'MacOSX'
{'fraction_non_alphanumeric': 0.17228464419475656, 'fraction_numerical': 0.0011827321111768185, 'mean_word_length': 2.761304670126019, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3904372', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1685, 'n_words': 455}