2015-12-31 00:11:33 +08:00
|
|
|
---
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: verify-settings.yml
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- asserts
|
2017-01-02 19:14:03 +08:00
|
|
|
|
2018-04-02 16:19:23 +08:00
|
|
|
# This is run before bin_dir is pinned because these tasks are run on localhost
|
|
|
|
- import_tasks: pre_upgrade.yml
|
|
|
|
tags:
|
|
|
|
- upgrade
|
|
|
|
|
2017-01-05 18:35:16 +08:00
|
|
|
- name: Force binaries directory for Container Linux by CoreOS
|
2016-08-27 01:24:47 +08:00
|
|
|
set_fact:
|
|
|
|
bin_dir: "/opt/bin"
|
2017-01-05 23:32:08 +08:00
|
|
|
when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- facts
|
2016-08-27 01:24:47 +08:00
|
|
|
|
2016-12-02 19:37:22 +08:00
|
|
|
- name: check bin dir exists
|
|
|
|
file:
|
|
|
|
path: "{{bin_dir}}"
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
become: true
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2016-08-22 20:45:42 +08:00
|
|
|
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: set_facts.yml
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- facts
|
2016-07-20 17:35:06 +08:00
|
|
|
|
2016-01-09 17:45:50 +08:00
|
|
|
- name: gather os specific variables
|
|
|
|
include_vars: "{{ item }}"
|
|
|
|
with_first_found:
|
|
|
|
- files:
|
2017-08-24 17:09:52 +08:00
|
|
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
|
|
|
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
|
|
|
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
|
|
|
|
- "{{ ansible_distribution|lower }}.yml"
|
|
|
|
- "{{ ansible_os_family|lower }}.yml"
|
|
|
|
- defaults.yml
|
2016-01-09 17:45:50 +08:00
|
|
|
paths:
|
2017-08-24 17:09:52 +08:00
|
|
|
- ../vars
|
2016-02-20 01:48:53 +08:00
|
|
|
skip: true
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- facts
|
2016-02-20 01:48:53 +08:00
|
|
|
|
2017-09-14 02:00:51 +08:00
|
|
|
- name: Create kubernetes directories
|
2016-01-30 23:04:47 +08:00
|
|
|
file:
|
2017-09-14 02:00:51 +08:00
|
|
|
path: "{{ item }}"
|
2016-01-30 23:04:47 +08:00
|
|
|
state: directory
|
2017-02-06 20:58:54 +08:00
|
|
|
owner: kube
|
2017-04-26 20:11:13 +08:00
|
|
|
when: inventory_hostname in groups['k8s-cluster']
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- kubelet
|
|
|
|
- k8s-secrets
|
|
|
|
- kube-controller-manager
|
|
|
|
- kube-apiserver
|
|
|
|
- bootstrap-os
|
|
|
|
- apps
|
|
|
|
- network
|
|
|
|
- master
|
|
|
|
- node
|
2017-09-14 02:00:51 +08:00
|
|
|
with_items:
|
|
|
|
- "{{ kube_config_dir }}"
|
|
|
|
- "{{ kube_config_dir }}/ssl"
|
|
|
|
- "{{ kube_manifest_dir }}"
|
|
|
|
- "{{ kube_script_dir }}"
|
2016-01-30 23:04:47 +08:00
|
|
|
|
2016-03-24 00:27:06 +08:00
|
|
|
- name: check cloud_provider value
|
|
|
|
fail:
|
2017-11-23 21:43:36 +08:00
|
|
|
msg: "If set the 'cloud_provider' var must be set either to 'generic', 'gce', 'aws', 'azure', 'openstack', 'vsphere', or external"
|
2017-04-26 20:11:13 +08:00
|
|
|
when:
|
|
|
|
- cloud_provider is defined
|
2017-11-23 21:43:36 +08:00
|
|
|
- cloud_provider not in ['generic', 'gce', 'aws', 'azure', 'openstack', 'vsphere', 'external']
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- cloud-provider
|
|
|
|
- facts
|
2016-03-29 20:50:22 +08:00
|
|
|
|
2016-01-30 23:04:47 +08:00
|
|
|
- name: Create cni directories
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
2017-02-06 20:58:54 +08:00
|
|
|
owner: kube
|
2016-01-30 23:04:47 +08:00
|
|
|
with_items:
|
|
|
|
- "/etc/cni/net.d"
|
|
|
|
- "/opt/cni/bin"
|
2017-04-26 20:11:13 +08:00
|
|
|
when:
|
2018-02-17 11:37:47 +08:00
|
|
|
- kube_network_plugin in ["calico", "weave", "canal", "flannel", "contiv", "cilium"]
|
2017-04-26 20:11:13 +08:00
|
|
|
- inventory_hostname in groups['k8s-cluster']
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- network
|
2018-02-17 11:37:47 +08:00
|
|
|
- cilium
|
2017-10-05 15:43:04 +08:00
|
|
|
- calico
|
|
|
|
- weave
|
|
|
|
- canal
|
contiv network support (#1914)
* Add Contiv support
Contiv is a network plugin for Kubernetes and Docker. It supports
vlan/vxlan/BGP/Cisco ACI technologies. It support firewall policies,
multiple networks and bridging pods onto physical networks.
* Update contiv version to 1.1.4
Update contiv version to 1.1.4 and added SVC_SUBNET in contiv-config.
* Load openvswitch module to workaround on CentOS7.4
* Set contiv cni version to 0.1.0
Correct contiv CNI version to 0.1.0.
* Use kube_apiserver_endpoint for K8S_API_SERVER
Use kube_apiserver_endpoint as K8S_API_SERVER to make contiv talks
to a available endpoint no matter if there's a loadbalancer or not.
* Make contiv use its own etcd
Before this commit, contiv is using a etcd proxy mode to k8s etcd,
this work fine when the etcd hosts are co-located with contiv etcd
proxy, however the k8s peering certs are only in etcd group, as a
result the etcd-proxy is not able to peering with the k8s etcd on
etcd group, plus the netplugin is always trying to find the etcd
endpoint on localhost, this will cause problem for all netplugins
not runnign on etcd group nodes.
This commit make contiv uses its own etcd, separate from k8s one.
on kube-master nodes (where net-master runs), it will run as leader
mode and on all rest nodes it will run as proxy mode.
* Use cp instead of rsync to copy cni binaries
Since rsync has been removed from hyperkube, this commit changes it
to use cp instead.
* Make contiv-etcd able to run on master nodes
* Add rbac_enabled flag for contiv pods
* Add contiv into CNI network plugin lists
* migrate contiv test to tests/files
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
* Add required rules for contiv netplugin
* Better handling json return of fwdMode
* Make contiv etcd port configurable
* Use default var instead of templating
* roles/download/defaults/main.yml: use contiv 1.1.7
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2017-11-29 22:24:16 +08:00
|
|
|
- contiv
|
2017-10-05 15:43:04 +08:00
|
|
|
- bootstrap-os
|
2016-01-30 23:04:47 +08:00
|
|
|
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: resolvconf.yml
|
2017-10-18 18:42:00 +08:00
|
|
|
when:
|
|
|
|
- dns_mode != 'none'
|
|
|
|
- resolvconf_mode == 'host_resolvconf'
|
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
|
|
|
- resolvconf
|
|
|
|
|
2016-01-26 01:16:56 +08:00
|
|
|
- name: Update package management cache (YUM)
|
2017-02-18 05:22:34 +08:00
|
|
|
yum:
|
|
|
|
update_cache: yes
|
|
|
|
name: '*'
|
2017-03-17 17:55:17 +08:00
|
|
|
register: yum_task_result
|
|
|
|
until: yum_task_result|succeeded
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
2017-04-26 20:11:13 +08:00
|
|
|
when:
|
|
|
|
- ansible_pkg_mgr == 'yum'
|
2017-12-06 17:00:41 +08:00
|
|
|
- ansible_distribution != 'RedHat'
|
2017-04-26 20:11:13 +08:00
|
|
|
- not is_atomic
|
2017-12-06 17:00:41 +08:00
|
|
|
tags: bootstrap-os
|
|
|
|
|
|
|
|
- name: Expire management cache (YUM) for Updation - Redhat
|
|
|
|
shell: yum clean expire-cache
|
|
|
|
register: expire_cache_output
|
|
|
|
until: expire_cache_output|succeeded
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
|
|
|
when:
|
|
|
|
- ansible_pkg_mgr == 'yum'
|
|
|
|
- ansible_distribution == 'RedHat'
|
|
|
|
- not is_atomic
|
|
|
|
tags: bootstrap-os
|
|
|
|
|
|
|
|
- name: Update package management cache (YUM) - Redhat
|
|
|
|
shell: yum makecache
|
|
|
|
register: make_cache_output
|
|
|
|
until: make_cache_output|succeeded
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
|
|
|
when:
|
|
|
|
- ansible_pkg_mgr == 'yum'
|
|
|
|
- ansible_distribution == 'RedHat'
|
|
|
|
- expire_cache_output.rc == 0
|
|
|
|
- not is_atomic
|
|
|
|
tags: bootstrap-os
|
|
|
|
|
2018-02-06 20:58:17 +08:00
|
|
|
- name: Update package management cache (zypper) - SUSE
|
|
|
|
shell: zypper -n --gpg-auto-import-keys ref
|
|
|
|
register: make_cache_output
|
|
|
|
until: make_cache_output|succeeded
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
|
|
|
when:
|
|
|
|
- ansible_pkg_mgr == 'zypper'
|
|
|
|
tags: bootstrap-os
|
2016-01-25 09:06:34 +08:00
|
|
|
|
2018-02-09 10:56:20 +08:00
|
|
|
- name: Update package management cache (APT)
|
2017-02-18 05:22:34 +08:00
|
|
|
apt:
|
|
|
|
update_cache: yes
|
|
|
|
cache_valid_time: 3600
|
2015-12-31 05:15:18 +08:00
|
|
|
when: ansible_os_family == "Debian"
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2016-01-09 17:45:50 +08:00
|
|
|
|
|
|
|
- name: Install python-dnf for latest RedHat versions
|
2016-02-13 18:59:46 +08:00
|
|
|
command: dnf install -y python-dnf yum
|
2017-03-17 17:55:17 +08:00
|
|
|
register: dnf_task_result
|
|
|
|
until: dnf_task_result|succeeded
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
2017-04-26 20:11:13 +08:00
|
|
|
when:
|
|
|
|
- ansible_distribution == "Fedora"
|
|
|
|
- ansible_distribution_major_version > 21
|
2017-10-16 15:03:33 +08:00
|
|
|
- not is_atomic
|
2016-01-09 17:45:50 +08:00
|
|
|
changed_when: False
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2015-12-31 21:07:02 +08:00
|
|
|
|
2016-04-11 04:08:13 +08:00
|
|
|
- name: Install epel-release on RedHat/CentOS
|
2018-02-07 14:53:09 +08:00
|
|
|
yum:
|
|
|
|
name: epel-release
|
|
|
|
state: present
|
2017-10-12 02:47:27 +08:00
|
|
|
when:
|
|
|
|
- ansible_distribution in ["CentOS","RedHat"]
|
|
|
|
- not is_atomic
|
|
|
|
- epel_enabled|bool
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2016-02-01 04:05:49 +08:00
|
|
|
|
2016-01-09 17:45:50 +08:00
|
|
|
- name: Install packages requirements
|
2015-12-31 21:07:02 +08:00
|
|
|
action:
|
|
|
|
module: "{{ ansible_pkg_mgr }}"
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: latest
|
2016-09-13 21:29:22 +08:00
|
|
|
register: pkgs_task_result
|
2017-03-17 17:55:17 +08:00
|
|
|
until: pkgs_task_result|succeeded
|
2016-09-13 21:29:22 +08:00
|
|
|
retries: 4
|
2016-09-15 17:23:27 +08:00
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|
2016-02-20 01:48:53 +08:00
|
|
|
with_items: "{{required_pkgs | default([]) | union(common_required_pkgs|default([]))}}"
|
2017-02-25 05:41:27 +08:00
|
|
|
when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] or is_atomic)
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2016-01-09 17:45:50 +08:00
|
|
|
|
2017-01-13 00:07:28 +08:00
|
|
|
# Todo : selinux configuration
|
2017-02-18 09:13:12 +08:00
|
|
|
- name: Confirm selinux deployed
|
|
|
|
stat:
|
|
|
|
path: /etc/selinux/config
|
|
|
|
when: ansible_os_family == "RedHat"
|
|
|
|
register: slc
|
|
|
|
|
2017-10-12 03:40:21 +08:00
|
|
|
- name: Set selinux policy
|
2017-02-18 05:22:34 +08:00
|
|
|
selinux:
|
|
|
|
policy: targeted
|
2017-10-12 03:40:21 +08:00
|
|
|
state: "{{ preinstall_selinux_state }}"
|
2017-04-26 20:11:13 +08:00
|
|
|
when:
|
|
|
|
- ansible_os_family == "RedHat"
|
|
|
|
- slc.stat.exists == True
|
2017-01-13 00:07:28 +08:00
|
|
|
changed_when: False
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2017-01-13 00:07:28 +08:00
|
|
|
|
2016-08-08 18:59:20 +08:00
|
|
|
- name: Disable IPv6 DNS lookup
|
|
|
|
lineinfile:
|
|
|
|
dest: /etc/gai.conf
|
|
|
|
line: "precedence ::ffff:0:0/96 100"
|
|
|
|
state: present
|
|
|
|
backup: yes
|
2017-04-26 20:11:13 +08:00
|
|
|
when:
|
|
|
|
- disable_ipv6_dns
|
|
|
|
- not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2016-08-08 18:59:20 +08:00
|
|
|
|
2017-02-09 17:16:52 +08:00
|
|
|
- name: set default sysctl file path
|
|
|
|
set_fact:
|
|
|
|
sysctl_file_path: "/etc/sysctl.d/99-sysctl.conf"
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2017-02-09 17:16:52 +08:00
|
|
|
|
|
|
|
- name: Stat sysctl file configuration
|
2017-02-18 05:22:34 +08:00
|
|
|
stat:
|
|
|
|
path: "{{sysctl_file_path}}"
|
2017-02-09 17:16:52 +08:00
|
|
|
register: sysctl_file_stat
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2017-02-09 17:16:52 +08:00
|
|
|
|
|
|
|
- name: Change sysctl file path to link source if linked
|
|
|
|
set_fact:
|
|
|
|
sysctl_file_path: "{{sysctl_file_stat.stat.lnk_source}}"
|
2017-04-26 20:11:13 +08:00
|
|
|
when:
|
|
|
|
- sysctl_file_stat.stat.islnk is defined
|
|
|
|
- sysctl_file_stat.stat.islnk
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2017-02-09 17:16:52 +08:00
|
|
|
|
2017-01-13 00:07:28 +08:00
|
|
|
- name: Enable ip forwarding
|
2017-02-09 16:28:44 +08:00
|
|
|
sysctl:
|
2017-02-09 17:16:52 +08:00
|
|
|
sysctl_file: "{{sysctl_file_path}}"
|
2017-02-09 16:28:44 +08:00
|
|
|
name: net.ipv4.ip_forward
|
|
|
|
value: 1
|
2017-01-13 00:07:28 +08:00
|
|
|
state: present
|
2017-10-27 01:06:21 +08:00
|
|
|
reload: yes
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2015-12-31 05:15:18 +08:00
|
|
|
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: etchosts.yml
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
|
|
|
- etchosts
|
2016-12-07 23:57:05 +08:00
|
|
|
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: dhclient-hooks.yml
|
2017-04-26 20:11:13 +08:00
|
|
|
when:
|
|
|
|
- dns_mode != 'none'
|
|
|
|
- resolvconf_mode == 'host_resolvconf'
|
|
|
|
- not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
|
|
|
- resolvconf
|
2017-01-11 22:08:24 +08:00
|
|
|
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: dhclient-hooks-undo.yml
|
2017-04-26 20:11:13 +08:00
|
|
|
when:
|
|
|
|
- dns_mode != 'none'
|
|
|
|
- resolvconf_mode != 'host_resolvconf'
|
|
|
|
- not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
|
|
|
- resolvconf
|
2017-01-11 22:08:24 +08:00
|
|
|
|
2016-12-12 21:14:22 +08:00
|
|
|
- name: Check if we are running inside a Azure VM
|
2017-02-18 05:22:34 +08:00
|
|
|
stat:
|
|
|
|
path: /var/lib/waagent/
|
2016-12-12 21:14:22 +08:00
|
|
|
register: azure_check
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|
2016-12-12 21:14:22 +08:00
|
|
|
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: growpart-azure-centos-7.yml
|
2017-04-26 20:11:13 +08:00
|
|
|
when:
|
|
|
|
- azure_check.stat.exists
|
|
|
|
- ansible_distribution in ["CentOS","RedHat"]
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- bootstrap-os
|