Skip to content

Commit

Permalink
Path reset playbook to keep reservation name.
Browse files Browse the repository at this point in the history
  • Loading branch information
fridim committed Sep 28, 2023
1 parent 75002cc commit 08fb2e5
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions playbooks/roles/infra-aws-sandbox/tasks/pool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,36 @@

- when: operation == 'RESET'
block:
- name: Get sandbox reservation
vars:
_data:
name:
S: "{{ account_name }}"
command: >-
aws --profile {{ dynamodb_profile | quote }}
--region {{ dynamodb_region | quote }}
dynamodb get-item
--table-name {{ dynamodb_table }}
--key '{{ _data | to_json }}'
--query 'Item.reservation'
--output text
register: r_get_reservation
changed_when: false

- name: Save some values for after cleanup
set_fact:
sandbox_reservation: "{{ r_get_reservation.stdout }}"

- when: sandbox_reservation | default("") != ""
set_fact:
additional_data:
reservation:
S: "{{ sandbox_reservation }}"

- when: sandbox_reservation | default("") == ""
set_fact:
additional_data: {}

- name: Pre-Reset account information for validation
vars:
_data:
Expand All @@ -66,7 +96,7 @@
--region {{ dynamodb_region }}
dynamodb put-item
--table-name {{ dynamodb_table }}
--item '{{ _data | to_json }}'
--item '{{ _data | combine(additional_data | default({}), recursive=True) | to_json }}'
- name: Validate Sandbox
include_tasks: validate.yaml
Expand All @@ -93,5 +123,5 @@
--region {{ dynamodb_region }}
dynamodb put-item
--table-name {{ dynamodb_table }}
--item '{{ _data | to_json }}'
--item '{{ _data | combine(additional_data | default({}), recursive=True) | to_json }}'
register: _resetaccount

0 comments on commit 08fb2e5

Please sign in to comment.