Files
ansible-msp-automations/roles/pfsense_upgrade/tasks/backup_webhook.yml

36 lines
966 B
YAML

---
# roles/pfsense_upgrade/tasks/backup_webhook.yml
# Captures config.xml and sends to webhook before upgrade
- name: Capture current config.xml for backup
ansible.builtin.raw: |
cat /conf/config.xml
register: _config_xml
when: perform_upgrade | bool
- name: Get timestamp from target system
ansible.builtin.raw: |
date -u +"%Y-%m-%dT%H:%M:%SZ"
register: _timestamp
when:
- perform_upgrade | bool
- n8n_webhook_url is defined
- n8n_webhook_url | length > 0
- name: Send config to webhook
uri:
url: "{{ n8n_webhook_url }}"
method: POST
body: |
{
"client_id": "{{ client_id }}",
"hostname": "{{ inventory_hostname }}",
"timestamp": "{{ _timestamp.stdout | trim }}",
"config_xml": "{{ _config_xml.stdout | b64encode }}"
}
body_format: json
when:
- perform_upgrade | bool
- n8n_webhook_url is defined
- n8n_webhook_url | length > 0
delegate_to: localhost