diff --git a/roles/aws_common/tasks/write-tags.yml b/roles/aws_common/tasks/write-tags.yml index 2c0fc47..254e92b 100644 --- a/roles/aws_common/tasks/write-tags.yml +++ b/roles/aws_common/tasks/write-tags.yml @@ -33,13 +33,25 @@ Key: "atl:deployment:first-run" Value: "{{ ansible_date_time.iso8601 }}" - - name: Set the first-run tags on the ASG + # Set the tags on the ASG and the local instance. We need to + # ignore errors as it's possible we don't have the permissions, + # and we can't check up-front. + - name: Set the first-run tags on the ASG ("FAIL" is not critical) command: "aws autoscaling create-or-update-tags --region {{ ansible_ec2_placement_region }} --tags '{{ deployment_firstrun_meta | to_json }}'" + ignore_errors: true + + - name: Set the tags on the local instance ("FAIL" is not critical) + ec2_tag: + 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 }}" + ignore_errors: true when: - ec2_autoscaling_group != '' - ec2_instance_tags.tags['atl:deployment:first-run'] is not defined - ignore_errors: true