kubeasz/roles/prepare/tasks/main.yml

70 lines
2.1 KiB
YAML
Raw Normal View History

2018-09-02 14:08:51 +08:00
# 系统基础软件环境
2019-07-16 22:47:53 +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-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
2019-05-19 22:01:40 +08:00
when: 'ansible_distribution in ["CentOS","RedHat","Amazon"]'
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
- name: 分发证书工具 CFSSL
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-09-02 14:08:51 +08:00
- name: 写入环境变量$PATH
lineinfile:
dest: ~/.bashrc
state: present
regexp: 'kubeasz'
line: 'export PATH={{ bin_dir }}:$PATH # generated by kubeasz'
2019-05-28 23:46:22 +08:00
- block:
- name: 分发证书相关
2020-12-25 11:53:00 +08:00
copy: src={{ cluster_dir }}/ssl/{{ item }} dest={{ ca_dir }}/{{ item }}
2019-05-28 23:46:22 +08:00
with_items:
- admin.pem
- admin-key.pem
- ca.pem
- ca-key.pem
- ca-config.json
- name: 添加 kubectl 命令自动补全
lineinfile:
dest: ~/.bashrc
state: present
regexp: 'kubectl completion'
line: 'source <(kubectl completion bash)'
- name: 分发 kubeconfig配置文件
copy: src=/root/.kube/config dest=/root/.kube/config
- name: 分发 kube-proxy.kubeconfig配置文件
2020-12-25 11:53:00 +08:00
copy: src={{ cluster_dir }}/kube-proxy.kubeconfig dest={{ cluster_dir }}/kube-proxy.kubeconfig
- name: 分发 kube-controller-manager.kubeconfig配置文件
2020-12-25 11:53:00 +08:00
copy: src={{ cluster_dir }}/kube-controller-manager.kubeconfig dest={{ cluster_dir }}/kube-controller-manager.kubeconfig
when: "inventory_hostname in groups['kube-master']"
- name: 分发 kube-scheduler.kubeconfig配置文件
2020-12-25 11:53:00 +08:00
copy: src={{ cluster_dir }}/kube-scheduler.kubeconfig dest={{ cluster_dir }}/kube-scheduler.kubeconfig
when: "inventory_hostname in groups['kube-master']"
2019-05-28 23:46:22 +08:00
when: "inventory_hostname in groups['kube-master'] or inventory_hostname in groups['kube-node']"