From 62816235da52d29c1abd909ba8fc0513efc65a1d Mon Sep 17 00:00:00 2001 From: Varun Arbatti Date: Wed, 22 Jan 2020 22:52:26 +0000 Subject: [PATCH] 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 --- roles/aws_common/tasks/write-tags.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/roles/aws_common/tasks/write-tags.yml b/roles/aws_common/tasks/write-tags.yml index 5824b53..d2a442d 100644 --- a/roles/aws_common/tasks/write-tags.yml +++ b/roles/aws_common/tasks/write-tags.yml @@ -14,6 +14,11 @@ set_fact: 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: # No existing timestamp, so this is a first run. Persist some metadata into the ASG. - name: Fetch the git revision for this repo @@ -27,20 +32,20 @@ - ResourceType: "auto-scaling-group" ResourceId: "{{ ec2_autoscaling_group }}" PropagateAtLaunch: true - Key: "atl:deployment:commit" + Key: "atl:deployment:commit-id" Value: "{{ git_out.stdout }}" - ResourceType: "auto-scaling-group" ResourceId: "{{ ec2_autoscaling_group }}" PropagateAtLaunch: true - Key: "atl:deployment:first-run" + Key: "atl:deployment:first-run-timestamp" Value: "{{ ansible_date_time.iso8601 }}" - ResourceType: "auto-scaling-group" ResourceId: "{{ ec2_autoscaling_group }}" PropagateAtLaunch: true - Key: "atl:deployment:restored" - Value: "{{ atl_restore_required }}" + Key: "atl:deployment:is-stack-restored" + Value: "{{ atl_restore_required_tag_value.0 }}" # Set the tags on the ASG and the local instance. We need to @@ -58,11 +63,11 @@ region: "{{ ansible_ec2_placement_region }}" resource: "{{ ansible_ec2_instance_id }}" tags: - "atl:deployment:commit": "{{ git_out.stdout }}" - "atl:deployment:first-run": "{{ ansible_date_time.iso8601 }}" - "atl:deployment:restored": "{{ atl_restore_required }}" + "atl:deployment:commit-id": "{{ git_out.stdout }}" + "atl:deployment:first-run-timestamp": "{{ ansible_date_time.iso8601 }}" + "atl:deployment:is-stack-restored": "{{ atl_restore_required_tag_value.0 }}" ignore_errors: true when: - 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