You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.6 KiB

9 years ago
9 years ago
  1. ---
  2. - name: Flannel | Set Flannel etcd configuration
  3. command: |-
  4. {{ bin_dir }}/etcdctl --peers={{ etcd_access_addresses }} \
  5. set /{{ cluster_name }}/network/config \
  6. '{ "Network": "{{ kube_pods_subnet }}", "SubnetLen": {{ kube_network_node_prefix }}, "Backend": { "Type": "{{ flannel_backend_type }}" } }'
  7. delegate_to: "{{groups['etcd'][0]}}"
  8. run_once: true
  9. - name: Flannel | Create flannel certs directory
  10. file:
  11. dest: "{{ flannel_cert_dir }}"
  12. state: directory
  13. mode: 0750
  14. owner: root
  15. group: root
  16. - name: Flannel | Link etcd certificates for flanneld
  17. file:
  18. src: "{{ etcd_cert_dir }}/{{ item.s }}"
  19. dest: "{{ flannel_cert_dir }}/{{ item.d }}"
  20. state: hard
  21. force: yes
  22. with_items:
  23. - {s: "ca.pem", d: "ca_cert.crt"}
  24. - {s: "node-{{ inventory_hostname }}.pem", d: "cert.crt"}
  25. - {s: "node-{{ inventory_hostname }}-key.pem", d: "key.pem"}
  26. - name: Flannel | Create flannel pod manifest
  27. template:
  28. src: flannel-pod.yml
  29. dest: "{{kube_manifest_dir}}/flannel-pod.manifest"
  30. notify: Flannel | delete default docker bridge
  31. - name: Flannel | Wait for flannel subnet.env file presence
  32. wait_for:
  33. path: /run/flannel/subnet.env
  34. delay: 5
  35. timeout: 600
  36. - name: Flannel | Get flannel_subnet from subnet.env
  37. shell: cat /run/flannel/subnet.env | awk -F'=' '$1 == "FLANNEL_SUBNET" {print $2}'
  38. register: flannel_subnet_output
  39. changed_when: false
  40. - set_fact:
  41. flannel_subnet: "{{ flannel_subnet_output.stdout }}"
  42. tags: facts
  43. - name: Flannel | Get flannel_mtu from subnet.env
  44. shell: cat /run/flannel/subnet.env | awk -F'=' '$1 == "FLANNEL_MTU" {print $2}'
  45. register: flannel_mtu_output
  46. changed_when: false
  47. - set_fact:
  48. flannel_mtu: "{{ flannel_mtu_output.stdout }}"
  49. tags: facts
  50. - set_fact:
  51. docker_options_file: >-
  52. {%- if ansible_os_family == "Debian" -%}/etc/default/docker{%- elif ansible_os_family == "RedHat" -%}/etc/sysconfig/docker{%- endif -%}
  53. tags: facts
  54. - set_fact:
  55. docker_options_name: >-
  56. {%- if ansible_os_family == "Debian" -%}DOCKER_OPTS{%- elif ansible_os_family == "RedHat" -%}other_args{%- endif -%}
  57. tags: facts
  58. - set_fact:
  59. docker_network_options: '"--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"'
  60. tags: facts
  61. - name: Flannel | Ensure path for docker network systemd drop-in
  62. file:
  63. path: "/etc/systemd/system/docker.service.d"
  64. state: directory
  65. owner: root
  66. - name: Flannel | Create docker network systemd drop-in
  67. template:
  68. src: flannel-options.conf.j2
  69. dest: "/etc/systemd/system/docker.service.d/flannel-options.conf"
  70. notify:
  71. - Flannel | restart docker