72 lines
1.6 KiB
YAML
Executable File
72 lines
1.6 KiB
YAML
Executable File
---
|
|
- name: Setup couple variables
|
|
set_fact:
|
|
service_path: "/etc/systemd/system/"
|
|
when: app_env.target_os == "coreos"
|
|
|
|
- name: Setup couple variables
|
|
set_fact:
|
|
service_path: "/lib/systemd/system/"
|
|
when: app_env.target_os == "ubuntu"
|
|
|
|
- name: Make sure that cloud-init script has completed
|
|
wait_for:
|
|
path: "/run/cloud-init/result.json"
|
|
when: app_env.target_os == "ubuntu"
|
|
|
|
- name: Install Docker Engine
|
|
apt:
|
|
name: docker.io
|
|
update_cache: no
|
|
when: app_env.target_os == "ubuntu"
|
|
|
|
- name: Ensure config directories are present
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
mode: 0755
|
|
owner: root
|
|
with_items:
|
|
- "/etc/kubernetes"
|
|
- "/opt"
|
|
- "/opt/bin"
|
|
- "~/.ssh"
|
|
- "~/.kube"
|
|
|
|
- name: Place the certificate in the right place
|
|
copy:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.target }}"
|
|
mode: 0400
|
|
with_items:
|
|
- { src: "{{ app_env.public_key_file }}", target: "~/.ssh/id_rsa.pub" }
|
|
- { src: "{{ app_env.private_key_file }}", target: "~/.ssh/id_rsa" }
|
|
|
|
- name: List all k8s service on the node
|
|
stat:
|
|
path: "{{ service_path }}{{ item }}.service"
|
|
with_items:
|
|
- kubelet
|
|
- kube-proxy
|
|
- kube-controller-manager
|
|
- kube-schedule
|
|
- kube-apiserver
|
|
- docker
|
|
- flanneld
|
|
register: k8s_services
|
|
|
|
- name: Stop k8s related services if they exist
|
|
service:
|
|
name: "{{ item.item }}"
|
|
state: stopped
|
|
with_items: "{{ k8s_services.results }}"
|
|
when: item.stat.exists == true
|
|
no_log: True
|
|
|
|
- name: Setup /etc/hosts on every node
|
|
lineinfile:
|
|
dest: /etc/hosts
|
|
line: "{{ item }}"
|
|
state: present
|
|
with_lines: cat "{{ playbook_dir }}/run/k8shosts"
|