Restructuration des roles

master
guppy 2023-05-10 10:21:53 +02:00
parent 7828ed0fe7
commit 51a54da4ad
9 changed files with 78 additions and 65 deletions

6
calico.yaml 100644
View File

@ -0,0 +1,6 @@
---
- hosts: control-plane
name: "Install Calico CNI"
roles:
- role: calico
run_once: True

View File

@ -52,58 +52,7 @@
register: kubectl
- debug: var=kubectl.stdout_lines
- name: get calico conf
template:
src: calico.yaml.j2
dest: $HOME/calico.yaml
- name: apply calico conf1
shell: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/tigera-operator.yaml
register: apply1
- debug: var=apply1.stdout_lines
- name: apply calico conf2
shell: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/custom-resources.yaml
register: apply2
- debug: var=apply2.stdout_lines
- name: apply calico conf3
shell: kubectl apply -f calico.yaml
register: apply3
- debug: var=apply3.stdout_lines
- name: show pods
command: kubectl get pods --all-namespaces
register: pods
- debug: var=pods.stdout_lines
- name: "Cluster token"
shell: kubeadm token list | cut -d ' ' -f1 | sed -n '2p'
register: K8S_TOKEN
- name: "CA Hash"
shell: openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
register: K8S_MASTER_CA_HASH
- name: "IP and port"
shell: kubectl cluster-info | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | cut -d ' ' -f 7 | sed -n '1p' | cut -c 9-
register: K8S_IP_PORT
- name: "Add K8S Token and Hash to dummy host"
add_host:
name: "K8S_TOKEN_HOLDER"
token: "{{ K8S_TOKEN.stdout }}"
hash: "{{ K8S_MASTER_CA_HASH.stdout }}"
ipport: "{{ K8S_IP_PORT.stdout }}"
- name:
debug:
msg: "[Master] K8S_TOKEN_HOLDER K8S token is {{ hostvars['K8S_TOKEN_HOLDER']['token'] }}"
- name:
debug:
msg: "[Master] K8S_TOKEN_HOLDER K8S Hash is {{ hostvars['K8S_TOKEN_HOLDER']['hash'] }}"
- name:
debug:
msg: "[Master] K8S_TOKEN_HOLDER K8S IP and port is {{ hostvars['K8S_TOKEN_HOLDER']['ipport'] }}"

View File

@ -1,15 +1,6 @@
---
- hosts: control-plane
name: "Start OpenEBS"
tasks:
- name: Install openEBS
shell: kubectl apply -f https://openebs.github.io/charts/openebs-operator-lite.yaml
- name: Copy conf
become: yes
template:
src: openebs.yaml
dest: /etc/openebs.yaml
- name: Apply Conf
shell: kubectl apply -f /etc/openebs.yaml
name: "Install OpenEBS Storagee provider"
roles:
- role: openebs
run_once: True

35
pre-join.yaml 100644
View File

@ -0,0 +1,35 @@
---
- hosts: control-plane
name: "Export token hash and IPPORT for node to join"
tasks:
- name: "Cluster token"
shell: kubeadm token list | cut -d ' ' -f1 | sed -n '2p'
register: K8S_TOKEN
- name: "CA Hash"
shell: openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
register: K8S_MASTER_CA_HASH
- name: "IP and port"
shell: kubectl cluster-info | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | cut -d ' ' -f 7 | sed -n '1p' | cut -c 9-
register: K8S_IP_PORT
- name: "Add K8S Token and Hash to dummy host"
add_host:
name: "K8S_TOKEN_HOLDER"
token: "{{ K8S_TOKEN.stdout }}"
hash: "{{ K8S_MASTER_CA_HASH.stdout }}"
ipport: "{{ K8S_IP_PORT.stdout }}"
- name:
debug:
msg: "[Master] K8S_TOKEN_HOLDER K8S token is {{ hostvars['K8S_TOKEN_HOLDER']['token'] }}"
- name:
debug:
msg: "[Master] K8S_TOKEN_HOLDER K8S Hash is {{ hostvars['K8S_TOKEN_HOLDER']['hash'] }}"
- name:
debug:
msg: "[Master] K8S_TOKEN_HOLDER K8S IP and port is {{ hostvars['K8S_TOKEN_HOLDER']['ipport'] }}"

View File

@ -0,0 +1,19 @@
- name: get calico conf
template:
src: calico.yaml.j2
dest: $HOME/calico.yaml
- name: apply calico conf1
shell: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/tigera-operator.yaml
register: apply1
- debug: var=apply1.stdout_lines
- name: apply calico conf2
shell: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/custom-resources.yaml
register: apply2
- debug: var=apply2.stdout_lines
- name: apply calico conf3
shell: kubectl apply -f calico.yaml
register: apply3
- debug: var=apply3.stdout_lines

View File

@ -0,0 +1,11 @@
- name: Install openEBS
shell: kubectl apply -f https://openebs.github.io/charts/openebs-operator-lite.yaml
- name: Copy conf
become: yes
template:
src: openebs.yaml
dest: /etc/openebs.yaml
- name: Apply Conf
shell: kubectl apply -f /etc/openebs.yaml

View File

@ -1,5 +1,7 @@
---
- import_playbook: initialize-kubernetes.yaml
- import_playbook: calico.yaml
- import_playbook: pre-join.yaml
- import_playbook: kubernetes-worker.yaml
#- import_playbook: openebs.yaml
#- import_playbook: purelb.yaml