certs.yml 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ---
  2. - name: Calico Node | Set cert flag
  3. set_fact:
  4. calico_certs_provided: "{{ calico_etcd_ca_cert_file is defined or calico_etcd_cert_file is defined or calico_etcd_key_file is defined or calico_etcd_endpoints is defined | bool }}"
  5. - name: Calico Node | Error if invalid cert arguments
  6. fail:
  7. msg: "Must provide all or none for the following etcd params: calico_etcd_ca_cert_file, calico_etcd_cert_file, calico_etcd_key_file, calico_etcd_endpoints"
  8. when:
  9. - calico_certs_provided
  10. - not (calico_etcd_ca_cert_file is defined and calico_etcd_cert_file is defined and calico_etcd_key_file is defined and calico_etcd_endpoints is defined)
  11. - name: Calico Node | Set separate Calico etcd flag
  12. set_fact:
  13. use_calico_etcd: "{{ calico_etcd_initial_cluster is defined or calico_etcd_generate_certs is defined or calico_etcd_service_ip is defined or calico_etcd_clients_port is defined or calico_etcd_peers_port is defined or calico_etcd_cert_dir is defined or calico_etcd_mount is defined | bool }}"
  14. - name: Calico Node | Error if using separate etcd with invalid arguments
  15. fail:
  16. msg: "Must provide all or none of the following etcd params: calico_etcd_initial_cluster, calico_etcd_generate_certs, calico_etcd_service_ip, calico_etcd_clients_port, calico_etcd_peers_port, calico_etcd_cert_dir, and calico_etcd_mount"
  17. when:
  18. - use_calico_etcd
  19. - not (calico_certs_provided and calico_etcd_initial_cluster is defined and calico_etcd_generate_certs is defined and calico_etcd_service_ip is defined and calico_etcd_clients_port is defined and calico_etcd_peers_port is defined and calico_etcd_cert_dir is defined and calico_etcd_mount is defined)
  20. - name: Calico Node | Configure separate Calico etcd and certs
  21. when: use_calico_etcd
  22. become: yes
  23. include_role:
  24. name: etcd
  25. tasks_from: server_certificates
  26. vars:
  27. etcd_cert_prefix: calico-etcd-
  28. etcd_cert_config_dir: "{{ calico_etcd_cert_dir }}"
  29. etcd_ca_host: "{{ groups.oo_etcd_to_config.0 }}"
  30. etcd_cert_subdir: "calico-etcd-{{ openshift.common.hostname }}"
  31. - name: Calico Node | Set etcd cert location facts
  32. when: not calico_certs_provided
  33. set_fact:
  34. calico_etcd_ca_cert_file: "/etc/origin/master/master.etcd-ca.crt"
  35. calico_etcd_cert_file: "/etc/origin/master/master.etcd-client.crt"
  36. calico_etcd_key_file: "/etc/origin/master/master.etcd-client.key"
  37. calico_etcd_endpoints: "{{ hostvars[groups.oo_first_master.0].openshift_master_etcd_urls | join(',') }}"
  38. - name: Calico Node | Error if no certs set.
  39. fail:
  40. msg: "Invalid etcd configuration for calico."
  41. when: item is not defined or item == ''
  42. with_items:
  43. - calico_etcd_ca_cert_file
  44. - calico_etcd_cert_file
  45. - calico_etcd_key_file
  46. - calico_etcd_endpoints
  47. - name: Calico Node | Assure the calico certs are present
  48. stat:
  49. path: "{{ item }}"
  50. get_checksum: false
  51. get_attributes: false
  52. get_mime: false
  53. with_items:
  54. - "{{ calico_etcd_ca_cert_file }}"
  55. - "{{ calico_etcd_cert_file }}"
  56. - "{{ calico_etcd_key_file }}"
  57. - name: Create secret
  58. oc_secret:
  59. name: calico-etcd-secrets
  60. state: present
  61. namespace: kube-system
  62. files:
  63. - name: etcd-key
  64. path: "{{ calico_etcd_key_file }}"
  65. - name: etcd-cert
  66. path: "{{ calico_etcd_cert_file }}"
  67. - name: etcd-ca
  68. path: "{{ calico_etcd_ca_cert_file }}"
  69. run_once: true