mirror of https://github.com/easzlab/kubeasz.git
69 lines
2.3 KiB
YAML
69 lines
2.3 KiB
YAML
# 系统基础软件环境
|
||
- name: apt更新缓存刷新
|
||
apt: update_cache=yes cache_valid_time=72000
|
||
ignore_errors: true
|
||
when:
|
||
- 'ansible_distribution in ["Ubuntu","Debian"]'
|
||
- 'INSTALL_SOURCE != "offline"'
|
||
|
||
- import_tasks: ubuntu.yml
|
||
when: 'ansible_distribution in ["Ubuntu","Debian"]'
|
||
|
||
- import_tasks: centos.yml
|
||
when: 'ansible_distribution in ["CentOS","RedHat","Amazon","Aliyun"]'
|
||
|
||
# 公共系统参数设置
|
||
- import_tasks: common.yml
|
||
|
||
- name: prepare some dirs
|
||
file: name={{ item }} state=directory
|
||
with_items:
|
||
- "{{ bin_dir }}"
|
||
- "{{ ca_dir }}"
|
||
- /root/.kube
|
||
- /opt/kube/images
|
||
|
||
# 某些系统没有/usr/bin/python,需要配置一个软链接,否则connection: local的任务会失败
|
||
# 如果仍旧出现任务失败,重新执行一遍即可 https://github.com/ansible/ansible/issues/64903
|
||
- name: symlink /usr/bin/python -> /usr/bin/python3
|
||
raw: |
|
||
if [ -f /usr/bin/python3 ] && [ ! -f /usr/bin/python ]; then
|
||
ln --symbolic /usr/bin/python3 /usr/bin/python;
|
||
fi
|
||
|
||
- name: 写入环境变量$PATH
|
||
lineinfile:
|
||
dest: ~/.bashrc
|
||
state: present
|
||
regexp: 'kubeasz'
|
||
line: 'export PATH={{ bin_dir }}:$PATH # generated by kubeasz'
|
||
|
||
- block:
|
||
- name: 添加 local registry hosts 解析
|
||
lineinfile:
|
||
dest: /etc/hosts
|
||
state: present
|
||
regexp: 'easzlab.io.local'
|
||
line: "{{ ansible_env.SSH_CLIENT.split(' ')[0] }} easzlab.io.local"
|
||
|
||
- name: 添加 kubectl 命令自动补全
|
||
lineinfile:
|
||
dest: ~/.bashrc
|
||
state: present
|
||
regexp: 'kubectl completion'
|
||
line: 'source <(kubectl completion bash)'
|
||
|
||
- name: 分发 kubeconfig配置文件
|
||
copy: src={{ cluster_dir }}/kubectl.kubeconfig dest=/root/.kube/config mode=0400
|
||
|
||
- name: 分发 kube-proxy.kubeconfig配置文件
|
||
copy: src={{ cluster_dir }}/kube-proxy.kubeconfig dest=/etc/kubernetes/kube-proxy.kubeconfig
|
||
|
||
- name: 分发controller/scheduler kubeconfig配置文件
|
||
copy: src={{ cluster_dir }}/{{ item }} dest=/etc/kubernetes/{{ item }}
|
||
with_items:
|
||
- kube-controller-manager.kubeconfig
|
||
- kube-scheduler.kubeconfig
|
||
when: "inventory_hostname in groups['kube_master']"
|
||
when: "inventory_hostname in groups['kube_master'] or inventory_hostname in groups['kube_node']"
|