main.yml 1.7 KB

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