Commit 52bcc792 authored by eric pellegrini's avatar eric pellegrini

added playbook and associated roles for setting the cluster

parent 204e0630
- hosts: master
remote_user: root
environment:
no_proxy: "{{ configured_no_proxy }}"
NO_PROXY: "{{ configured_no_proxy }}"
roles:
- role: roles/initialize-control-plane
- role: roles/initialize-cluster
become_user: kubernetes-admin
become: yes
---
# tasks file for initialize-cluster
- name: (re)initialize the kubernetes cluster
command: kubeadm init --node-name={{ master_name }} --pod-network-cidr={{ pod_network_cidr }}
# tasks file for create-admin
- name: remove previous kubernetes configuration file
file:
path: "{{ kubernetes_admin_home }}/.kube"
state: absent
- name: create ~/.kube file
file:
path: "{{ kubernetes_admin_home }}/.kube"
state: directory
- name: copy default kubernetes configuration file to ~/.kube
copy:
src: /etc/kubernetes/admin.conf
dest: "{{ kubernetes_admin_home }}/.kube/config"
remote_src: yes
become: yes
- name: change ownership of ~/.kube/config
file:
path: "{{ kubernetes_admin_home }}/.kube/config"
owner: kubernetes-admin
group: kubernetes
become: yes
- name: install cni provider for pod network
command: kubectl apply -f https://raw.githubusercontent.com/coreos/{{cni_provider}}/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-{{cni_provider}}.yml
- name: generate the kubernetes join command
command: kubeadm token create --print-join-command
register: kub_join_command
- name: copy join command to local file
local_action: copy content="{{ kub_join_command.stdout }}" dest="~/kub-join-command.sh"
---
# tasks file for initialize-cluster
- name: (re)initialize the kubernetes cluster
command: kubeadm init --node-name={{ inventory_hostname }} --pod-network-cidr={{ pod_network_cidr }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment