2017-11-11 19:14:21 +08:00
|
|
|
|
- name: prepare some dirs
|
|
|
|
|
file: name={{ item }} state=directory
|
|
|
|
|
with_items:
|
|
|
|
|
- "{{ bin_dir }}"
|
|
|
|
|
- "{{ ca_dir }}"
|
|
|
|
|
- /root/.kube
|
|
|
|
|
- /etc/docker
|
|
|
|
|
|
|
|
|
|
- name: 写入环境变量$PATH
|
2018-05-04 15:27:46 +08:00
|
|
|
|
lineinfile:
|
2018-05-06 09:08:09 +08:00
|
|
|
|
dest: ~/.bashrc
|
2018-05-04 22:11:08 +08:00
|
|
|
|
state: present
|
2018-05-04 15:27:46 +08:00
|
|
|
|
regexp: 'kubeasz'
|
|
|
|
|
line: 'export PATH={{ bin_dir }}:$PATH # generated by kubeasz'
|
2017-11-11 19:14:21 +08:00
|
|
|
|
|
2018-03-16 18:23:34 +08:00
|
|
|
|
- name: 下载证书工具 CFSSL和 kubectl
|
2017-11-11 19:14:21 +08:00
|
|
|
|
copy: src={{ base_dir }}/bin/{{ item }} dest={{ bin_dir }}/{{ item }} mode=0755
|
|
|
|
|
with_items:
|
|
|
|
|
- cfssl
|
|
|
|
|
- cfssl-certinfo
|
|
|
|
|
- cfssljson
|
2018-03-16 18:23:34 +08:00
|
|
|
|
- kubectl
|
2018-05-11 11:07:14 +08:00
|
|
|
|
tags: upgrade_k8s
|
2018-03-16 18:23:34 +08:00
|
|
|
|
|
|
|
|
|
- name: 安装kubeconfig配置文件
|
|
|
|
|
copy: src=/root/.kube/config dest=/root/.kube/config
|
2017-11-11 19:14:21 +08:00
|
|
|
|
|
|
|
|
|
- name: 分发CA 证书
|
2018-03-16 18:23:34 +08:00
|
|
|
|
copy: src={{ ca_dir }}/{{ item }} dest={{ ca_dir }}/{{ item }} mode=0644
|
2017-11-11 19:14:21 +08:00
|
|
|
|
with_items:
|
|
|
|
|
- ca.pem
|
|
|
|
|
- ca-key.pem
|
|
|
|
|
- ca.csr
|
|
|
|
|
- ca-config.json
|
2017-12-15 17:27:56 +08:00
|
|
|
|
|
|
|
|
|
# 先拉取下节点的ansible setup信息,起到缓存效果,否则后续when 判断可能失败
|
|
|
|
|
- name: 缓存ansilbe setup信息
|
|
|
|
|
setup: gather_subset=min
|
|
|
|
|
|
2017-12-15 21:20:26 +08:00
|
|
|
|
# 删除默认安装
|
|
|
|
|
- name: 删除ubuntu默认安装
|
|
|
|
|
when: ansible_distribution == "Ubuntu"
|
|
|
|
|
apt: name={{ item }} state=absent
|
|
|
|
|
with_items:
|
|
|
|
|
- ufw
|
|
|
|
|
- lxd
|
|
|
|
|
- lxd-client
|
|
|
|
|
- lxcfs
|
|
|
|
|
- lxc-common
|
|
|
|
|
|
2018-03-29 09:24:04 +08:00
|
|
|
|
# Ubuntu 安装基础软件包
|
|
|
|
|
- name: 安装 ubuntu基础软件
|
|
|
|
|
when: ansible_distribution == "Ubuntu"
|
|
|
|
|
apt: name={{ item }} state=latest
|
|
|
|
|
with_items:
|
2018-03-29 16:27:26 +08:00
|
|
|
|
- jq # 轻量JSON处理程序,安装docker查询镜像需要
|
2018-04-08 09:39:59 +08:00
|
|
|
|
- socat # 用于port forwarding
|
2018-03-29 16:27:26 +08:00
|
|
|
|
- nfs-common # 挂载nfs 共享文件需要 (创建基于 nfs的PV 需要)
|
2018-04-02 13:52:05 +08:00
|
|
|
|
- conntrack # network connection cleanup 用到
|
2018-04-10 18:06:12 +08:00
|
|
|
|
- bash-completion
|
2018-03-29 09:24:04 +08:00
|
|
|
|
|
2018-03-16 17:52:02 +08:00
|
|
|
|
- block:
|
|
|
|
|
- name: 删除centos默认安装
|
|
|
|
|
yum: name={{ item }} state=absent
|
|
|
|
|
with_items:
|
|
|
|
|
- firewalld
|
|
|
|
|
- python-firewall
|
|
|
|
|
- firewalld-filesystem
|
2018-05-24 00:08:09 +08:00
|
|
|
|
|
|
|
|
|
- name: 添加EPEL仓库
|
|
|
|
|
yum: name=epel-release state=latest
|
|
|
|
|
|
2018-03-16 17:52:02 +08:00
|
|
|
|
- name: 安装基础软件包
|
2018-03-29 09:24:04 +08:00
|
|
|
|
yum: name={{ item }} state=latest
|
2018-03-16 17:52:02 +08:00
|
|
|
|
with_items:
|
2018-03-29 16:27:26 +08:00
|
|
|
|
- jq # 轻量JSON处理程序,安装docker查询镜像需要
|
2018-04-08 09:39:59 +08:00
|
|
|
|
- socat # 用于port forwarding
|
2018-03-29 16:27:26 +08:00
|
|
|
|
- psmisc # 安装psmisc 才能使用命令killall,它在keepalive的监测脚本中使用到
|
|
|
|
|
- nfs-utils # 挂载nfs 共享文件需要 (创建基于 nfs的PV 需要)
|
2018-03-16 17:52:02 +08:00
|
|
|
|
- net-tools
|
|
|
|
|
- bash-completion
|
|
|
|
|
- name: 临时关闭 selinux
|
|
|
|
|
shell: "setenforce 0"
|
|
|
|
|
failed_when: false
|
|
|
|
|
- name: 永久关闭 selinux
|
|
|
|
|
lineinfile:
|
|
|
|
|
dest: /etc/selinux/config
|
2018-05-17 22:29:43 +08:00
|
|
|
|
regexp: "^SELINUX="
|
2018-03-16 17:52:02 +08:00
|
|
|
|
line: "SELINUX=disabled"
|
2018-03-19 14:37:43 +08:00
|
|
|
|
when: ansible_distribution == "CentOS"
|
2017-12-15 21:20:26 +08:00
|
|
|
|
|
2018-03-16 17:52:02 +08:00
|
|
|
|
- name: 添加 kubectl 命令自动补全
|
2018-05-04 22:11:08 +08:00
|
|
|
|
lineinfile:
|
2018-05-06 09:08:09 +08:00
|
|
|
|
dest: ~/.bashrc
|
2018-05-04 22:11:08 +08:00
|
|
|
|
state: present
|
|
|
|
|
regexp: 'kubectl completion'
|
|
|
|
|
line: 'source <(kubectl completion bash)'
|
2017-12-28 14:34:04 +08:00
|
|
|
|
|
|
|
|
|
# 设置系统参数for k8s
|
|
|
|
|
# 消除docker info 警告WARNING: bridge-nf-call-ip[6]tables is disabled
|
|
|
|
|
- name: 设置系统参数
|
|
|
|
|
copy: src=95-k8s-sysctl.conf dest=/etc/sysctl.d/95-k8s-sysctl.conf
|
|
|
|
|
|
2018-01-11 18:34:46 +08:00
|
|
|
|
- name: 加载br_netfilter模块
|
2018-01-13 11:33:40 +08:00
|
|
|
|
modprobe: name=br_netfilter state=present
|
2018-03-06 11:05:19 +08:00
|
|
|
|
ignore_errors: true
|
2018-01-11 18:34:46 +08:00
|
|
|
|
|
2017-12-28 14:34:04 +08:00
|
|
|
|
- name: 生效系统参数
|
|
|
|
|
shell: "sysctl -p /etc/sysctl.d/95-k8s-sysctl.conf"
|
2018-01-08 18:59:18 +08:00
|
|
|
|
ignore_errors: true
|