main.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ---
  2. - name: Create openshift_generated_configs_dir if it doesn't exist
  3. file:
  4. path: "{{ openshift_generated_configs_dir }}"
  5. state: directory
  6. - name: Generate the node client config
  7. command: >
  8. {{ openshift.common.admin_binary }} create-api-client-config
  9. --certificate-authority={{ openshift_master_ca_cert }}
  10. --client-dir={{ openshift_generated_configs_dir }}/node-{{ item.openshift.common.hostname }}
  11. --groups=system:nodes
  12. --master={{ openshift.master.api_url }}
  13. --signer-cert={{ openshift_master_ca_cert }}
  14. --signer-key={{ openshift_master_ca_key }}
  15. --signer-serial={{ openshift_master_ca_serial }}
  16. --user=system:node-{{ item.openshift.common.hostname }}
  17. args:
  18. chdir: "{{ openshift_generated_configs_dir }}"
  19. creates: "{{ openshift_generated_configs_dir }}/node-{{ item.openshift.common.hostname }}"
  20. with_items: nodes_needing_certs
  21. - name: Generate the node server certificate
  22. delegate_to: "{{ openshift_first_master }}"
  23. command: >
  24. {{ openshift.common.admin_binary }} create-server-cert
  25. --cert=server.crt --key=server.key --overwrite=true
  26. --hostnames={{ [item.openshift.common.hostname, item.openshift.common.public_hostname]|unique|join(",") }}
  27. --signer-cert={{ openshift_master_ca_cert }}
  28. --signer-key={{ openshift_master_ca_key }}
  29. --signer-serial={{ openshift_master_ca_serial }}
  30. args:
  31. chdir: "{{ openshift_generated_configs_dir }}/node-{{ item.openshift.common.hostname }}"
  32. creates: "{{ openshift_generated_configs_dir }}/node-{{ item.openshift.common.hostname }}/server.crt"
  33. with_items: nodes_needing_certs
  34. - name: Register unregistered nodes
  35. kubernetes_register_node:
  36. kubectl_cmd: "{{ [openshift.common.client_binary] }}"
  37. default_client_config: '~/.config/openshift/.config'
  38. name: "{{ item.openshift.common.hostname }}"
  39. api_version: "{{ openshift_kube_api_version }}"
  40. cpu: "{{ item.openshift.node.resources_cpu | default(None) }}"
  41. memory: "{{ item.openshift.node.resources_memory | default(None) }}"
  42. pod_cidr: "{{ item.openshift.node.pod_cidr | default(None) }}"
  43. host_ip: "{{ item.openshift.common.ip }}"
  44. labels: "{{ item.openshift.node.labels | default({}) }}"
  45. annotations: "{{ item.openshift.node.annotations | default({}) }}"
  46. with_items: openshift_nodes
  47. register: register_result