blob: d319fdd1a5da095793c1500a1b47b69e65d7fbd3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
---
- name: Remove any ansible facts created during AMI creation
file:
path: "/etc/ansible/facts.d/{{ item }}"
state: absent
with_items:
- openshift.fact
- name: fetch newly created instances
ec2_remote_facts:
region: "{{ openshift_aws_region }}"
filters:
"tag:Name": "{{ openshift_aws_base_ami_name }}"
instance-state-name: running
register: instancesout
retries: 20
delay: 3
until: instancesout.instances|length > 0
- name: bundle ami
ec2_ami:
instance_id: "{{ instancesout.instances.0.id }}"
region: "{{ openshift_aws_region }}"
state: present
description: "This was provisioned {{ ansible_date_time.iso8601 }}"
name: "{{ openshift_aws_ami_name }}"
tags: "{{ openshift_aws_ami_tags }}"
wait: yes
register: amioutput
- debug: var=amioutput
- when: openshift_aws_ami_encrypt | bool
block:
- name: augment the encrypted ami tags with source-ami
set_fact:
source_tag:
source-ami: "{{ amioutput.image_id }}"
- name: copy the ami for encrypted disks
include: ami_copy.yml
vars:
openshift_aws_ami_copy_name: "{{ openshift_aws_ami_name }}-encrypted"
openshift_aws_ami_copy_src_ami: "{{ amioutput.image_id }}"
# TODO: How does the kms alias get passed to ec2_ami_copy
openshift_aws_ami_copy_kms_alias: "alias/{{ openshift_aws_clusterid }}_kms"
openshift_aws_ami_copy_tags: "{{ source_tag | combine(openshift_aws_ami_tags) }}"
# this option currently fails due to boto waiters
# when supported this need to be reapplied
#openshift_aws_ami_copy_wait: True
- name: terminate temporary instance
ec2:
state: absent
region: "{{ openshift_aws_region }}"
instance_ids: "{{ instancesout.instances.0.id }}"
|