From 928f9b2cfc378f88e4be7de6d77ef0fdd587653e Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 1 Jul 2025 12:56:14 +0100 Subject: [PATCH] Loop over old neovim stow directories --- roles/neovim/tasks/Debian.yaml | 24 +++++------------------- roles/neovim/tasks/sudo-rmdir.yaml | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 roles/neovim/tasks/sudo-rmdir.yaml diff --git a/roles/neovim/tasks/Debian.yaml b/roles/neovim/tasks/Debian.yaml index fc47090..de22b24 100644 --- a/roles/neovim/tasks/Debian.yaml +++ b/roles/neovim/tasks/Debian.yaml @@ -10,26 +10,12 @@ state: absent - set_fact: - old_package_dir: '/usr/local/lib/nvim/nvim-linux-x86_64' + old_package_dirs: + - /usr/local/lib/nvim/nvim-linux-x86_64 + - /usr/local/stow/nvim/nvim-linux64 -- name: check if old package directory exists - stat: - path: '{{old_package_dir}}' - register: old_package - -- name: uninstall package from old directory - when: old_package.stat.exists - become: true - command: - cmd: 'stow --delete --target /usr/local .' - chdir: '{{old_package_dir}}' - -- name: remove old package directory - when: old_package.stat.exists - become: true - file: - state: absent - path: '{{old_package_dir}}' +- include_tasks: sudo-rmdir.yaml + with_items: '{{old_package_dirs}}' - name: install gnu stow for managing tar.gz package become: true diff --git a/roles/neovim/tasks/sudo-rmdir.yaml b/roles/neovim/tasks/sudo-rmdir.yaml new file mode 100644 index 0000000..05572a6 --- /dev/null +++ b/roles/neovim/tasks/sudo-rmdir.yaml @@ -0,0 +1,19 @@ +--- +- name: check if {{item}} exists + stat: + path: '{{item}}' + register: old_package + +- name: uninstall package from {{item}} + when: old_package.stat.exists + become: true + command: + cmd: 'stow --delete --target /usr/local .' + chdir: '{{item}}' + +- name: remove {{item}} + when: old_package.stat.exists + become: true + file: + state: absent + path: '{{item}}'