--- # ============================================================================ # Sophos SNMP and Logging Role - Main Tasks # ============================================================================ - name: Display SNMP and logging configuration overview ansible.builtin.debug: msg: - "======================================" - "Configuring SNMP and Logging" - "======================================" - "Firewall: {{ inventory_hostname }}" - "SNMP Enabled: {{ sophos_snmp.enabled | default(false) }}" - "Syslog Servers: {{ sophos_logging.syslog_servers | default([]) | length }}" tags: ['always'] # Configure SNMP - name: Configure SNMP settings ansible.builtin.uri: url: "https://{{ sophos_mgmt_host }}:{{ sophos_mgmt_port }}/webconsole/APIController" method: POST validate_certs: "{{ sophos_validate_certs }}" headers: Content-Type: "application/x-www-form-urlencoded" body: "reqxml={{ lookup('template', 'snmp_config.json.j2') | urlencode }}" status_code: [200, 201] timeout: "{{ sophos_api_timeout }}" when: sophos_snmp is defined no_log: "{{ sophos_no_log_sensitive }}" tags: ['snmp'] # Configure Syslog - name: Configure syslog servers ansible.builtin.uri: url: "https://{{ sophos_mgmt_host }}:{{ sophos_mgmt_port }}/webconsole/APIController" method: POST validate_certs: "{{ sophos_validate_certs }}" headers: Content-Type: "application/x-www-form-urlencoded" body: "reqxml={{ lookup('template', 'syslog_server.json.j2') | urlencode }}" status_code: [200, 201] timeout: "{{ sophos_api_timeout }}" loop: "{{ sophos_logging.syslog_servers | default([]) }}" loop_control: label: "{{ item.host }}" when: sophos_logging is defined no_log: "{{ sophos_no_log_sensitive }}" tags: ['logging', 'syslog'] # Configure NTP - name: Configure NTP settings ansible.builtin.uri: url: "https://{{ sophos_mgmt_host }}:{{ sophos_mgmt_port }}/webconsole/APIController" method: POST validate_certs: "{{ sophos_validate_certs }}" headers: Content-Type: "application/x-www-form-urlencoded" body: "reqxml={{ lookup('template', 'ntp_config.json.j2') | urlencode }}" status_code: [200, 201] timeout: "{{ sophos_api_timeout }}" when: sophos_ntp is defined no_log: "{{ sophos_no_log_sensitive }}" tags: ['ntp'] - name: SNMP and logging configuration completed ansible.builtin.debug: msg: "SNMP, logging, and NTP configured successfully" tags: ['always']