From 8c25a6bd3bacdfe59b628fd21a1e1edf723d37c4 Mon Sep 17 00:00:00 2001 From: rohitthakur2590 Date: Mon, 26 May 2025 19:18:47 +0530 Subject: [PATCH 1/2] update pattern specifications Signed-off-by: rohitthakur2590 --- .../update_pattern_specifications.yml | 3 ++ .../backup/template_surveys/backup.yaml | 46 +++++++++++-------- roles/backup/tasks/backup.yaml | 11 +++-- 3 files changed, 36 insertions(+), 24 deletions(-) create mode 100644 changelogs/fragments/update_pattern_specifications.yml diff --git a/changelogs/fragments/update_pattern_specifications.yml b/changelogs/fragments/update_pattern_specifications.yml new file mode 100644 index 0000000..004fe2b --- /dev/null +++ b/changelogs/fragments/update_pattern_specifications.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - update pattern specification and default filename and path handling. diff --git a/extensions/patterns/backup/template_surveys/backup.yaml b/extensions/patterns/backup/template_surveys/backup.yaml index 80dead9..e9a1358 100644 --- a/extensions/patterns/backup/template_surveys/backup.yaml +++ b/extensions/patterns/backup/template_surveys/backup.yaml @@ -4,40 +4,46 @@ description: "Survey to configure network backup options" spec: - type: "multiplechoice" question_name: "Backup Type" - question_description: "Select the type of backup" + question_description: "Select the type of backup to perform — a full or differential (diff) backup." variable: "backup_type" choices: - "full" - "diff" - required: true + required: false default: "full" + - type: "text" + question_name: "GitHub Username" + question_description: "Enter your GitHub username associated with the target repository." + variable: "gh_user" + required: true + + - type: "text" + question_name: "GitHub Email" + question_description: "Enter the email address linked to your GitHub account that owns the target repository." + variable: "gh_email" + required: false + - type: "text" question_name: "GitHub Repository URL" - question_description: "URL of the GitHub repository for storing the backup" - variable: "GH_REPO" + question_description: "Enter the GitHub repository URL you want to use." + variable: "gh_url" required: true - type: "password" question_name: "GitHub Token" - question_description: "Personal access token for GitHub repository" - variable: "GH_TOKEN" + question_description: "Enter your GitHub personal access token with access to the target repository." + variable: "gh_token" required: true - type: "text" - question_name: "GitHub Username" - question_description: "GitHub username for the repository" - variable: "GH_USER" - required: true - - - type: "text" - question_name: "GitHub Email" - question_description: "GitHub email associated with the repository" - variable: "GH_EMAIL" - required: true - + question_name: "Path" + question_description: "Specify the relative path inside your GitHub repository where the backup file should be saved. If left blank, the default role path () will be used." + variable: "path" + required: false + - type: "text" - question_name: "Backup File Name" - question_description: "Name of the backup file (optional). If not provided, a timestamp will be used." - variable: "backup_file_name" + question_name: "Backup Filename" + question_description: "Provide a name for the backup file (e.g., device_backup.txt). If left blank, a default filename will be generated using the device name and timestamp." + variable: "filename" required: false diff --git a/roles/backup/tasks/backup.yaml b/roles/backup/tasks/backup.yaml index 916ea3a..57e5c5d 100644 --- a/roles/backup/tasks/backup.yaml +++ b/roles/backup/tasks/backup.yaml @@ -15,14 +15,17 @@ - name: Get file name ansible.builtin.set_fact: - network_backup_path: "{{ network_backup_path_root }}/{{ data_store.scm.origin.path }}" + network_backup_path: "{{ network_backup_path_root }}/{{ data_store.scm.origin.path | default(role_path, true)}}" when: data_store['scm']['origin'] is defined -- name: Get file name +- name: Get timestamp ansible.builtin.set_fact: - network_backup_filename: "{{ data_store.scm.origin.filename }}" - when: data_store['scm']['origin'] is defined + timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d_%H-%M-%S') }}" +- name: Set default filename + ansible.builtin.set_fact: + network_backup_filename: >- + {{ data_store.scm.origin.filename | default(inventory_hostname ~ '_' ~ timestamp ~ '.txt', true) }} - name: Include tasks ansible.builtin.include_tasks: network.yaml From 1d5764ec3946516957a967d3ce1291b7b896eaa3 Mon Sep 17 00:00:00 2001 From: rohitthakur2590 Date: Thu, 29 May 2025 12:29:26 +0530 Subject: [PATCH 2/2] update restore surveys Signed-off-by: rohitthakur2590 --- .../restore/template_surveys/restore.yaml | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/extensions/patterns/restore/template_surveys/restore.yaml b/extensions/patterns/restore/template_surveys/restore.yaml index 485ba01..0329d6a 100644 --- a/extensions/patterns/restore/template_surveys/restore.yaml +++ b/extensions/patterns/restore/template_surveys/restore.yaml @@ -4,18 +4,24 @@ description: "Survey to configure network restore options" spec: - type: "text" question_name: "GitHub Repository URL" - question_description: "URL of the GitHub repository containing the backup" - variable: "GH_REPO" + question_description: "Enter the GitHub repository URL you want to use." + variable: "gh_url" required: true - type: "password" question_name: "GitHub Token" - question_description: "Personal access token for GitHub repository" - variable: "GH_TOKEN" + question_description: "Enter your GitHub personal access token with access to the target repository." + variable: "gh_token" required: true - type: "text" - question_name: "File Path for Restore" - question_description: "Path to the specific backup file in the GitHub repository" - variable: "file_path" + question_name: "Path" + question_description: "Specify the relative path inside your GitHub repository where the backup file is saved." + variable: "path" + required: true + + - type: "text" + question_name: "Backup Filename" + question_description: "Provide the backup file name" + variable: "filename" required: true