launch.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ---
  2. - name: Launch instance(s)
  3. hosts: localhost
  4. connection: local
  5. gather_facts: no
  6. vars_files:
  7. - vars.yml
  8. tasks:
  9. - set_fact: k8s_type="master"
  10. - name: "Generate master instance names(s)"
  11. set_fact: scratch="{{ cluster_id }}-{{ k8s_type }}-{{ '%05x' |format( 1048576 |random) }}"
  12. register: instance_names_output
  13. with_sequence: start=1 end={{ masters }}
  14. # These set_fact's cannot be combined
  15. - set_fact:
  16. instance_names_string: "{% for item in instance_names_output.results %}{{item.ansible_facts.scratch}} {% endfor %}"
  17. - set_fact:
  18. master_names: "{{ instance_names_string.strip().split(' ') }}"
  19. - include: launch_instances.yml
  20. vars:
  21. instances: "{{ master_names }}"
  22. cluster: "{{ cluster_id }}"
  23. type: "{{ k8s_type }}"
  24. group_name: "tag_env-host-type-{{ cluster_id }}-openshift-master"
  25. - set_fact: k8s_type="node"
  26. - name: "Generate node instance names(s)"
  27. set_fact: scratch="{{ cluster_id }}-{{ k8s_type }}-{{ '%05x' |format( 1048576 |random) }}"
  28. register: instance_names_output
  29. with_sequence: start=1 end={{ nodes }}
  30. # These set_fact's cannot be combined
  31. - set_fact:
  32. instance_names_string: "{% for item in instance_names_output.results %}{{item.ansible_facts.scratch}} {% endfor %}"
  33. - set_fact:
  34. node_names: "{{ instance_names_string.strip().split(' ') }}"
  35. - include: launch_instances.yml
  36. vars:
  37. instances: "{{ node_names }}"
  38. cluster: "{{ cluster_id }}"
  39. type: "{{ k8s_type }}"
  40. group_name: "tag_env-host-type-{{ cluster_id }}-openshift-node"
  41. - include: ../openshift-master/config.yml
  42. vars:
  43. oo_host_group_exp: "{{ master_names }}"
  44. oo_env: "{{ cluster_id }}"
  45. - include: ../openshift-node/config.yml
  46. vars:
  47. oo_host_group_exp: "{{ node_names }}"
  48. oo_env: "{{ cluster_id }}"