1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- ---
- # When openshift_aws_use_custom_ami is '' then
- # we retrieve the latest build AMI.
- # Then set openshift_aws_ami to the ami.
- - when:
- - (openshift_aws_ami == '' and openshift_aws_node_group.group not in openshift_aws_ami_map) or (openshift_aws_node_group.group in openshift_aws_ami_map and openshift_aws_ami_map[openshift_aws_node_group.group] == '')
- block:
- - name: fetch recently created AMI
- ec2_ami_facts:
- region: "{{ openshift_aws_region }}"
- filters: "{ 'name': '{{ openshift_aws_ami_name }}*',
- {%- for key in openshift_aws_ami_tags -%}
- 'tag:{{ key }}': '{{ openshift_aws_ami_tags[key] }}',
- {%- endfor -%} }"
- register: amiout
- failed_when: "amiout.images|length == 0"
- - name: Set the openshift_aws_ami
- set_fact:
- openshift_aws_ami: "{{ ( amiout.images | sort(attribute='creation_date') | map(attribute='image_id') | reverse | list )[0] }}"
- when:
- - "'images' in amiout"
- - amiout.images|length > 0
- # query asg's and determine if we need to create the others.
- # if we find more than 1 for each type, and this isn't an upgrade, then exit
- - name: query all asg's for this cluster
- ec2_asg_facts:
- region: "{{ openshift_aws_region }}"
- tags: "{{ {'kubernetes.io/cluster/' ~ openshift_aws_clusterid: openshift_aws_clusterid} | combine(openshift_aws_node_group.tags) }}"
- register: asgs
- - debug:
- msg: "{{ asgs }}"
- - fail:
- msg: "Found more than 1 auto scaling group that matches the query for group: {{ openshift_aws_node_group }}"
- when:
- - not openshift_aws_node_group_upgrade
- - asgs.results|length > 1
- - fail:
- msg: "Upgrade: Found more than 2 auto scaling group that matches the query for group: {{ openshift_aws_node_group }}"
- when:
- - openshift_aws_node_group_upgrade
- - asgs.results|length > 2
- - name: set the value for the deployment_serial and the current asgs
- set_fact:
- # scale_groups_serial is a custom filter in role lib_utils
- l_deployment_serial: "{{ openshift_aws_node_group_deployment_serial if openshift_aws_node_group_deployment_serial is defined else asgs.results | scale_groups_serial(openshift_aws_node_group_upgrade) }}"
- openshift_aws_current_asgs: "{{ openshift_aws_current_asgs + [asgs.results[0]['auto_scaling_group_name']] if asgs.results else openshift_aws_current_asgs }}"
- - name: dump deployment serial
- debug:
- msg: "Deployment serial: {{ l_deployment_serial }}"
- - name: dump current_asgs
- debug:
- msg: "openshift_aws_current_asgs: {{ openshift_aws_current_asgs }}"
- - name: set appropriate vars for upgrade resume
- set_fact:
- openshift_aws_created_asgs: "{{ [openshift_aws_node_group.name ~ ' ' ~ l_deployment_serial]
- | union(openshift_aws_created_asgs) | list }}"
- when:
- - openshift_aws_node_group_upgrade | default(False)
- - asgs.results|length == 2
- - when:
- - openshift_aws_create_iam_role
- - asgs.results|length != 2
- include_tasks: iam_role.yml
- - when:
- - openshift_aws_create_launch_config
- - asgs.results|length != 2
- include_tasks: launch_config.yml
- - when:
- - openshift_aws_create_scale_group
- - asgs.results|length != 2
- include_tasks: scale_group.yml
|