provision_instance.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ---
  2. - name: set openshift_node_bootstrap to True when building AMI
  3. set_fact:
  4. openshift_node_bootstrap: True
  5. - include_tasks: vpc_and_subnet_id.yml
  6. - name: create instance for ami creation
  7. ec2:
  8. assign_public_ip: yes
  9. region: "{{ openshift_aws_region }}"
  10. key_name: "{{ openshift_aws_ssh_key_name }}"
  11. group: "{{ openshift_aws_build_ami_group }}"
  12. instance_type: m4.xlarge
  13. vpc_subnet_id: "{{ openshift_aws_subnet_id | default(subnetout.subnets[0].id) }}"
  14. image: "{{ openshift_aws_base_ami }}"
  15. volumes: "{{ openshift_aws_node_group_config_node_volumes }}"
  16. wait: yes
  17. exact_count: 1
  18. count_tag:
  19. Name: "{{ openshift_aws_base_ami_name }}"
  20. instance_tags:
  21. Name: "{{ openshift_aws_base_ami_name }}"
  22. - name: fetch newly created instances
  23. ec2_instance_facts:
  24. region: "{{ openshift_aws_region }}"
  25. filters:
  26. "tag:Name": "{{ openshift_aws_base_ami_name }}"
  27. instance-state-name: running
  28. register: instancesout
  29. retries: 20
  30. delay: 3
  31. until: instancesout.instances|length > 0
  32. - name: wait for ssh to become available
  33. wait_for:
  34. port: 22
  35. host: "{{ instancesout.instances[0].public_ip_address }}"
  36. timeout: 300
  37. search_regex: OpenSSH
  38. - name: add host to nodes
  39. add_host:
  40. groups: nodes,g_new_node_hosts
  41. name: "{{ instancesout.instances[0].public_dns_name }}"