main.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ---
  2. - name: Install flannel
  3. become: yes
  4. package:
  5. name: flannel
  6. state: present
  7. register: result
  8. until: result is succeeded
  9. - name: Set flannel etcd options
  10. become: yes
  11. lineinfile:
  12. dest: /etc/sysconfig/flanneld
  13. backrefs: yes
  14. regexp: "{{ item.regexp }}"
  15. line: "{{ item.line }}"
  16. with_items:
  17. - { regexp: "^(FLANNEL_ETCD=)", line: '\1{{ etcd_hosts|join(",") }}' }
  18. - { regexp: "^(FLANNEL_ETCD_ENDPOINTS=)", line: '\1{{ etcd_hosts|join(",") }}' }
  19. - { regexp: "^(FLANNEL_ETCD_KEY=)", line: '\1{{ flannel_etcd_key }}' }
  20. - { regexp: "^(FLANNEL_ETCD_PREFIX=)", line: '\1{{ flannel_etcd_key }}' }
  21. - name: Set flannel options
  22. become: yes
  23. lineinfile:
  24. dest: /etc/sysconfig/flanneld
  25. backrefs: yes
  26. regexp: "^#?(FLANNEL_OPTIONS=)"
  27. line: '\1--iface {{ flannel_interface }} --etcd-cafile={{ etcd_peer_ca_file }} --etcd-keyfile={{ etcd_peer_key_file }} --etcd-certfile={{ etcd_peer_cert_file }}'
  28. - name: Enable flanneld
  29. become: yes
  30. systemd:
  31. name: flanneld
  32. state: started
  33. enabled: yes
  34. register: start_result
  35. - name: Remove docker bridge ip
  36. become: yes
  37. shell: ip a del `ip a show docker0 | grep "inet[[:space:]]" | awk '{print $2}'` dev docker0
  38. notify:
  39. - restart docker
  40. - restart node
  41. - name: Enable Pod to Pod communication
  42. command: /sbin/iptables --wait -I FORWARD -d {{ openshift_cluster_network_cidr }} -i {{ flannel_interface }} -j ACCEPT -m comment --comment "Pod to Pod communication"
  43. notify:
  44. - save iptable rules
  45. - name: Allow external network access
  46. command: /sbin/iptables -t nat -A POSTROUTING -o {{ flannel_interface }} -j MASQUERADE -m comment --comment "Allow external network access"
  47. notify:
  48. - save iptable rules
  49. - name: Allow DNS access
  50. command: /sbin/iptables -A OS_FIREWALL_ALLOW -p {{ item }} -m {{ item }} --dport 53 -j ACCEPT -m comment --comment "Allow DNS {{ item }} access"
  51. with_items:
  52. - "tcp"
  53. - "udp"
  54. notify:
  55. - save iptable rules