kubeasz/roles/prepare/tasks/main.yml

73 lines
1.8 KiB
YAML
Raw Normal View History

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: 集群hosts文件更新
# copy: src=hosts.j2 dest=/etc/hosts
2017-11-11 19:14:21 +08:00
- name: 写入环境变量$PATH
2017-12-14 23:09:56 +08:00
shell: "sed -i '/export PATH=/d' /etc/profile && \
2017-12-11 11:06:00 +08:00
echo export PATH={{ bin_dir }}:$PATH >> /etc/profile"
2017-11-11 19:14:21 +08:00
- name: 下载证书工具 CFSSL
copy: src={{ base_dir }}/bin/{{ item }} dest={{ bin_dir }}/{{ item }} mode=0755
with_items:
- cfssl
- cfssl-certinfo
- cfssljson
- name: 分发CA 证书
copy: src={{ item }} dest={{ ca_dir }}/{{ item }} mode=0644
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
# 删除默认安装
- name: 删除centos默认安装
when: ansible_distribution == "CentOS"
yum: name={{ item }} state=absent
with_items:
- firewalld
- firewalld-filesystem
- python-firewall
2017-12-15 17:27:56 +08:00
- name: 关闭 selinux
shell: "setenforce 0 && echo SELINUX=disabled > /etc/selinux/config"
when: ansible_distribution == "CentOS"
ignore_errors: true
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
- name: 加载br_netfilter模块
2018-01-13 11:33:40 +08:00
modprobe: name=br_netfilter state=present
ignore_errors: true
2018-01-13 11:33:40 +08:00
#shell: "modprobe br_netfilter"
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