c12s-kubespray/roles/network_plugin/flannel/tasks/main.yml

82 lines
2.7 KiB
YAML
Raw Normal View History

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={{ network_plugin_etcd_access_endpoint }} \
2016-11-09 10:44:41 +00:00
set /{{ cluster_name }}/network/config \
'{ "Network": "{{ kube_pods_subnet }}", "SubnetLen": {{ kube_network_node_prefix }}, "Backend": { "Type": "{{ flannel_backend_type }}" } }'
delegate_to: "{{network_plugins_etcd_access_delagate}}"
2016-11-09 10:44:41 +00:00
run_once: true
2016-01-09 09:45:50 +00:00
- name: Flannel | Create flannel pod manifest
2015-10-03 20:19:50 +00:00
template:
src: flannel-pod.yml
dest: "{{kube_manifest_dir}}/flannel-pod.manifest"
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
timeout: 600
2016-01-09 09:45:50 +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
- set_fact:
flannel_subnet: "{{ flannel_subnet_output.stdout }}"
tags: facts
2016-01-09 09:45:50 +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
- set_fact:
flannel_mtu: "{{ flannel_mtu_output.stdout }}"
tags: facts
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 -%}
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 -%}
tags: facts
2016-11-04 21:40:14 +00:00
- set_fact:
docker_network_options: '"--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"'
tags: facts
2016-11-04 21:40:14 +00:00
- name: Flannel | Remove non-systemd docker daemon network options that don't match desired line
lineinfile:
dest: "{{ docker_options_file }}"
regexp: "^DOCKER_NETWORK_OPTIONS=(?!{{ docker_network_options|regex_escape() }})"
state: absent
when: ansible_service_mgr in ["sysvinit","upstart"]
- name: Flannel | Set non-systemd docker daemon network options
lineinfile:
dest: "{{ docker_options_file }}"
line: DOCKER_NETWORK_OPTIONS={{ docker_network_options }}
insertbefore: ^{{ docker_options_name }}=
owner: root
group: root
mode: 0644
notify:
- Flannel | restart docker
2016-11-04 21:40:14 +00:00
when: ansible_service_mgr in ["sysvinit","upstart"]
2016-08-30 16:34:34 +00:00
2016-11-04 21:40:14 +00:00
- name: Flannel | Create docker network systemd drop-in
template:
2016-11-04 21:40:14 +00:00
src: flannel-options.conf.j2
dest: "/etc/systemd/system/docker.service.d/flannel-options.conf"
notify:
- Flannel | restart docker
2016-11-04 21:40:14 +00:00
when: ansible_service_mgr == "systemd"
- meta: flush_handlers