-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
286 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,35 @@ | ||
--- | ||
|
||
- name: Add manifest addons files | ||
- name: look up manifest files on localhost | ||
find: | ||
paths: "{{ source_directory }}" | ||
register: local_files_find_return | ||
delegate_to: localhost | ||
|
||
- name: create array of managed files | ||
ansible.builtin.set_fact: | ||
managed_files: "{{local_files_find_return.files | map(attribute='path') | map('basename') }}" | ||
|
||
- name: Add manifest addons files from localhost | ||
ansible.builtin.copy: | ||
src: "{{ src }}" | ||
dest: "/var/lib/rancher/rke2/server/manifests/" | ||
src: "{{ source_directory | regex_replace('\\/$', '') }}/" | ||
dest: "{{ destination_directory }}" | ||
mode: '0640' | ||
owner: root | ||
group: root | ||
|
||
- name: look up manifest files on remote | ||
find: | ||
paths: "{{ destination_directory }}" | ||
register: remote_files_find_return | ||
|
||
- name: create array of remote files | ||
ansible.builtin.set_fact: | ||
current_files: "{{remote_files_find_return.files | map(attribute='path') | map('basename') }}" | ||
|
||
- name: remove remote files not in managed files list | ||
ansible.builtin.file: | ||
path: "{{ destination_directory }}/{{ item }}" | ||
state: absent | ||
with_items: "{{current_files}}" | ||
when: item not in managed_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
- name: Wait for k8s apiserver | ||
ansible.builtin.wait_for: | ||
host: localhost | ||
port: "6443" | ||
state: present | ||
timeout: "{{ check_node_ready_timeout }}" | ||
changed_when: false | ||
register: api_serve_status | ||
ignore_errors: "{{check_node_ready_ignore_errors}}" | ||
|
||
- name: set fact | ||
ansible.builtin.set_fact: | ||
api_server_running: true | ||
when: | ||
- api_serve_status.state is not undefined | ||
- api_serve_status.state == "present" | ||
|
||
- name: set fact | ||
ansible.builtin.set_fact: | ||
api_server_running: "{{api_server_running}}" | ||
|
||
- name: Get node_metrics | ||
ansible.builtin.uri: | ||
url: https://localhost:10250/metrics | ||
return_content: true | ||
ca_path: /var/lib/rancher/rke2/server/tls/server-ca.crt | ||
client_cert: /var/lib/rancher/rke2/server/tls/client-admin.crt | ||
client_key: /var/lib/rancher/rke2/server/tls/client-admin.key | ||
register: node_metrics | ||
retries: "{{ check_node_ready_retries }}" | ||
delay: "{{ check_node_ready_delay }}" | ||
ignore_errors: "{{check_node_ready_ignore_errors}}" | ||
|
||
- name: Check that node_metrics collection was successful | ||
ansible.builtin.set_fact: | ||
metrics_running: true | ||
when: | ||
- 200 | string in node_metrics.status | string | ||
|
||
- name: set fact for metrics_running | ||
ansible.builtin.set_fact: | ||
metrics_running: "{{metrics_running}}" | ||
|
||
- name: Extract the kubelet_node_name from node metrics | ||
ansible.builtin.set_fact: | ||
kubelet_node_name: "{{ node_metrics.content | \ | ||
regex_search('kubelet_node_name{node=\"(.*)\"}',\ | ||
'\\1') }}" | ||
when: | ||
- 200 | string in node_metrics.status | string | ||
|
||
- name: Wait for node to show Ready status | ||
ansible.builtin.command: >- | ||
/var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml | ||
--server https://127.0.0.1:6443 get no {{ kubelet_node_name[0] }} | ||
-o jsonpath='{.status.conditions[?(@.type=="Ready")].status}' | ||
register: status_result | ||
until: status_result.stdout.find("True") != -1 | ||
retries: "{{ check_node_ready_retries }}" | ||
delay: "{{ check_node_ready_delay }}" | ||
changed_when: false | ||
ignore_errors: "{{check_node_ready_ignore_errors}}" | ||
|
||
- name: set fact | ||
ansible.builtin.set_fact: | ||
node_ready: "true" | ||
when: | ||
- status_result.rc is not undefined | ||
- status_result.rc | string == "0" | ||
|
||
- name: set fact | ||
ansible.builtin.set_fact: | ||
node_ready: "{{node_ready}}" | ||
|
||
- name: node status | ||
debug: | ||
msg: | | ||
"node_ready: {{node_ready}}" | ||
"metrics_running: {{metrics_running}}" | ||
"api_server_running: {{api_server_running}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.