kubeasz/roles/prepare/tasks/main.yml

54 lines
1.6 KiB
YAML
Raw Normal View History

2018-09-02 14:08:51 +08:00
# 系统基础软件环境
2021-10-17 10:33:00 +08:00
- name: apt更新缓存刷新
apt: update_cache=yes cache_valid_time=72000
ignore_errors: true
when:
- 'ansible_distribution in ["Ubuntu","Debian"]'
- 'INSTALL_SOURCE != "offline"'
2019-07-16 22:47:53 +08:00
2019-06-28 12:53:04 +08:00
- import_tasks: ubuntu.yml
2019-05-19 22:01:40 +08:00
when: 'ansible_distribution in ["Ubuntu","Debian"]'
2018-09-02 14:08:51 +08:00
- import_tasks: centos.yml
2020-12-30 11:25:54 +08:00
when: 'ansible_distribution in ["CentOS","RedHat","Amazon","Aliyun"]'
2018-09-02 14:08:51 +08:00
# 公共系统参数设置
- import_tasks: common.yml
2017-11-11 19:14:21 +08:00
- name: prepare some dirs
file: name={{ item }} state=directory
with_items:
- "{{ bin_dir }}"
- "{{ ca_dir }}"
2019-05-28 09:10:44 +08:00
- /root/.kube
2017-11-11 19:14:21 +08:00
2021-10-17 10:33:00 +08:00
# 某些系统没有/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
2022-06-13 19:03:45 +08:00
- name: 写入环境变量$PATH
2018-09-02 14:08:51 +08:00
lineinfile:
dest: ~/.bashrc
state: present
2022-06-13 19:03:45 +08:00
regexp: 'custom PATH'
2022-07-10 10:09:07 +08:00
line: 'export PATH={{ bin_dir }}:$PATH # generated by kubeasz:custom PATH'
2019-05-28 23:46:22 +08:00
2022-06-13 19:03:45 +08:00
- 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]"
2022-06-09 22:33:46 +08:00
2022-06-13 19:03:45 +08:00
- name: 添加 local registry hosts 解析
lineinfile:
dest: /etc/hosts
state: present
regexp: 'easzlab.io.local'
line: "{{ ansible_env.SSH_CLIENT.split(' ')[0] }} easzlab.io.local"