Skip to content
Merged
2 changes: 1 addition & 1 deletion roles/debian/ce_provision/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
with_items: "{{ ce_provision.groups }}"
loop_control:
loop_var: group
when: ce_provision.groups | length
when: ce_provision.groups is defined and ce_provision.groups | length > 0

# User normally created already in the _init role.
- name: Generate SSH key for the controller user for provisioning.
Expand Down
12 changes: 5 additions & 7 deletions roles/debian/wazuh/templates/generate_weekly_report.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
REPORT_DATE=$(date +"%Y-%m-%d")
REPORT_NAME="weekly-report-${REPORT_DATE}"
LOG_FILE="/var/log/opensearch-reports.log"
USERNAME= {{ wazuh.mitre_report.username }}
PASSWORD= {{ _wazuh_filebeat_password }}
USERNAME="{{ wazuh.mitre_report.username | default('') }}"
PASSWORD="{{ _wazuh_filebeat_password.stdout | default('') }}"

# Function to log messages
log_message() {
Expand All @@ -17,16 +17,14 @@ log_message() {
log_message "Starting weekly report generation"

# Generate and send the report
opensearch-reporting-cli \
/usr/local/bin/opensearch-reporting-cli \
-u "{{ wazuh.mitre_report.visualization_url }}" \
-a basic \
-c "$USERNAME:$PASSWORD" \
--selfsignedcerts true \
-f pdf \
-n "$REPORT_NAME" \
-e smtp \
-s "{{ wazuh.mitre_report.e_mail_from }}" \
-r "{{ wazuh.manager.wazuh_manager_mailto}}" \
-r "{{ wazuh.manager.wazuh_manager_mailto }}" \
--subject "Weekly OpenSearch Report - $(date '+%B %d, %Y')" \
--note "Hi,\n\nPlease find attached the weekly Wazuh Mitre report covering the last 7 days.\n\nReport generated on: $(date '+%Y-%m-%d %H:%M:%S')\n\nBest regards,\nAutomated Reporting System" \
--smtphost localhost \
Expand All @@ -43,4 +41,4 @@ fi
# Optional: Clean up old report files (keep last 2 weeks)
find /tmp -name "weekly-report-*.pdf" -mtime +14 -delete 2>/dev/null

log_message "Weekly report process completed"
log_message "Weekly report process completed"