a15d626771
In order to enable offline/intranet installation cases: * Move DNS/resolvconf configuration to preinstall role. Remove skip_dnsmasq_k8s var as not needed anymore. * Preconfigure DNS stack early, which may be the case when downloading artifacts from intranet repositories. Do not configure K8s DNS resolvers for hosts /etc/resolv.conf yet early (as they may be not existing). * Reconfigure K8s DNS resolvers for hosts only after kubedns/dnsmasq was set up and before K8s apps to be created. * Move docker install task to early stage as well and unbind it from the etcd role's specific install path. Fix external flannel dependency on docker role handlers. Also fix the docker restart handlers' steps ordering to match the expected sequence (the socket then the service). * Add default resolver fact, which is the cloud provider specific and remove hardcoded GCE resolver. * Reduce default ndots for hosts /etc/resolv.conf to 2. Multiple search domains combined with high ndots values lead to poor performance of DNS stack and make ansible workers to fail very often with the "Timeout (12s) waiting for privilege escalation prompt:" error. * Update docs. Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
81 lines
2.6 KiB
YAML
81 lines
2.6 KiB
YAML
---
|
|
- 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
|
|
|
|
- name: Flannel | Create flannel pod manifest
|
|
template:
|
|
src: flannel-pod.yml
|
|
dest: /etc/kubernetes/manifests/flannel-pod.manifest
|
|
notify: Flannel | delete default docker bridge
|
|
|
|
- name: Flannel | Wait for flannel subnet.env file presence
|
|
wait_for:
|
|
path: /run/flannel/subnet.env
|
|
delay: 5
|
|
timeout: 600
|
|
|
|
- name: Flannel | Get flannel_subnet from subnet.env
|
|
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
|
|
|
|
- name: Flannel | Get flannel_mtu from subnet.env
|
|
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
|
|
|
|
- set_fact:
|
|
docker_options_file: >-
|
|
{%- if ansible_os_family == "Debian" -%}/etc/default/docker{%- elif ansible_os_family == "RedHat" -%}/etc/sysconfig/docker{%- endif -%}
|
|
tags: facts
|
|
|
|
- set_fact:
|
|
docker_options_name: >-
|
|
{%- if ansible_os_family == "Debian" -%}DOCKER_OPTS{%- elif ansible_os_family == "RedHat" -%}other_args{%- endif -%}
|
|
tags: facts
|
|
|
|
- set_fact:
|
|
docker_network_options: '"--bip={{ flannel_subnet }} --mtu={{ flannel_mtu }}"'
|
|
tags: facts
|
|
|
|
- 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
|
|
when: ansible_service_mgr in ["sysvinit","upstart"]
|
|
|
|
- name: Flannel | Create docker network systemd drop-in
|
|
template:
|
|
src: flannel-options.conf.j2
|
|
dest: "/etc/systemd/system/docker.service.d/flannel-options.conf"
|
|
notify:
|
|
- Flannel | restart docker
|
|
when: ansible_service_mgr == "systemd"
|
|
|
|
- meta: flush_handlers
|