commit | author | age
|
1c72da
|
1 |
--- |
GC |
2 |
- name: Get all custom AMI for that environment / version |
|
3 |
environment: |
|
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 }}" |
a1906c
|
11 |
tag:version: "{{ osrelease | default(repo_version) }}" |
1c72da
|
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 |
|
|
19 |
- when: amifacts.images | length > 0 |
|
20 |
block: |
|
21 |
# For now, use one image for all the machines of the config. Start simple. |
|
22 |
# TODO: add another tag to the image to apply it to specific group of hosts in the config |
|
23 |
- set_fact: |
|
24 |
custom_image: "{{ amifacts | json_query('images[]') | sort(attribute='creation_date') | last }}" |
|
25 |
|
|
26 |
- name: Print debug information about the custom image used |
|
27 |
debug: |
|
28 |
var: custom_image |
|
29 |
|
|
30 |
- name: Skip packer tasks if the tags in the image say to do so |
|
31 |
set_fact: |
|
32 |
skip_packer_tasks: true |
|
33 |
when: |
|
34 |
- custom_image is defined |
|
35 |
- custom_image.tags.skip_packer_tasks is defined |
|
36 |
- custom_image.tags.skip_packer_tasks in ['true', 'yes', 'True', 'Yes'] |