Files
offline_kubespray/collection/infinidat/infinibox/playbooks/test_create_snapshots.yml
ByeonJungHun 360c6eef4a offline 작업
2024-02-19 16:02:29 +09:00

104 lines
3.7 KiB
YAML

---
- hosts: localhost
gather_facts: True # Required for ansible_date_time
tasks:
- name: POSITIVE test -> Create pool {{ auto_prefix }}pool
infini_pool:
name: "{{ auto_prefix }}pool"
size: 1TB
vsize: 1TB
state: present
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
- name: POSITIVE test -> Create thin volume {{ auto_prefix }}vol under pool {{ auto_prefix }}pool
infini_vol:
name: "{{ auto_prefix }}vol"
size: 1GB
pool: "{{ auto_prefix }}pool"
state: present
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
- name: POSITIVE test -> Create snapshot {{ auto_prefix }}vol_snap from volume {{ auto_prefix }}vol
infini_vol:
name: "{{ auto_prefix }}vol_snap"
state: present
volume_type: snapshot
parent_volume_name: "{{ auto_prefix }}vol"
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
- name: DEBUG test -> Find the current date-time (WARNING - Time marks when the playbook gathered facts)
debug:
var=ansible_date_time.iso8601_micro
- name: POSITIVE test -> Create and lock for 2 minutes snapshot {{ auto_prefix }}vol_snap_locked from volume {{ auto_prefix }}vol
infini_vol:
name: "{{ auto_prefix }}vol_snap_locked"
state: present
volume_type: snapshot
parent_volume_name: "{{ auto_prefix }}vol"
snapshot_lock_expires_at: "{{ ansible_date_time.iso8601_micro | to_datetime(fmt) | infinidat.infinibox.delta_time(minutes=2) }}"
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
vars:
fmt: "%Y-%m-%dT%H:%M:%S.%fZ"
- name: POSITIVE test -> Extend lock to 3 minutes for {{ auto_prefix }}vol_snap_locked without refresh
infini_vol:
name: "{{ auto_prefix }}vol_snap_locked"
state: present
volume_type: snapshot
parent_volume_name: "{{ auto_prefix }}vol"
snapshot_lock_expires_at: "{{ ansible_date_time.iso8601_micro | to_datetime(fmt) | infinidat.infinibox.delta_time(minutes=3) }}"
snapshot_lock_only: true
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
vars:
fmt: "%Y-%m-%dT%H:%M:%S.%fZ"
- name: NEGATIVE test -> Attempt to create snapshot locked for 31 days, 31 days exceeds 30 day maximum lock time enforced by infini_vol module (not API)
infini_vol:
name: "{{ auto_prefix }}vol_snap_locked_too_long"
state: present
volume_type: snapshot
parent_volume_name: "{{ auto_prefix }}vol"
snapshot_lock_expires_at: "{{ ansible_date_time.iso8601_micro | to_datetime(fmt) | infinidat.infinibox.delta_time(days=31) }}"
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
register: result
failed_when: "not result.msg | regex_search('snapshot_lock_expires_at exceeds.*days in the future')"
vars:
fmt: "%Y-%m-%dT%H:%M:%S.%fZ"
- name: NEGATIVE test -> Attempt to remove locked snapshot {{ auto_prefix }}vol_snap_locked
infini_vol:
name: "{{ auto_prefix }}vol_snap_locked"
state: absent
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
register: result
failed_when: "'Cannot delete snapshot. Locked' not in result.msg"
- name: POSITIVE test -> Wait for lock on {{ auto_prefix }}vol_snap_locked to expire
pause:
seconds: 181
prompt: Waiting for {{ auto_prefix }}vol_snap_locked to expire
- name: POSITIVE test -> Lock expired. Remove snapshot {{ auto_prefix }}vol_snap_locked.
infini_vol:
name: "{{ auto_prefix }}vol_snap_locked"
state: absent
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"