main.yml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ---
  2. - name: Install flannel
  3. sudo: true
  4. yum: pkg=flannel state=present
  5. when: ansible_pkg_mgr == "yum"
  6. - name: Install flannel
  7. sudo: true
  8. dnf: pkg=flannel state=present
  9. when: ansible_pkg_mgr == "dnf"
  10. - name: Set flannel etcd url
  11. sudo: true
  12. lineinfile:
  13. dest: /etc/sysconfig/flanneld
  14. backrefs: yes
  15. regexp: "^(FLANNEL_ETCD=)"
  16. line: '\1{{ etcd_hosts|join(",") }}'
  17. - name: Set flannel etcd key
  18. sudo: true
  19. lineinfile:
  20. dest: /etc/sysconfig/flanneld
  21. backrefs: yes
  22. regexp: "^(FLANNEL_ETCD_KEY=)"
  23. line: '\1{{ flannel_etcd_key }}'
  24. - name: Set flannel options
  25. sudo: true
  26. lineinfile:
  27. dest: /etc/sysconfig/flanneld
  28. backrefs: yes
  29. regexp: "^#?(FLANNEL_OPTIONS=)"
  30. line: '\1--iface {{ flannel_interface }} --etcd-cafile={{ etcd_peer_ca_file }} --etcd-keyfile={{ etcd_peer_key_file }} --etcd-certfile={{ etcd_peer_cert_file }}'
  31. - name: Enable flanneld
  32. sudo: true
  33. service:
  34. name: flanneld
  35. state: started
  36. enabled: yes
  37. register: start_result
  38. - name: Remove docker bridge ip
  39. sudo: true
  40. shell: ip a del `ip a show docker0 | grep "inet[[:space:]]" | awk '{print $2}'` dev docker0
  41. notify:
  42. - restart docker
  43. - restart node