build_node_group.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ---
  2. # When openshift_aws_use_custom_ami is '' then
  3. # we retrieve the latest build AMI.
  4. # Then set openshift_aws_ami to the ami.
  5. - when:
  6. - openshift_aws_ami == ''
  7. - openshift_aws_node_group.group not in openshift_aws_ami_map
  8. block:
  9. - name: fetch recently created AMI
  10. ec2_ami_find:
  11. region: "{{ openshift_aws_region }}"
  12. sort: creationDate
  13. sort_order: descending
  14. name: "{{ openshift_aws_ami_name }}*"
  15. ami_tags: "{{ openshift_aws_ami_tags }}"
  16. no_result_action: fail
  17. register: amiout
  18. - name: Set the openshift_aws_ami
  19. set_fact:
  20. openshift_aws_ami: "{{ amiout.results[0].ami_id }}"
  21. when:
  22. - "'results' in amiout"
  23. - amiout.results|length > 0
  24. # Need to set epoch time in one place to use for launch_config and scale_group
  25. - set_fact:
  26. l_epoch_time: "{{ ansible_date_time.epoch }}"
  27. #
  28. # query asg's and determine if we need to create the others.
  29. # if we find more than 1 for each type, then exit
  30. - name: query all asg's for this cluster
  31. ec2_asg_facts:
  32. region: "{{ openshift_aws_region }}"
  33. tags: "{{ {'kubernetes.io/cluster/' ~ openshift_aws_clusterid: openshift_aws_clusterid} | combine(openshift_aws_node_group.tags) }}"
  34. register: asgs
  35. - fail:
  36. msg: "Found more than 1 auto scaling group that matches the query for group: {{ openshift_aws_node_group }}"
  37. when:
  38. - asgs.results|length > 1
  39. - debug:
  40. msg: "{{ asgs }}"
  41. - name: set the value for the deployment_serial and the current asgs
  42. set_fact:
  43. # scale_groups_serial is a custom filter in role lib_utils
  44. 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) }}"
  45. openshift_aws_current_asgs: "{{ asgs.results | map(attribute='auto_scaling_group_name') | list | union(openshift_aws_current_asgs) }}"
  46. - name: dump deployment serial
  47. debug:
  48. msg: "Deployment serial: {{ l_deployment_serial }}"
  49. - name: dump current_asgs
  50. debug:
  51. msg: "openshift_aws_current_asgs: {{ openshift_aws_current_asgs }}"
  52. - when: openshift_aws_create_iam_role
  53. include_tasks: iam_role.yml
  54. - when: openshift_aws_create_launch_config
  55. include_tasks: launch_config.yml
  56. - when: openshift_aws_create_scale_group
  57. include_tasks: scale_group.yml