From 94b2f03d5bd9ada69527a1f420067e10246ac4c8 Mon Sep 17 00:00:00 2001 From: Matt Woodson Date: Wed, 7 Feb 2018 17:21:03 -0500 Subject: aws ami: make it so the tags from the orinal AMI are used with the newly created AMI --- roles/openshift_aws/tasks/seal_ami.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'roles') diff --git a/roles/openshift_aws/tasks/seal_ami.yml b/roles/openshift_aws/tasks/seal_ami.yml index 74877d5c7..c1cb37a3b 100644 --- a/roles/openshift_aws/tasks/seal_ami.yml +++ b/roles/openshift_aws/tasks/seal_ami.yml @@ -10,6 +10,19 @@ delay: 3 until: instancesout.instances|length > 0 +- name: fetch the ami used to create the instance + ec2_ami_find: + region: "{{ openshift_aws_region }}" + ami_id: "{{ instancesout.instances[0]['image_id'] }}" + register: original_ami_out + retries: 20 + delay: 3 + until: original_ami_out.results|length > 0 + +- name: combine the tags of the original ami with newly created ami + set_fact: + l_openshift_aws_ami_tags: "{{ original_ami_out.results[0]['tags'] | combine(openshift_aws_ami_tags) }}" + - name: bundle ami ec2_ami: instance_id: "{{ instancesout.instances.0.instance_id }}" @@ -17,7 +30,7 @@ state: present description: "This was provisioned {{ ansible_date_time.iso8601 }}" name: "{{ openshift_aws_ami_name }}" - tags: "{{ openshift_aws_ami_tags }}" + tags: "{{ l_openshift_aws_ami_tags }}" wait: yes register: amioutput -- cgit v1.2.1