commit | author | age
|
d92002
|
1 |
--- |
80843b
|
2 |
- name: Get all custom AMI for this specific ( envtype / version / stage ) - plan A |
d92002
|
3 |
environment: |
GC |
4 |
AWS_ACCESS_KEY_ID: "{{aws_access_key_id}}" |
|
5 |
AWS_SECRET_ACCESS_KEY: "{{aws_secret_access_key}}" |
|
6 |
AWS_DEFAULT_REGION: "{{aws_region_loop|d(aws_region)}}" |
|
7 |
ec2_ami_facts: |
|
8 |
owner: self |
|
9 |
filters: |
|
10 |
tag:env_type: "{{ env_type }}" |
a05a62
|
11 |
tag:version: "{{ osrelease | default(repo_version) }}" |
d92002
|
12 |
tag:stages: "*{{ custom_image_stage | d('unknown') }}*" |
GC |
13 |
register: amifacts |
|
14 |
|
|
15 |
# by default do not skip docker tasks |
|
16 |
- set_fact: |
|
17 |
skip_packer_tasks: false |
|
18 |
|
80843b
|
19 |
- name: Select AMI among candidates |
GC |
20 |
when: |
|
21 |
- amifacts is succeeded |
810bb7
|
22 |
- amifacts is not skipped |
80843b
|
23 |
- "'images' in amifacts" |
GC |
24 |
- amifacts.images | d([]) | length > 0 |
82dde9
|
25 |
include_tasks: select_custom_image.yml |
d92002
|
26 |
|
80843b
|
27 |
- name: Get custom AMI using the provided filter - plan B |
82dde9
|
28 |
when: |
810bb7
|
29 |
- amifacts is not skipped |
GC |
30 |
- amifacts is succeeded |
82dde9
|
31 |
- amifacts.images | length == 0 |
GC |
32 |
- custom_image_filter is defined |
|
33 |
environment: |
|
34 |
AWS_ACCESS_KEY_ID: "{{aws_access_key_id}}" |
|
35 |
AWS_SECRET_ACCESS_KEY: "{{aws_secret_access_key}}" |
|
36 |
AWS_DEFAULT_REGION: "{{aws_region_loop|d(aws_region)}}" |
|
37 |
ec2_ami_facts: |
|
38 |
owner: self |
|
39 |
filters: |
|
40 |
name: "*{{ custom_image_filter }}*" |
34f4f0
|
41 |
register: amifacts2 |
d92002
|
42 |
|
31c851
|
43 |
- debug: |
GC |
44 |
msg: "name: \"*{{ custom_image_filter }}*\"" |
|
45 |
|
80843b
|
46 |
- when: |
GC |
47 |
- amifacts2 is not skipped |
|
48 |
- amifacts2 is succeeded |
|
49 |
block: |
|
50 |
- name: Write back the register to amifacts |
|
51 |
set_fact: |
|
52 |
amifacts: "{{ amifacts2 }}" |
34f4f0
|
53 |
|
31c851
|
54 |
- name: debug amifacts2 |
GC |
55 |
debug: |
|
56 |
var: amifacts2 |
|
57 |
- name: debug amifact |
|
58 |
debug: |
|
59 |
var: amifacts |
|
60 |
|
80843b
|
61 |
- name: Select AMI among candidates |
GC |
62 |
when: |
|
63 |
- amifacts is succeeded |
|
64 |
- "'images' in amifacts" |
|
65 |
- amifacts.images | d([]) | length > 0 |
|
66 |
include_tasks: select_custom_image.yml |