From 3d1ea3e79ea9a89c05d022ef6a75f2a9dc897a9b Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sun, 27 Nov 2022 10:10:00 +0200 Subject: [PATCH] Auto-delete old matrix scripts from /usr/local/bin --- .../tasks/cleanup_usr_local_bin.yml | 14 ++++++++++++++ .../matrix_playbook_migration/tasks/main.yml | 6 ++++++ 2 files changed, 20 insertions(+) create mode 100644 roles/custom/matrix_playbook_migration/tasks/cleanup_usr_local_bin.yml diff --git a/roles/custom/matrix_playbook_migration/tasks/cleanup_usr_local_bin.yml b/roles/custom/matrix_playbook_migration/tasks/cleanup_usr_local_bin.yml new file mode 100644 index 00000000..e7abd471 --- /dev/null +++ b/roles/custom/matrix_playbook_migration/tasks/cleanup_usr_local_bin.yml @@ -0,0 +1,14 @@ +--- + +- name: Find leftover matrix scripts in /usr/local/bin + ansible.builtin.find: + path: "/usr/local/bin" + patterns: "^matrix-.*" + use_regex: true + register: matrix_usr_local_bin_files_result + +- name: Ensure /usr/local/bin does not contain matrix scripts + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + with_items: "{{ matrix_usr_local_bin_files_result.files }}" diff --git a/roles/custom/matrix_playbook_migration/tasks/main.yml b/roles/custom/matrix_playbook_migration/tasks/main.yml index 491fabcd..96b68b60 100644 --- a/roles/custom/matrix_playbook_migration/tasks/main.yml +++ b/roles/custom/matrix_playbook_migration/tasks/main.yml @@ -5,3 +5,9 @@ tags: - setup-all - install-all + +- block: + - ansible.builtin.include_tasks: "{{ role_path }}/tasks/cleanup_usr_local_bin.yml" + tags: + - setup-all + - install-all