minikube_create.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ---
  2. - name: "Check if {{minikube_profile_name}} already exists"
  3. command:
  4. argv:
  5. - "{{minikube_binary}}"
  6. - "profile"
  7. - "list"
  8. register: profile_check_result
  9. changed_when: False
  10. - set_fact:
  11. profile_name: '{{ profile_check_result.stdout_lines | join("~") | regex_search(minikube_profile_name)}}'
  12. #- debug: msg="{{profile_check_result}}"
  13. - name: "Create minikube profile {{minikube_profile_name}}"
  14. command:
  15. argv:
  16. - "{{minikube_binary}}"
  17. - -p
  18. - "{{minikube_profile_name}}"
  19. - start
  20. - --memory={{minikube_memory}}
  21. - --cpus={{minikube_cpus}}
  22. - --disk-size={{minikube_disk_size}}
  23. - --delete-on-failure=true
  24. - --driver={{minikube_driver}}
  25. register: minikube_start_result
  26. when: profile_name | length == 0
  27. # - debug: msg="{{minikube_start_result}}"
  28. - name: "Fail when not started"
  29. fail:
  30. msg: "Unable to start minikube"
  31. when: minikube_start_result.rc is defined and minikube_start_result.rc != 0
  32. - name: "Set profile as current profile"
  33. command:
  34. argv:
  35. - "{{minikube_binary}}"
  36. - profile
  37. - "{{minikube_profile_name}}"
  38. changed_when: False
  39. - name: "Enabling addon"
  40. command:
  41. argv:
  42. - "{{minikube_binary}}"
  43. - addons
  44. - enable
  45. - "{{item}}"
  46. loop: "{{minikube_addons}}"
  47. register: addons_enable_result
  48. changed_when: False