From 1a43936c6b22258f8931f117f2596515e4a563f6 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sat, 6 Feb 2021 09:18:23 -0600 Subject: [PATCH] Provide method for non-SSHFS machines to report. --- facts/general/system.yml | 32 ++++++++++++++++++++++++++++---- tasks/general/cron/root.yml | 21 ++++++++++++++++++++- tasks/general/start.yml | 7 +++++-- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/facts/general/system.yml b/facts/general/system.yml index 2e2fc36..3a4a82c 100644 --- a/facts/general/system.yml +++ b/facts/general/system.yml @@ -25,7 +25,31 @@ - name: Facts | General | System | 1337 set_fact: leet_drive: /mnt/leet - heartbeat_report: "/mnt/leet/Temp/ansible/{{ ansible_hostname }}.txt" - lynis_report: "/mnt/leet/Temp/ansible/{{ ansible_hostname }}_lynis.txt" - nmap_report: "/mnt/leet/Temp/ansible/{{ ansible_hostname }}_nmap.txt" - ansible_pull_report: "/mnt/leet/Temp/ansible/{{ ansible_hostname }}_last_pull_times.txt" \ No newline at end of file + +- name: Facts | General | System | 1337 Mounted? + stat: + path: "{{ leet_drive }}"/ansible + register: leet_drive_details + +- name: Facts | General | System | 1337 Mounted? DEBUG + debug: + variable: leet_drive_details + + +- name: Facts | General | System | Report Location = 1337 + set_fact: + report_location: "{{ leet_drive }}/Temp/ansible" + when: leet_drive_details.stat.exists + +- name: Facts | General | System | Report Location = /root + set_fact: + report_location: "/root" + report_scp_location: "Temp/ansible/" + when: not leet_drive_details.stat.exists + +- name: Facts | General | System | Reports + set_fact: + heartbeat_report: "{{ report_location }}/{{ ansible_hostname }}.txt" + lynis_report: "{{ report_location }}/{{ ansible_hostname }}_lynis.txt" + nmap_report: "{{ report_location }}/{{ ansible_hostname }}_nmap.txt" + ansible_pull_report: "{{ report_location }}/{{ ansible_hostname }}_last_pull_times.txt" \ No newline at end of file diff --git a/tasks/general/cron/root.yml b/tasks/general/cron/root.yml index 29aa3a7..0893ee8 100644 --- a/tasks/general/cron/root.yml +++ b/tasks/general/cron/root.yml @@ -9,4 +9,23 @@ job: "{{ sshfs_leet_cmd }}" state: present disabled: no - when: ansible_system == "FreeBSD" \ No newline at end of file + when: ansible_system == "FreeBSD" + +- name: General | Cron | Root | Enable Secure Copy Reports + cron: + user: root + name: "Copy Reports" + minute: "05,20,35,50" + job: "scp {{ ansible_pull_report }} {{ heartbeat_report }} {{ lynis_report }} {{ nmap_report }} ling@leet:{{ report_scp_location }}" + state: present + disabled: no + when: not leet_drive_details.stat.exists + +- name: General | Cron | Root | Disable Secure Copy Reports + cron: + user: root + name: "Copy Reports" + job: "As a wise man once said, I'm disabled." + state: present + disabled: yes + when: leet_drive_details.stat.exists \ No newline at end of file diff --git a/tasks/general/start.yml b/tasks/general/start.yml index 935718f..547f317 100644 --- a/tasks/general/start.yml +++ b/tasks/general/start.yml @@ -4,11 +4,14 @@ - name: General | Start | Ansible Pull Report | Start File shell: "echo 'START' > {{ ansible_pull_report }}" + when: leet_drive_details.stat.exists -- name: General | Start | Ansible Pull Report | Make Viewable +- name: General | Start | Ansible Pull Report | Make Viewable (SSHFS) file: path: "{{ ansible_pull_report }}" mode: '0777' + when: leet_drive_details.stat.exists - name: General | Start | Ansible Pull Report | Add Date Entry - shell: "date >> {{ ansible_pull_report }}" \ No newline at end of file + shell: "date >> {{ ansible_pull_report }}" + when: leet_drive_details.stat.exists \ No newline at end of file