From fa0ea0098ed3cad46e4a7cf740b4ddb0c1c70b5e Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 6 Apr 2026 15:24:33 -0700 Subject: [PATCH] Only do the metasploit activities if it is not already installed. --- tasks/general/software/metasploit.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tasks/general/software/metasploit.yml b/tasks/general/software/metasploit.yml index 6208e96..3207d8e 100644 --- a/tasks/general/software/metasploit.yml +++ b/tasks/general/software/metasploit.yml @@ -1,13 +1,16 @@ --- # Install Metasploit Framework -# TBD: Check if msfconsole is in PATH and if so skip this reinstallation process. - - name: General | Software | Metasploit | Facts set_fact: metasploit_installer: msfinstall when: ansible_system in ("Linux", "Darwin") +- name: General | Software | Metasploit | Check Install Status + stat: + path: /usr/bin/msfconsole + register: metasploit_status + - name: General | Software | Metasploit | Refresh Apt Files shell: "{{ item }}" loop: @@ -15,7 +18,8 @@ - "mv -fv /usr/share/keyrings/metasploit-framework.gpg /tmp/apt/metasploit-framework.gpg.old" - "mv -fv /etc/apt/sources.list.d/metasploit-framework.list /tmp/apt/metasploit-framework.list.old" - "mv -fv /etc/apt/preferences.d/pin-metasploit.pref /tmp/apt/pin-metasploit.pref.old" - when: ansible_system in ("Linux") + when: ansible_system in ("Linux") and + not metasploit_status.stat.exists ignore_errors: true - name: General | Software | Metasploit | Install @@ -26,4 +30,5 @@ - "mkdir -p {{ global_bin }}" - "mv -fv ./msfinstall {{ global_bin }}/{{ metasploit_installer }}" - yes y | "{{ global_bin }}/{{ metasploit_installer }}" - when: ansible_system in ("Linux", "Darwin") + when: ansible_system in ("Linux", "Darwin") and + not metasploit_status.stat.exists