Replace ansible_date_time.iso8601 with a timestamp from the target system
This commit is contained in:
@@ -1,10 +1,23 @@
|
|||||||
|
---
|
||||||
|
# roles/pfsense_upgrade/tasks/backup_webhook.yml
|
||||||
|
# Captures config.xml and sends to webhook before upgrade
|
||||||
|
|
||||||
- name: Capture current config.xml for backup
|
- name: Capture current config.xml for backup
|
||||||
ansible.builtin.raw: |
|
ansible.builtin.raw: |
|
||||||
cat /conf/config.xml
|
cat /conf/config.xml
|
||||||
register: _config_xml
|
register: _config_xml
|
||||||
when: perform_upgrade | bool
|
when: perform_upgrade | bool
|
||||||
|
|
||||||
- name: Send config to webhook (if webhook URL provided)
|
- 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:
|
uri:
|
||||||
url: "{{ n8n_webhook_url }}"
|
url: "{{ n8n_webhook_url }}"
|
||||||
method: POST
|
method: POST
|
||||||
@@ -12,7 +25,7 @@
|
|||||||
{
|
{
|
||||||
"client_id": "{{ client_id }}",
|
"client_id": "{{ client_id }}",
|
||||||
"hostname": "{{ inventory_hostname }}",
|
"hostname": "{{ inventory_hostname }}",
|
||||||
"timestamp": "{{ ansible_date_time.iso8601 }}",
|
"timestamp": "{{ _timestamp.stdout | trim }}",
|
||||||
"config_xml": "{{ _config_xml.stdout | b64encode }}"
|
"config_xml": "{{ _config_xml.stdout | b64encode }}"
|
||||||
}
|
}
|
||||||
body_format: json
|
body_format: json
|
||||||
|
|||||||
Reference in New Issue
Block a user