DCD-890: Simplify tagging logic.

This commit is contained in:
Steve Smith
2020-01-14 11:14:36 +11:00
parent 590eca6aa5
commit ce52f34742

View File

@@ -11,19 +11,6 @@
set_fact: set_fact:
ec2_autoscaling_group: "{{ ec2_tags.tags['aws:autoscaling:groupName'] | default('') }}" ec2_autoscaling_group: "{{ ec2_tags.tags['aws:autoscaling:groupName'] | default('') }}"
- block:
# We're in an ASG, lookup the tags...
- name: Get AutoscalingGroup tags
command: "aws autoscaling
describe-tags
--region {{ ansible_ec2_placement_region }}
--filters Name=auto-scaling-group,Values='{{ ec2_autoscaling_group }}'"
register: asg_tags_out
- name: Parse and transform the AWS tags into a lookup table
set_fact:
asg_tags: "{{ (asg_tags_out.stdout | from_json).Tags | items2dict(key_name='Key', value_name='Value') }}"
- 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
@@ -52,7 +39,7 @@
--region {{ ansible_ec2_placement_region }} --region {{ ansible_ec2_placement_region }}
--tags '{{ deployment_firstrun_meta | to_json }}'" --tags '{{ deployment_firstrun_meta | to_json }}'"
when: asg_tags['atl:deployment:first-run'] is not defined when:
- ec2_autoscaling_group != ''
when: ec2_autoscaling_group != '' - ec2_instance_tags.tags['atl:deployment:first-run'] is not defined
ignore_errors: true ignore_errors: true