feat(ansible): rename playbooks and update AnsibleTasks
Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
15 files changed
+39
-12
No files matched your search
@@ -0,0 +1,74 @@
|
||||
---
|
||||
- hosts:
|
||||
- master
|
||||
- worker
|
||||
become: true
|
||||
gather_facts: true
|
||||
any_errors_fatal: true
|
||||
pre_tasks:
|
||||
- name: Pausing for 5 seconds...
|
||||
pause:
|
||||
seconds: 5
|
||||
tasks:
|
||||
- name: Check if cluster is installed
|
||||
check_mode: false
|
||||
ansible.builtin.stat:
|
||||
path: "/etc/rancher/k3s/config.yaml"
|
||||
register: k3s_check_installed
|
||||
|
||||
- name: Set manifest facts
|
||||
ansible.builtin.set_fact:
|
||||
k3s_server_manifests_templates: []
|
||||
k3s_server_manifests_urls: []
|
||||
when: k3s_check_installed.stat.exists
|
||||
|
||||
- name: Install Kubernetes
|
||||
include_role:
|
||||
name: xanmanning.k3s
|
||||
public: true
|
||||
|
||||
- name: Get absolute path to this Git repository
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
run_once: true
|
||||
check_mode: false
|
||||
ansible.builtin.command: |-
|
||||
git rev-parse --show-toplevel
|
||||
register: repo_abs_path
|
||||
|
||||
- name: Copy kubeconfig to provision folder
|
||||
run_once: true
|
||||
ansible.builtin.fetch:
|
||||
src: "/etc/rancher/k3s/k3s.yaml"
|
||||
dest: "{{ repo_abs_path.stdout }}/provision/kubeconfig"
|
||||
flat: true
|
||||
when:
|
||||
- k3s_control_node is defined
|
||||
- k3s_control_node
|
||||
|
||||
- name: Update kubeconfig with the right IPv4 address
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
run_once: true
|
||||
ansible.builtin.replace:
|
||||
path: "{{ repo_abs_path.stdout }}/provision/kubeconfig"
|
||||
regexp: "https://127.0.0.1:6443"
|
||||
replace: "https://{{ k3s_registration_address }}:6443"
|
||||
|
||||
- name: Wait for k3s to finish installing the deployed manifests
|
||||
ansible.builtin.wait_for:
|
||||
timeout: 15
|
||||
when: k3s_server_manifests_templates | length > 0
|
||||
or k3s_server_manifests_dir | length > 0
|
||||
|
||||
- name: Remove deployed manifest templates
|
||||
ansible.builtin.file:
|
||||
path: "{{ k3s_server_manifests_dir }}/{{ item | basename | regex_replace('\\.j2$', '') }}"
|
||||
state: absent
|
||||
loop: "{{ k3s_server_manifests_templates | default([]) }}"
|
||||
|
||||
- name: Remove deployed manifest urls
|
||||
ansible.builtin.file:
|
||||
path: "{{ k3s_server_manifests_dir }}/{{ item.filename }}"
|
||||
state: absent
|
||||
loop: "{{ k3s_server_manifests_urls | default([]) }}"
|
||||
Reference in new issue
Block a user