launch.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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: master_names_output
  13. with_sequence: start=1 end={{ masters }}
  14. # These set_fact's cannot be combined
  15. - set_fact:
  16. master_names_string: "{% for item in master_names_output.results %}{{ item.ansible_facts.scratch }} {% endfor %}"
  17. - set_fact:
  18. master_names: "{{ master_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: node_names_output
  29. with_sequence: start=1 end={{ nodes }}
  30. # These set_fact's cannot be combined
  31. - set_fact:
  32. node_names_string: "{% for item in node_names_output.results %}{{ item.ansible_facts.scratch }} {% endfor %}"
  33. - set_fact:
  34. node_names: "{{ node_names_string.strip().split(' ') }}"
  35. - include: launch_instances.yml
  36. vars:
  37. instances: "{{ node_names }}"
  38. cluster: "{{ cluster_id }}"
  39. type: "{{ k8s_type }}"
  40. - hosts: "tag_env-{{ cluster_id }}"
  41. roles:
  42. - repos
  43. - os_update_latest
  44. - include: ../openshift-master/config.yml
  45. vars:
  46. oo_host_group_exp: "groups[\"tag_env-host-type-{{ cluster_id }}-openshift-master\"]"
  47. oo_env: "{{ cluster_id }}"
  48. - include: ../openshift-node/config.yml
  49. vars:
  50. oo_host_group_exp: "groups[\"tag_env-host-type-{{ cluster_id }}-openshift-node\"]"
  51. oo_env: "{{ cluster_id }}"