You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
4.6 KiB

6 years ago
  1. ---
  2. - name: Helm | Make sure HELM_HOME directory exists
  3. file: path={{ helm_home_dir }} state=directory
  4. - name: Helm | Set up helm launcher
  5. include_tasks: "install_{{ helm_deployment_type }}.yml"
  6. - name: Helm | Lay Down Helm Manifests (RBAC)
  7. template:
  8. src: "{{item.file}}.j2"
  9. dest: "{{kube_config_dir}}/{{item.file}}"
  10. with_items:
  11. - {name: tiller, file: tiller-namespace.yml, type: namespace}
  12. - {name: tiller, file: tiller-sa.yml, type: sa}
  13. - {name: tiller, file: tiller-clusterrolebinding.yml, type: clusterrolebinding}
  14. register: manifests
  15. when:
  16. - dns_mode != 'none'
  17. - inventory_hostname == groups['kube-master'][0]
  18. - name: Helm | Apply Helm Manifests (RBAC)
  19. kube:
  20. name: "{{item.item.name}}"
  21. namespace: "{{ tiller_namespace }}"
  22. kubectl: "{{bin_dir}}/kubectl"
  23. resource: "{{item.item.type}}"
  24. filename: "{{kube_config_dir}}/{{item.item.file}}"
  25. state: "latest"
  26. with_items: "{{ manifests.results }}"
  27. when:
  28. - dns_mode != 'none'
  29. - inventory_hostname == groups['kube-master'][0]
  30. # Generate necessary certs for securing Helm and Tiller connection with TLS
  31. - name: Helm | Set up TLS
  32. include_tasks: "gen_helm_tiller_certs.yml"
  33. when: tiller_enable_tls
  34. - name: Helm | Install/upgrade helm
  35. command: >
  36. {{ bin_dir }}/helm init --tiller-namespace={{ tiller_namespace }}
  37. {% if helm_skip_refresh %} --skip-refresh{% endif %}
  38. {% if helm_stable_repo_url is defined %} --stable-repo-url {{ helm_stable_repo_url }}{% endif %}
  39. {% if inventory_hostname == groups['kube-master'][0] %}
  40. --upgrade --tiller-image={{ tiller_image_repo }}:{{ tiller_image_tag }}
  41. {% if rbac_enabled %} --service-account=tiller{% endif %}
  42. {% if tiller_node_selectors is defined %} --node-selectors {{ tiller_node_selectors }}{% endif %}
  43. {% if kube_version is version('v1.11.1', '>=') %} --override spec.template.spec.priorityClassName={% if tiller_namespace == 'kube-system' %}system-cluster-critical{% else %}k8s-cluster-critical{% endif %}{% endif %}
  44. {% if tiller_override is defined and tiller_override != "" %} --override {{ tiller_override }}{% endif %}
  45. {% if tiller_max_history is defined %} --history-max={{ tiller_max_history }}{% endif %}
  46. {% if tiller_enable_tls %} --tiller-tls --tiller-tls-verify --tiller-tls-cert={{ tiller_tls_cert }} --tiller-tls-key={{ tiller_tls_key }} --tls-ca-cert={{ tiller_tls_ca_cert }} {% endif %}
  47. {% if tiller_secure_release_info %} --override 'spec.template.spec.containers[0].command'='{/tiller,--storage=secret}' {% endif %}
  48. {% if tiller_wait %} --wait{% endif %}
  49. {% else %}
  50. --client-only
  51. {% endif %}
  52. register: install_helm
  53. changed_when: false
  54. environment: "{{proxy_env}}"
  55. # FIXME: https://github.com/helm/helm/issues/4063
  56. - name: Helm | Force apply tiller overrides if necessary
  57. shell: >
  58. {{ bin_dir }}/helm init --upgrade --tiller-image={{ tiller_image_repo }}:{{ tiller_image_tag }} --tiller-namespace={{ tiller_namespace }}
  59. {% if helm_skip_refresh %} --skip-refresh{% endif %}
  60. {% if helm_stable_repo_url is defined %} --stable-repo-url {{ helm_stable_repo_url }}{% endif %}
  61. {% if rbac_enabled %} --service-account=tiller{% endif %}
  62. {% if tiller_node_selectors is defined %} --node-selectors {{ tiller_node_selectors }}{% endif %}
  63. {% if kube_version is version('v1.11.1', '>=') %} --override spec.template.spec.priorityClassName={% if tiller_namespace == 'kube-system' %}system-cluster-critical{% else %}k8s-cluster-critical{% endif %}{% endif %}
  64. {% if tiller_override is defined and tiller_override != "" %} --override {{ tiller_override }}{% endif %}
  65. {% if tiller_max_history is defined %} --history-max={{ tiller_max_history }}{% endif %}
  66. {% if tiller_enable_tls %} --tiller-tls --tiller-tls-verify --tiller-tls-cert={{ tiller_tls_cert }} --tiller-tls-key={{ tiller_tls_key }} --tls-ca-cert={{ tiller_tls_ca_cert }} {% endif %}
  67. {% if tiller_secure_release_info %} --override 'spec.template.spec.containers[0].command'='{/tiller,--storage=secret}' {% endif %}
  68. {% if tiller_wait %} --wait{% endif %}
  69. --output yaml
  70. | {{bin_dir}}/kubectl apply -f -
  71. changed_when: false
  72. when:
  73. - (tiller_override is defined and tiller_override != "") or (kube_version is version('v1.11.1', '>='))
  74. - inventory_hostname == groups['kube-master'][0]
  75. environment: "{{proxy_env}}"
  76. - name: Helm | Set up bash completion
  77. shell: "umask 022 && {{ bin_dir }}/helm completion bash >/etc/bash_completion.d/helm.sh"
  78. when:
  79. - ((helm_container is defined and helm_container.changed) or (helm_task_result is defined and helm_task_result.changed))
  80. - not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]