kubeasz/roles/prepare/tasks/main.yml

62 lines
1.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 系统基础软件环境
- 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
- /etc/cni/net.d
# 某些系统没有/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: 'custom PATH'
line: 'export PATH={{ bin_dir }}:$PATH # generated by kubeasz:custom PATH'
- name: ansible 控制端写入命令别名
lineinfile:
dest: ~/.bashrc
state: present
regexp: 'docker exec'
line: "alias dk='docker exec -it kubeasz' # generated by kubeasz"
when: "inventory_hostname == ansible_env.SSH_CLIENT.split(' ')[0]"
- name: 添加 kubectl 自动补全
lineinfile:
dest: ~/.bashrc
state: present
regexp: 'kubectl completion'
line: 'source <(kubectl completion bash) # generated by kubeasz'
- name: 添加 local registry hosts 解析
lineinfile:
dest: /etc/hosts
state: present
regexp: 'easzlab.io.local'
line: "{{ ansible_env.SSH_CLIENT.split(' ')[0] }} easzlab.io.local"