Keep cluster state if cluster exists
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
---
|
---
|
||||||
|
- name: Creates RKE directory on nodes
|
||||||
|
file:
|
||||||
|
path: /rke
|
||||||
|
state: directory
|
||||||
|
|
||||||
- name: Create RKE directory
|
- name: Create RKE directory
|
||||||
file:
|
file:
|
||||||
path: "{{ rke_directory }}"
|
path: "{{ rke_directory }}"
|
||||||
@@ -6,6 +11,28 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: true
|
run_once: true
|
||||||
|
|
||||||
|
- name: Check if RKE cluster state file exists
|
||||||
|
stat:
|
||||||
|
path: /rke/rke-cluster.rkestate
|
||||||
|
register: cluster_state_result
|
||||||
|
|
||||||
|
- name: Check if RKE kubeconfig file exists
|
||||||
|
stat:
|
||||||
|
path: /rke/kube_config_rke-cluster.yaml
|
||||||
|
register: kube_config_result
|
||||||
|
|
||||||
|
- name: Copy RKE cluster state back to local if it already exists
|
||||||
|
fetch:
|
||||||
|
src: /rke/rke-cluster.rkestate
|
||||||
|
dest: /local
|
||||||
|
when: cluster_state_result.stat.exists == True
|
||||||
|
|
||||||
|
- name: Copy RKE kube config if it already exists
|
||||||
|
fetch:
|
||||||
|
src: /rke/kube_config_rke-cluster.yaml
|
||||||
|
dest: "{{ rke_directory }}/kube_config_rke-cluster.yaml"
|
||||||
|
when: kube_config_result.stat.exists == True
|
||||||
|
|
||||||
- name: Create RKE Configs directory
|
- name: Create RKE Configs directory
|
||||||
file:
|
file:
|
||||||
path: "{{ rke_directory }}/configs"
|
path: "{{ rke_directory }}/configs"
|
||||||
@@ -39,9 +66,6 @@
|
|||||||
src: ../templates/rke-configs/{{ item }}.j2
|
src: ../templates/rke-configs/{{ item }}.j2
|
||||||
dest: "{{ rke_directory }}/configs/{{ item }}"
|
dest: "{{ rke_directory }}/configs/{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
- traefik-rbac.yaml
|
|
||||||
- traefik-ds.yaml
|
|
||||||
- traefik-ingress.yaml
|
|
||||||
- nfs-client-deployment.yaml
|
- nfs-client-deployment.yaml
|
||||||
- nfs-client-rbac.yaml
|
- nfs-client-rbac.yaml
|
||||||
- nfs-client-storageclass.yaml
|
- nfs-client-storageclass.yaml
|
||||||
@@ -66,3 +90,13 @@
|
|||||||
bash -c "{{ rke_directory }}/rke up --config {{ rke_directory }}/rke-cluster.yaml"
|
bash -c "{{ rke_directory }}/rke up --config {{ rke_directory }}/rke-cluster.yaml"
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: true
|
run_once: true
|
||||||
|
|
||||||
|
- name: Copy RKE kube config back to nodes after RKE run
|
||||||
|
copy:
|
||||||
|
src: "{{ rke_directory }}/kube_config_rke-cluster.yaml"
|
||||||
|
dest: /rke/kube_config_rke-cluster.yaml
|
||||||
|
|
||||||
|
- name: Copy RKE cluster state back to nodes after RKE run
|
||||||
|
copy:
|
||||||
|
src: "{{ rke_directory }}/rke-cluster.rkestate"
|
||||||
|
dest: /rke/rke-cluster.rkestate
|
||||||
Reference in New Issue
Block a user