netplugin.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ---
  2. - include: netplugin_firewalld.yml
  3. when: has_firewalld
  4. - include: netplugin_iptables.yml
  5. when: has_iptables
  6. - name: Netplugin | Ensure localhost entry correct in /etc/hosts
  7. lineinfile:
  8. dest: /etc/hosts
  9. regexp: '^127\.0\.0\.1.*'
  10. line: '127.0.0.1 localhost {{ ansible_hostname }}'
  11. state: present
  12. - name: Netplugin | Remove incorrect localhost entry in /etc/hosts
  13. lineinfile:
  14. dest: /etc/hosts
  15. regexp: '^::1. localhost '
  16. line: '::1 '
  17. state: absent
  18. - include: ovs.yml
  19. when: netplugin_driver == "ovs"
  20. - name: Netplugin | Create Netplugin bin symlink
  21. file:
  22. src: "{{ contiv_current_release_directory }}/netplugin"
  23. dest: "{{ bin_dir }}/netplugin"
  24. state: link
  25. - name: Netplugin | Ensure cni_bin_dir exists
  26. file:
  27. path: "{{ cni_bin_dir }}"
  28. recurse: yes
  29. state: directory
  30. - name: Netplugin | Create CNI bin symlink
  31. file:
  32. src: "{{ contiv_current_release_directory }}/contivk8s"
  33. dest: "{{ cni_bin_dir }}/contivk8s"
  34. state: link
  35. - name: Netplugin | Copy CNI loopback bin
  36. copy:
  37. src: loopback
  38. dest: "{{ cni_bin_dir }}/loopback"
  39. mode: 0755
  40. - name: Netplugin | Ensure kube_plugin_dir and cni/net.d directories exist
  41. file:
  42. path: "{{ item }}"
  43. recurse: yes
  44. state: directory
  45. with_items:
  46. - "{{ kube_plugin_dir }}"
  47. - "/etc/cni/net.d"
  48. - name: Netplugin | Ensure contiv_config_dir exists
  49. file:
  50. path: "{{ contiv_config_dir }}"
  51. recurse: yes
  52. state: directory
  53. - name: Netplugin | Copy contiv_cni.conf file
  54. copy:
  55. src: contiv_cni.conf
  56. dest: "{{ item }}"
  57. with_items:
  58. - "{{ kube_plugin_dir }}/contiv_cni.conf"
  59. - "/etc/cni/net.d"
  60. # notify: restart kubelet
  61. - name: Netplugin | Setup contiv.json config for the cni plugin
  62. template:
  63. src: contiv.cfg.j2
  64. dest: "{{ contiv_config_dir }}/contiv.json"
  65. notify: restart netplugin
  66. - name: Netplugin | Copy environment file for netplugin
  67. template:
  68. src: netplugin.j2
  69. dest: /etc/default/netplugin
  70. mode: 0644
  71. notify: restart netplugin
  72. - name: Docker | Make sure proxy setting exists
  73. lineinfile:
  74. dest: /etc/sysconfig/docker-network
  75. regexp: '^https_proxy.*'
  76. line: 'https_proxy={{ https_proxy }}'
  77. state: present
  78. register: docker_updated
  79. - name: Netplugin | Copy systemd unit for netplugin
  80. template:
  81. src: netplugin.service
  82. dest: /etc/systemd/system/netplugin.service
  83. notify: reload systemd
  84. - name: systemd reload
  85. command: systemctl daemon-reload
  86. when: docker_updated|changed
  87. - name: Docker | Restart docker
  88. service:
  89. name: docker
  90. state: restarted
  91. when: docker_updated|changed
  92. - name: Netplugin | Enable Netplugin
  93. service:
  94. name: netplugin
  95. enabled: yes
  96. - name: Netplugin | Start Netplugin
  97. service:
  98. name: netplugin
  99. state: started
  100. register: netplugin_started
  101. # notify: restart kubelet