Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PB-8755: Add labels for backup schedule request #26

Open
wants to merge 1 commit into
base: 2.8.1
Choose a base branch
from
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
1 change: 1 addition & 0 deletions ansible-collection/examples/backup/create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
volume_snapshot_class_mapping: "{{ item.volume_snapshot_class_mapping | default(omit) }}"
direct_kdmp: "{{ item.direct_kdmp | default(omit) }}"
validate_certs: "{{ item.validate_certs | default(true) }}"
labels: "{{ item.labels | default(omit) }}"
loop: "{{ backups }}"
register: backup_result
loop_control:
Expand Down
3 changes: 2 additions & 1 deletion ansible-collection/examples/backup_schedule/create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@
cluster_ref: "{{ item.cluster_ref }}"
backup_object_type: "{{ item.backup_object_type }}"
skip_vm_auto_exec_rules: "{{ item.skip_vm_auto_exec_rules | default(omit) }}"
volume_snapshot_class_mapping: "{{ item.volume_snapshot_class_mapping }}"
volume_snapshot_class_mapping: "{{ item.volume_snapshot_class_mapping | default(omit) }}"
direct_kdmp: "{{ item.direct_kdmp }}"
owner: "admin"
exclude_resource_types: "{{ item.exclude_resource_types | default(omit) }}"
labels: "{{ item.labels | default(omit) }}"
loop: "{{ backup_schedules }}"
register: backup_result
loop_control:
Expand Down
7 changes: 6 additions & 1 deletion ansible-collection/examples/backup_schedule/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

vars_files:
- "{{ inventory_dir }}/group_vars/common/all.yaml"
- "{{ inventory_dir }}/group_vars/backup_schedule/update.yaml"
- "{{ inventory_dir }}/group_vars/backup_schedule/update_vars.yaml"
Copy link
Contributor

Choose a reason for hiding this comment

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

update_vars is this a typo?


pre_tasks:
- name: Validate required variables
Expand All @@ -20,6 +20,8 @@
current_timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"

tasks:
- name: Login and fetch Px-Backup token
include_tasks: "{{ playbook_dir | dirname }}/auth/auth.yaml"
- name: Backup and update schedules
block:
- name: Get current configurations
Expand All @@ -36,6 +38,7 @@
backup_location_ref: "{{ item.backup_location_ref }}"
pre_exec_rule_ref: "{{ item.pre_exec_rule_ref | default(omit) }}"
post_exec_rule_ref: "{{ item.post_exec_rule_ref | default(omit) }}"
labels: "{{ item.labels | default(omit) }}"
register: current_configs
loop: "{{ backup_schedules_update }}"
loop_control:
Expand Down Expand Up @@ -64,6 +67,7 @@
backup_location_ref: "{{ item.backup_location_ref }}"
pre_exec_rule_ref: "{{ item.pre_exec_rule_ref | default(omit) }}"
post_exec_rule_ref: "{{ item.post_exec_rule_ref | default(omit) }}"
labels: "{{ item.labels | default(omit) }}"
register: update_result
loop: "{{ backup_schedules_update }}"
loop_control:
Expand Down Expand Up @@ -92,6 +96,7 @@
backup_location_ref: "{{ item.backup_location_ref }}"
pre_exec_rule_ref: "{{ item.pre_exec_rule_ref | default(omit) }}"
post_exec_rule_ref: "{{ item.post_exec_rule_ref | default(omit) }}"
labels: "{{ item.labels | default(omit) }}"
register: final_validation
loop: "{{ backup_schedules_update }}"
loop_control:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Backup schedules to inspect
backup_schedules_inspect:
- name: "bs-1"
uid: "uid-1"

- name: "bl-2"
uid: "uid-1"
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ backup_schedules_update:
backup_location_ref:
name: "s3-backup-loc"
uid: "backup-loc-uid"

labels:
key: value

# Global update configuration
backup_configs: true
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ def backup_schedule_request_body(module):
if module.params.get('volume_snapshot_class_mapping'):
backup_schedule_request['volume_snapshot_class_mapping'] = module.params['volume_snapshot_class_mapping']

if module.params.get('labels'):
backup_schedule_request['metadata']['labels'] = module.params['labels']

return backup_schedule_request

def run_module():
Expand Down