Merged in DCD-890-make-tags-consistent-with-qs-template (pull request #77)

DCD-890: Rename tag keys to make it consistent with tags exposed by quickstart templates

* DCD-890: Rename tag keys to make it consistent with tags exposed by quickstart templates

* DCD-869: Store restore tag in an array of one item to force type to a string

* DCD-869: Fix yaml lint

Approved-by: Steve Smith <ssmith@atlassian.com>
This commit is contained in:
Varun Arbatti
2020-01-22 22:52:26 +00:00
parent 91ddbb157b
commit 62816235da

View File

@@ -14,6 +14,11 @@
set_fact: set_fact:
ec2_autoscaling_group: "{{ ec2_tags.tags['aws:autoscaling:groupName'] | default('') }}" ec2_autoscaling_group: "{{ ec2_tags.tags['aws:autoscaling:groupName'] | default('') }}"
# Because Ansible - https://github.com/ansible/ansible/issues/11905#issuecomment-130496173
- name: Set fact to store boolean 'atl_restore_required' value as as array of one string
set_fact:
atl_restore_required_tag_value: ["{{ atl_restore_required | lower }}"]
- block: - block:
# No existing timestamp, so this is a first run. Persist some metadata into the ASG. # No existing timestamp, so this is a first run. Persist some metadata into the ASG.
- name: Fetch the git revision for this repo - name: Fetch the git revision for this repo
@@ -27,20 +32,20 @@
- ResourceType: "auto-scaling-group" - ResourceType: "auto-scaling-group"
ResourceId: "{{ ec2_autoscaling_group }}" ResourceId: "{{ ec2_autoscaling_group }}"
PropagateAtLaunch: true PropagateAtLaunch: true
Key: "atl:deployment:commit" Key: "atl:deployment:commit-id"
Value: "{{ git_out.stdout }}" Value: "{{ git_out.stdout }}"
- ResourceType: "auto-scaling-group" - ResourceType: "auto-scaling-group"
ResourceId: "{{ ec2_autoscaling_group }}" ResourceId: "{{ ec2_autoscaling_group }}"
PropagateAtLaunch: true PropagateAtLaunch: true
Key: "atl:deployment:first-run" Key: "atl:deployment:first-run-timestamp"
Value: "{{ ansible_date_time.iso8601 }}" Value: "{{ ansible_date_time.iso8601 }}"
- ResourceType: "auto-scaling-group" - ResourceType: "auto-scaling-group"
ResourceId: "{{ ec2_autoscaling_group }}" ResourceId: "{{ ec2_autoscaling_group }}"
PropagateAtLaunch: true PropagateAtLaunch: true
Key: "atl:deployment:restored" Key: "atl:deployment:is-stack-restored"
Value: "{{ atl_restore_required }}" Value: "{{ atl_restore_required_tag_value.0 }}"
# Set the tags on the ASG and the local instance. We need to # Set the tags on the ASG and the local instance. We need to
@@ -58,11 +63,11 @@
region: "{{ ansible_ec2_placement_region }}" region: "{{ ansible_ec2_placement_region }}"
resource: "{{ ansible_ec2_instance_id }}" resource: "{{ ansible_ec2_instance_id }}"
tags: tags:
"atl:deployment:commit": "{{ git_out.stdout }}" "atl:deployment:commit-id": "{{ git_out.stdout }}"
"atl:deployment:first-run": "{{ ansible_date_time.iso8601 }}" "atl:deployment:first-run-timestamp": "{{ ansible_date_time.iso8601 }}"
"atl:deployment:restored": "{{ atl_restore_required }}" "atl:deployment:is-stack-restored": "{{ atl_restore_required_tag_value.0 }}"
ignore_errors: true ignore_errors: true
when: when:
- ec2_autoscaling_group != '' - ec2_autoscaling_group != ''
- ec2_instance_tags.tags['atl:deployment:first-run'] is not defined - ec2_instance_tags.tags['atl:deployment:first-run-timestamp'] is not defined