2015-10-03 20:19:50 +00:00
|
|
|
---
|
2016-11-09 10:44:41 +00:00
|
|
|
- name: Flannel | Set Flannel etcd configuration
|
|
|
|
command: |-
|
|
|
|
{{ bin_dir }}/etcdctl --peers={{ etcd_access_addresses }} \
|
|
|
|
set /{{ cluster_name }}/network/config \
|
|
|
|
'{ "Network": "{{ kube_pods_subnet }}", "SubnetLen": {{ kube_network_node_prefix }}, "Backend": { "Type": "{{ flannel_backend_type }}" } }'
|
|
|
|
delegate_to: "{{groups['etcd'][0]}}"
|
|
|
|
run_once: true
|
2016-05-09 04:42:42 +00:00
|
|
|
|
2016-12-30 12:47:12 +00:00
|
|
|
- name: Flannel | Create flannel certs directory
|
|
|
|
file:
|
|
|
|
dest: "{{ flannel_cert_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: 0750
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
|
|
|
- name: Flannel | Link etcd certificates for flanneld
|
|
|
|
file:
|
|
|
|
src: "{{ etcd_cert_dir }}/{{ item.s }}"
|
|
|
|
dest: "{{ flannel_cert_dir }}/{{ item.d }}"
|
|
|
|
state: hard
|
|
|
|
force: yes
|
|
|
|
with_items:
|
|
|
|
- {s: "ca.pem", d: "ca_cert.crt"}
|
|
|
|
- {s: "node-{{ inventory_hostname }}.pem", d: "cert.crt"}
|
|
|
|
- {s: "node-{{ inventory_hostname }}-key.pem", d: "key.pem"}
|
|
|
|
|
2016-01-09 09:45:50 +00:00
|
|
|
- name: Flannel | Create flannel pod manifest
|
2015-10-03 20:19:50 +00:00
|
|
|
template:
|
2016-01-30 15:04:47 +00:00
|
|
|
src: flannel-pod.yml
|
2016-12-13 10:43:06 +00:00
|
|
|
dest: "{{kube_manifest_dir}}/flannel-pod.manifest"
|
2016-12-07 15:57:05 +00:00
|
|
|
notify: Flannel | delete default docker bridge
|
2016-01-09 09:45:50 +00:00
|
|
|
|
|
|
|
- name: Flannel | Wait for flannel subnet.env file presence
|
|
|
|
wait_for:
|
|
|
|
path: /run/flannel/subnet.env
|
|
|
|
delay: 5
|
2016-02-19 17:48:53 +00:00
|
|
|
timeout: 600
|
2016-01-09 09:45:50 +00:00
|
|
|
|
2016-01-30 15:04:47 +00:00
|
|
|
- name: Flannel | Get flannel_subnet from subnet.env
|
2016-01-09 09:45:50 +00:00
|
|
|
shell: cat /run/flannel/subnet.env | awk -F'=' '$1 == "FLANNEL_SUBNET" {print $2}'
|
|
|
|
register: flannel_subnet_output
|
|
|
|
changed_when: false
|
2017-02-06 18:13:21 +00:00
|
|
|
check_mode: no
|
2016-01-09 09:45:50 +00:00
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
flannel_subnet: "{{ flannel_subnet_output.stdout }}"
|
|
|
|
|
2016-01-30 15:04:47 +00:00
|
|
|
- name: Flannel | Get flannel_mtu from subnet.env
|
2016-01-09 09:45:50 +00:00
|
|
|
shell: cat /run/flannel/subnet.env | awk -F'=' '$1 == "FLANNEL_MTU" {print $2}'
|
|
|
|
register: flannel_mtu_output
|
|
|
|
changed_when: false
|
2017-02-06 18:13:21 +00:00
|
|
|
check_mode: no
|
2016-01-09 09:45:50 +00:00
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
flannel_mtu: "{{ flannel_mtu_output.stdout }}"
|
2016-01-30 15:04:47 +00:00
|
|
|
|
2016-11-04 21:40:14 +00:00
|
|
|
- set_fact:
|
|
|
|
docker_options_file: >-
|
|
|
|
{%- if ansible_os_family == "Debian" -%}/etc/default/docker{%- elif ansible_os_family == "RedHat" -%}/etc/sysconfig/docker{%- endif -%}
|
2016-12-08 13:36:00 +00:00
|
|
|
tags: facts
|
2016-11-04 21:40:14 +00:00
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
docker_options_name: >-
|
|
|
|
{%- if ansible_os_family == "Debian" -%}DOCKER_OPTS{%- elif ansible_os_family == "RedHat" -%}other_args{%- endif -%}
|
2016-12-08 13:36:00 +00:00
|
|
|
tags: facts
|
2016-11-04 21:40:14 +00:00
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
docker_network_options: '"--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"'
|
|
|
|
|
2016-12-21 18:06:12 +00:00
|
|
|
- name: Flannel | Ensure path for docker network systemd drop-in
|
|
|
|
file:
|
|
|
|
path: "/etc/systemd/system/docker.service.d"
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
|
2016-11-04 21:40:14 +00:00
|
|
|
- name: Flannel | Create docker network systemd drop-in
|
2016-08-30 16:17:41 +00:00
|
|
|
template:
|
2016-11-04 21:40:14 +00:00
|
|
|
src: flannel-options.conf.j2
|
2016-08-30 16:17:41 +00:00
|
|
|
dest: "/etc/systemd/system/docker.service.d/flannel-options.conf"
|
|
|
|
notify:
|
2016-12-07 15:57:05 +00:00
|
|
|
- Flannel | restart docker
|