Only do the metasploit activities if it is not already installed.

This commit is contained in:
2026-04-06 15:24:33 -07:00
parent 579764ca76
commit fa0ea0098e

View File

@@ -1,13 +1,16 @@
--- ---
# Install Metasploit Framework # Install Metasploit Framework
# TBD: Check if msfconsole is in PATH and if so skip this reinstallation process.
- name: General | Software | Metasploit | Facts - name: General | Software | Metasploit | Facts
set_fact: set_fact:
metasploit_installer: msfinstall metasploit_installer: msfinstall
when: ansible_system in ("Linux", "Darwin") 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 - name: General | Software | Metasploit | Refresh Apt Files
shell: "{{ item }}" shell: "{{ item }}"
loop: loop:
@@ -15,7 +18,8 @@
- "mv -fv /usr/share/keyrings/metasploit-framework.gpg /tmp/apt/metasploit-framework.gpg.old" - "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/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" - "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 ignore_errors: true
- name: General | Software | Metasploit | Install - name: General | Software | Metasploit | Install
@@ -26,4 +30,5 @@
- "mkdir -p {{ global_bin }}" - "mkdir -p {{ global_bin }}"
- "mv -fv ./msfinstall {{ global_bin }}/{{ metasploit_installer }}" - "mv -fv ./msfinstall {{ global_bin }}/{{ metasploit_installer }}"
- yes y | "{{ 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