From 99fa2c8c71ac254ffccb221aa341cc978de7db83 Mon Sep 17 00:00:00 2001 From: Gavin Will Date: Sat, 1 Apr 2023 18:55:20 +0100 Subject: [PATCH] prettier quoutes --- meta/main.yml | 11 +++++++++-- tasks/main.yml | 46 +++++++++++++++++++++++----------------------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/meta/main.yml b/meta/main.yml index c5a9733..fcb3bde 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,12 +1,19 @@ galaxy_info: author: Gavin Will - description: ansible role to backup pfsense firewalls + description: Ansible Role to Backup pfSense Firewalls + role_name: ansible_role_pfsense_backup + namespace: ansible_role_pfsense_backup issue_tracker_url: https://github.com/gavinwill/ansible-role-pfsense-backup/issues license: MIT - min_ansible_version: 2.9 + min_ansible_version: "2.9" + + platforms: + - name: FreeBSD + versions: + - all galaxy_tags: - pfsense diff --git a/tasks/main.yml b/tasks/main.yml index 54bb0b9..2a4c84c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,7 +2,7 @@ # Documentation from netgate for remote backup options: # https://docs.netgate.com/pfsense/en/latest/backup/remote-backup.html -- name: pfSense Backup | Assert that hostname and credentials supplied +- name: PfSense Backup | Assert that hostname and credentials supplied ansible.builtin.assert: that: - "{{ item }} | length" @@ -14,36 +14,36 @@ - pfsense_password - pfsense_backup_directory -- name: pfSense Backup | Construct Backup URL Protocol +- name: PfSense Backup | Construct Backup URL Protocol ansible.builtin.set_fact: - pfsense_backup_protocol: "{{'http' if not (pfsense_https) else 'https'}}" + pfsense_backup_protocol: "{{ 'http' if not (pfsense_https) else 'https' }}" -- name: pfSense Backup | Obtain Cookies & CSRF Token +- name: PfSense Backup | Obtain Cookies & CSRF Token ansible.builtin.uri: url: "{{ pfsense_backup_protocol }}://{{ pfsense_hostname }}/{{ pfsense_backup_page }}" validate_certs: "{{ pfsense_validate_certificates }}" method: GET - return_content: yes + return_content: true register: pfsense_cookie_token no_log: "{{ pfsense_backup_no_log }}" -- name: pfSense Backup | Set Fact for CSRF Token +- name: PfSense Backup | Set Fact for CSRF Token ansible.builtin.set_fact: - pfsense_backup_csrf0: "{{ pfsense_cookie_token.content | regex_search('var\\s+csrfMagicToken\\s+=\\s+\\\"([a-f0-9sidp:;,]+)\\\"','\\1') }}" + pfsense_backup_csrf0: "{{ pfsense_cookie_token.content | regex_search('var\\s+csrfMagicToken\\s+=\\s+\\\"([a-f0-9sidp:;,]+)\\\"', '\\1') }}" no_log: "{{ pfsense_backup_no_log }}" -- name: pfSense Backup | Set Fact for CSRF Cookie +- name: PfSense Backup | Set Fact for CSRF Cookie ansible.builtin.set_fact: - pfsense_backup_cookie0: "{{ pfsense_cookie_token.set_cookie }}" + pfsense_backup_cookie0: "{{ pfsense_cookie_token.set_cookie }}" no_log: "{{ pfsense_backup_no_log }}" -- name: pfSense Backup | Authenticate with backup page and register Backup CSRF +- name: PfSense Backup | Authenticate with backup page and register Backup CSRF ansible.builtin.uri: url: "{{ pfsense_backup_protocol }}://{{ pfsense_hostname }}/{{ pfsense_backup_page }}" validate_certs: "{{ pfsense_validate_certificates }}" - follow_redirects: no + follow_redirects: false method: POST - return_content: yes + return_content: true body_format: form-urlencoded status_code: 302 body: @@ -56,39 +56,39 @@ register: pfsense_cookie_token2 no_log: "{{ pfsense_backup_no_log }}" -- name: pfSense Backup | Set Fact for Cookie from Backup Page +- name: PfSense Backup | Set Fact for Cookie from Backup Page ansible.builtin.set_fact: pfsense_backup_cookie1: "{{ pfsense_cookie_token2.set_cookie }}" no_log: "{{ pfsense_backup_no_log }}" -- name: pfSense Backup | Fetch Target page for new CSRF token +- name: PfSense Backup | Fetch Target page for new CSRF token ansible.builtin.uri: url: "{{ pfsense_backup_protocol }}://{{ pfsense_hostname }}/{{ pfsense_backup_page }}" validate_certs: "{{ pfsense_validate_certificates }}" - follow_redirects: no + follow_redirects: false method: GET - return_content: yes + return_content: true headers: Cookie: "{{ pfsense_backup_cookie1 }}" register: pfsense_cookie_token3 no_log: "{{ pfsense_backup_no_log }}" -- name: PFSENSE | Set Fact for CSRF Token +- name: PfSense Backup | Set Fact for CSRF Token ansible.builtin.set_fact: - pfsense_backup_csrf1: "{{ pfsense_cookie_token3.content | regex_search('var\\s+csrfMagicToken\\s+=\\s+\\\"([a-f0-9sidp:;,]+)\\\"','\\1') }}" + pfsense_backup_csrf1: "{{ pfsense_cookie_token3.content | regex_search('var\\s+csrfMagicToken\\s+=\\s+\\\"([a-f0-9sidp:;,]+)\\\"', '\\1') }}" no_log: "{{ pfsense_backup_no_log }}" -- name: pfSense Backup | Set Fact for CSRF Cookie +- name: PfSense Backup | Set Fact for CSRF Cookie ansible.builtin.set_fact: - pfsense_backup_cookie2: "{{ pfsense_cookie_token3.set_cookie }}" + pfsense_backup_cookie2: "{{ pfsense_cookie_token3.set_cookie }}" no_log: "{{ pfsense_backup_no_log }}" -- name: pfSense Backup | Download Backup Configuration +- name: PfSense Backup | Download Backup Configuration ansible.builtin.uri: url: "{{ pfsense_backup_protocol }}://{{ pfsense_hostname }}/{{ pfsense_backup_page }}" validate_certs: "{{ pfsense_validate_certificates }}" method: POST - return_content: yes + return_content: true body_format: form-urlencoded body: download: download @@ -97,7 +97,7 @@ donotbackuprrd: "{{'yes' if (pfsense_donotbackuprrd) | default(omit) }}" encrypt: "{{'yes' if (pfsense_encrypted_password | length) | default(omit) }}" encrypt_password: "{{ (pfsense_encrypted_password) | default(omit) }}" - encrypt_password_confirm: "{{ (pfsense_encrypted_password ) | default(omit) }}" + encrypt_password_confirm: "{{ (pfsense_encrypted_password) | default(omit) }}" __csrf_magic: "{{ pfsense_backup_csrf1 }}" headers: Cookie: "{{ pfsense_backup_cookie2 }}"