main.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. ---
  2. - name: Calico Node | Error if invalid cert arguments
  3. fail:
  4. msg: "Must provide all or none for the following etcd params: calico_etcd_cert_dir, calico_etcd_ca_cert_file, calico_etcd_cert_file, calico_etcd_key_file, calico_etcd_endpoints"
  5. when:
  6. - calico_etcd_cert_dir is defined or 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
  7. - not (calico_etcd_cert_dir is defined and 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)
  8. - name: Calico Node | Generate OpenShift-etcd certs
  9. include_role:
  10. name: etcd
  11. tasks_from: client_certificates
  12. when: calico_etcd_ca_cert_file is not defined or calico_etcd_cert_file is not defined or calico_etcd_key_file is not defined or calico_etcd_endpoints is not defined or calico_etcd_cert_dir is not defined
  13. vars:
  14. etcd_cert_prefix: calico.etcd-
  15. etcd_cert_config_dir: "{{ openshift.common.config_base }}/calico"
  16. embedded_etcd: "{{ hostvars[groups.oo_first_master.0].openshift.master.embedded_etcd }}"
  17. etcd_ca_host: "{{ groups.oo_etcd_to_config.0 }}"
  18. etcd_cert_subdir: "openshift-calico-{{ openshift.common.hostname }}"
  19. - name: Calico Node | Set etcd cert location facts
  20. when: calico_etcd_ca_cert_file is not defined or calico_etcd_cert_file is not defined or calico_etcd_key_file is not defined or calico_etcd_endpoints is not defined or calico_etcd_cert_dir is not defined
  21. set_fact:
  22. calico_etcd_ca_cert_file: "/etc/origin/calico/calico.etcd-ca.crt"
  23. calico_etcd_cert_file: "/etc/origin/calico/calico.etcd-client.crt"
  24. calico_etcd_key_file: "/etc/origin/calico/calico.etcd-client.key"
  25. calico_etcd_endpoints: "{{ hostvars[groups.oo_first_master.0].openshift.master.etcd_urls | join(',') }}"
  26. calico_etcd_cert_dir: "/etc/origin/calico/"
  27. - name: Calico Node | Error if no certs set.
  28. fail:
  29. msg: "Invalid etcd configuration for calico."
  30. when: item is not defined or item == ''
  31. with_items:
  32. - calico_etcd_ca_cert_file
  33. - calico_etcd_cert_file
  34. - calico_etcd_key_file
  35. - calico_etcd_endpoints
  36. - name: Calico Node | Assure the calico certs are present
  37. stat:
  38. path: "{{ item }}"
  39. with_items:
  40. - "{{ calico_etcd_ca_cert_file }}"
  41. - "{{ calico_etcd_cert_file }}"
  42. - "{{ calico_etcd_key_file }}"
  43. - name: Calico Node | Configure Calico service unit file
  44. template:
  45. dest: "/lib/systemd/system/calico.service"
  46. src: calico.service.j2
  47. - name: Calico Node | Enable calico
  48. become: yes
  49. systemd:
  50. name: calico
  51. daemon_reload: yes
  52. state: started
  53. enabled: yes
  54. register: start_result
  55. - name: Calico Node | Assure CNI conf dir exists
  56. become: yes
  57. file: path="{{ cni_conf_dir }}" state=directory
  58. - name: Calico Node | Generate Calico CNI config
  59. become: yes
  60. template:
  61. src: "10-calico.conf.j2"
  62. dest: "{{ cni_conf_dir }}/10-calico.conf"
  63. - name: Calico Node | Assures Kuberentes CNI bin dir exists
  64. become: yes
  65. file: path="{{ cni_bin_dir }}" state=directory
  66. - name: Calico Node | Download Calico CNI Plugin
  67. become: yes
  68. get_url:
  69. url: "{{ calico_url_cni }}"
  70. dest: "{{ cni_bin_dir }}"
  71. mode: a+x
  72. - name: Calico Node | Download Calico IPAM Plugin
  73. become: yes
  74. get_url:
  75. url: "{{ calico_url_ipam }}"
  76. dest: "{{ cni_bin_dir }}"
  77. mode: a+x
  78. - name: Calico Node | Download and extract standard CNI plugins
  79. become: yes
  80. unarchive:
  81. remote_src: True
  82. src: "{{ cni_url }}"
  83. dest: "{{ cni_bin_dir }}"
  84. - name: Calico Node | Assure Calico conf dir exists
  85. become: yes
  86. file: path=/etc/calico/ state=directory
  87. - name: Calico Node | Set calicoctl.cfg
  88. template:
  89. src: calicoctl.cfg.j2
  90. dest: "/etc/calico/calicoctl.cfg"