main.yml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ---
  2. # TODO: support new create-config command to generate node certs and config
  3. # TODO: recreate master/node configs if settings that affect the configs
  4. # change (hostname, public_hostname, ip, public_ip, etc)
  5. # TODO: create a failed_when condition
  6. - name: Create node server certificates
  7. command: >
  8. /usr/bin/openshift admin create-server-cert
  9. --overwrite=false
  10. --cert={{ openshift_cert_dir }}/node-{{ item.openshift.common.hostname }}/server.crt
  11. --key={{ openshift_cert_dir }}/node-{{ item.openshift.common.hostname }}/server.key
  12. --hostnames={{ [item.openshift.common.hostname,
  13. item.openshift.common.public_hostname]|unique|join(",") }}
  14. args:
  15. chdir: "{{ openshift_cert_dir_parent }}"
  16. creates: "{{ openshift_cert_dir_abs }}/node-{{ item.openshift.common.hostname }}/server.crt"
  17. with_items: openshift_nodes
  18. register: server_cert_result
  19. # TODO: create a failed_when condition
  20. - name: Create node client certificates
  21. command: >
  22. /usr/bin/openshift admin create-node-cert
  23. --overwrite=false
  24. --cert={{ openshift_cert_dir }}/node-{{ item.openshift.common.hostname }}/cert.crt
  25. --key={{ openshift_cert_dir }}/node-{{ item.openshift.common.hostname }}/key.key
  26. --node-name={{ item.openshift.common.hostname }}
  27. args:
  28. chdir: "{{ openshift_cert_dir_parent }}"
  29. creates: "{{ openshift_cert_dir_abs }}/node-{{ item.openshift.common.hostname }}/cert.crt"
  30. with_items: openshift_nodes
  31. register: node_cert_result
  32. # TODO: create a failed_when condition
  33. - name: Create kubeconfigs for nodes
  34. command: >
  35. /usr/bin/openshift admin create-kubeconfig
  36. --client-certificate={{ openshift_cert_dir }}/node-{{ item.openshift.common.hostname }}/cert.crt
  37. --client-key={{ openshift_cert_dir }}/node-{{ item.openshift.common.hostname }}/key.key
  38. --kubeconfig={{ openshift_cert_dir }}/node-{{ item.openshift.common.hostname }}/.kubeconfig
  39. --master={{ openshift.master.api_url }}
  40. --public-master={{ openshift.master.public_api_url }}
  41. args:
  42. chdir: "{{ openshift_cert_dir_parent }}"
  43. creates: "{{ openshift_cert_dir_abs }}/node-{{ item.openshift.common.hostname }}/.kubeconfig"
  44. with_items: openshift_nodes
  45. register: kubeconfig_result
  46. - name: Register unregistered nodes
  47. kubernetes_register_node:
  48. client_user: openshift-client
  49. name: "{{ item.openshift.common.hostname }}"
  50. api_version: "{{ openshift_kube_api_version }}"
  51. cpu: "{{ item.openshift.node.resources_cpu | default(None) }}"
  52. memory: "{{ item.openshift.node.resources_memory | default(None) }}"
  53. pod_cidr: "{{ item.openshift.node.pod_cidr | default(None) }}"
  54. host_ip: "{{ item.openshift.common.ip }}"
  55. labels: "{{ item.openshift.node.labels | default({}) }}"
  56. annotations: "{{ item.openshift.node.annotations | default({}) }}"
  57. external_id: "{{ item.openshift.node.external_id }}"
  58. # TODO: support customizing other attributes such as: client_config,
  59. # client_cluster, client_context, client_user
  60. # TODO: update for v1beta3 changes after rebase: hostnames, external_ips,
  61. # internal_ips, external_id
  62. with_items: openshift_nodes
  63. register: register_result