Skip to content

Commit

Permalink
testing adding file discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
TechDufus committed Dec 14, 2023
1 parent f722bbc commit afca50a
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions roles/neovim/tasks/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,52 @@
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/.config/nvim/init.lua"
src: "init.lua"
mode: 0644
mode: "0644"

- name: "Neovim | Copy .luarc.json"
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/.config/nvim/.luarc.json"
src: ".luarc.json"
mode: 0644
mode: "0644"

- name: "Neovim | Copy modules"
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/.config/nvim/lua"
src: "lua/"
mode: "0644"

- name: "Neovim | Define base paths"
ansible.builtin.set_fact:
remote_path: "{{ ansible_user_dir }}/.config/nvim/lua"
config_path: "{{ role_path }}/files/lua"

- name: "Neovim | Get config files"
ansible.builtin.find:
paths: "{{ ansible_role_path }}/files/lua"
paths: "{{ role_path }}/files/lua"
file_type: file
recurse: true
register: config_files

- name: Find all remote files
- name: "Neovim | Find all remote files"
ansible.builtin.find:
paths: "{{ ansible_user_dir }}/.config/nvim/lua"
file_type: file
recurse: true
register: existing

- ansible.builtin.debug:
# msg: "{{ item.path | replace('{{ remote_path }}', '') }}"
msg: "{{ item.path }}"
loop: "{{ existing.files | default([]) }}"

- name: "Neovim | Setting File List Facts"
ansible.builtin.set_fact:
config_trimmed_files: "{{ config_files.files | map(attribute='path') | map('regex_replace', config_path, '') | list }}"

- name: "Neovim | Delete any leftover files"
ansible.builtin.file:
path: {{ item.path }}
path: "{{ item.path }}"
state: absent
when: item.path|basename not in config_files.files|map(attribute='path')|list
with_items: "{{existing.files|default([ ])}}"
when: item.path|map('regex_replace', remote_path, '') not in config_trimmed_files
with_items: "{{ existing.files | default([]) }}"
register: removed

0 comments on commit afca50a

Please sign in to comment.