Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/update_pattern_specifications.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- update pattern specification and default filename and path handling.
46 changes: 26 additions & 20 deletions extensions/patterns/backup/template_surveys/backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<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
20 changes: 13 additions & 7 deletions extensions/patterns/restore/template_surveys/restore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 7 additions & 4 deletions roles/backup/tasks/backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we merged this change here #38 we can revert it from here

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
Expand Down