feat: add advanced features to config (#1208)

* feat: add advanced features to config

Signed-off-by: Devin Buhl <devin@buhl.casa>

* fix: only enable longhorn if distro is k3s or k0s

Signed-off-by: Devin Buhl <devin@buhl.casa>

* fix: update ansible lint

Signed-off-by: Devin Buhl <devin@buhl.casa>

---------

Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
Devin Buhl authored and GitHub committed 2024-01-20 12:27:20 -05:00
1 parent 0fda1f6a56
commit 1ec59d1559
87 files changed
+158 -145

No files matched your search

+4 -4
View File
@@ -1,6 +1,6 @@
---
- name: Query Cloudflare zone
when: not ci_test | default(false)
when: not ci_test|default(false)
ansible.builtin.uri:
url: https://api.cloudflare.com/client/v4/zones?name={{ bootstrap_cloudflare_domain }}&status=active
headers:
@@ -12,14 +12,14 @@
register: result
- name: Check if Cloudflare zone exists
when: not ci_test | default(false)
when: not ci_test|default(false)
ansible.builtin.assert:
that: result.json.success is true
success_msg: Cloudflare zone {{ bootstrap_cloudflare_domain }} exists
fail_msg: Cloudflare zone {{ bootstrap_cloudflare_domain }} does not exist
- name: Query Cloudflared tunnel
when: not ci_test | default(false)
when: not ci_test|default(false)
ansible.builtin.uri:
url: https://api.cloudflare.com/client/v4/accounts/{{ bootstrap_cloudflare_account_tag }}/cfd_tunnel/{{ bootstrap_cloudflare_tunnel_id }}
headers:
@@ -31,7 +31,7 @@
register: result
- name: Check if Cloudflared tunnel exists
when: not ci_test | default(false)
when: not ci_test|default(false)
ansible.builtin.assert:
that: result.json.success is true
success_msg: Cloudflared tunnel {{ bootstrap_cloudflare_tunnel_id }} exists
+10 -10
View File
@@ -1,6 +1,6 @@
---
- name: Query Github username
when: not ci_test | default(false)
when: not ci_test|default(false)
ansible.builtin.uri:
url: https://api.github.com/users/{{ bootstrap_github_username }}
timeout: 5
@@ -9,14 +9,14 @@
register: result
- name: Check if username exists
when: not ci_test | default(false)
when: not ci_test|default(false)
ansible.builtin.assert:
that: result.json.login == bootstrap_github_username
success_msg: Github user {{ bootstrap_github_username }} exists
fail_msg: Github user {{ bootstrap_github_username }} does not exist
- name: Query Github repo
when: (not ci_test | default(false)) and (not bootstrap_private_github_repo | default(false))
when: (not ci_test|default(false)) and (not bootstrap_private_github_repo|default(false))
ansible.builtin.uri:
url: https://api.github.com/repos/{{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }}
timeout: 5
@@ -25,24 +25,24 @@
register: result
- name: Check if repo exists
when: (not ci_test | default(false)) and (not bootstrap_private_github_repo | default(false))
when: (not ci_test|default(false)) and (not bootstrap_private_github_repo|default(false))
ansible.builtin.assert:
that: result.json.full_name == bootstrap_github_username + '/' + bootstrap_github_repository_name
success_msg: Github repo {{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }} exists
fail_msg: Github repo {{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }} does not exist
- name: Query Github repo branch
when: (not ci_test | default(false)) and (not bootstrap_private_github_repo | default(false))
when: (not ci_test|default(false)) and (not bootstrap_private_github_repo|default(false))
ansible.builtin.uri:
url: https://api.github.com/repos/{{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }}/branches/{{ bootstrap_github_repository_branch | default('main', true) }}
url: https://api.github.com/repos/{{ bootstrap_github_username }}/{{ bootstrap_github_repository_name }}/branches/{{ bootstrap_github_repository_branch|default('main', true) }}
timeout: 5
return_content: true
body_format: json
register: result
- name: Check if repo branch exists
when: (not ci_test | default(false)) and (not bootstrap_private_github_repo | default(false))
when: (not ci_test|default(false)) and (not bootstrap_private_github_repo|default(false))
ansible.builtin.assert:
that: result.json.name == bootstrap_github_repository_branch | default('main', true)
success_msg: Github repo branch {{ bootstrap_github_repository_branch | default('main', true) }} exists
fail_msg: Github repo branch {{ bootstrap_github_repository_branch | default('main', true) }} does not exist
that: result.json.name == bootstrap_github_repository_branch|default('main', true)
success_msg: Github repo branch {{ bootstrap_github_repository_branch|default('main', true) }} exists
fail_msg: Github repo branch {{ bootstrap_github_repository_branch|default('main', true) }} does not exist
+18 -18
View File
@@ -14,21 +14,21 @@
fail_msg: Node CIDR {{ bootstrap_node_cidr }} is invalid.
- name: Check if cluster CIDR is ipv4 OR ipv6
when: not bootstrap_ipv6_enabled | default(false)
when: not bootstrap_ipv6_enabled|default(false)
ansible.builtin.assert:
that: bootstrap_cluster_cidr is ansible.utils.ipv4 or bootstrap_cluster_cidr is ansible.utils.ipv6
success_msg: Cluster CIDR {{ bootstrap_cluster_cidr }} is valid.
fail_msg: Cluster CIDR {{ bootstrap_cluster_cidr }} is invalid.
- name: Check if service CIDR is ipv4 OR ipv6
when: not bootstrap_ipv6_enabled | default(false)
when: not bootstrap_ipv6_enabled|default(false)
ansible.builtin.assert:
that: bootstrap_service_cidr is ansible.utils.ipv4 or bootstrap_service_cidr is ansible.utils.ipv6
success_msg: Service CIDR {{ bootstrap_service_cidr }} is valid.
fail_msg: Service CIDR {{ bootstrap_service_cidr }} is invalid.
- name: Check if cluster CIDR is ipv4 AND ipv6
when: bootstrap_ipv6_enabled | default(false)
when: bootstrap_ipv6_enabled|default(false)
ansible.builtin.assert:
that: >
(
@@ -42,7 +42,7 @@
fail_msg: Cluster CIDR {{ bootstrap_cluster_cidr }} is invalid.
- name: Check if service CIDR is ipv4 AND ipv6
when: bootstrap_ipv6_enabled | default(false)
when: bootstrap_ipv6_enabled|default(false)
ansible.builtin.assert:
that: >
(
@@ -122,24 +122,24 @@
fail_msg: All IP addresses are not unique.
- name: Check if nodes are not the same IPs as k8s_gateway or ingress external/internal
when: not bootstrap_kube_vip_enabled | default(true)
when: not bootstrap_kube_vip_enabled|default(true)
ansible.builtin.assert:
that: item.address not in (bootstrap_k8s_gateway_addr, bootstrap_external_ingress_addr, bootstrap_internal_ingress_addr)
success_msg: Node address {{ item.address }} is different than k8s_gateway or ingress-nginx.
fail_msg: Node address {{ item.address }} is not different than k8s_gateway or ingress-nginx.
quiet: true
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker|default([]) }}"
loop_control:
label: "{{ item.address }}"
- name: Check if nodes are not the same IPs as k8s_gateway, ingress external/internal or Kube API address
when: (bootstrap_distribution == "k3s") and (bootstrap_kube_vip_enabled | default(true))
when: (bootstrap_distribution == "k3s") and (bootstrap_kube_vip_enabled|default(true))
ansible.builtin.assert:
that: item.address not in (bootstrap_k8s_gateway_addr, bootstrap_external_ingress_addr, bootstrap_internal_ingress_addr, bootstrap_kube_api_addr)
success_msg: Node address {{ item.address }} is different than k8s_gateway, ingress-nginx or Kube API.
fail_msg: Node address {{ item.address }} is not different than k8s_gateway, ingress-nginx or Kube API.
quiet: true
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker|default([]) }}"
loop_control:
label: "{{ item.address }}"
@@ -149,7 +149,7 @@
success_msg: Node address {{ item.address }} is valid.
fail_msg: Node address {{ item.address }} is invalid.
quiet: true
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker|default([]) }}"
loop_control:
label: "{{ item.address }}"
@@ -159,7 +159,7 @@
success_msg: Node address {{ item.address }} is within {{ bootstrap_node_cidr }}.
fail_msg: Node address {{ item.address }} is not within {{ bootstrap_node_cidr }}.
quiet: true
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker|default([]) }}"
loop_control:
label: "{{ item.address }}"
@@ -167,11 +167,11 @@
ansible.builtin.assert:
that: >
(
(bootstrap_nodes.master + bootstrap_nodes.worker | default([])) | map(attribute='address') | list
(bootstrap_nodes.master + bootstrap_nodes.worker|default([])) | map(attribute='address') | list
) | unique | length
==
(
(bootstrap_nodes.master + bootstrap_nodes.worker | default([])) | map(attribute='address') | list
(bootstrap_nodes.master + bootstrap_nodes.worker|default([])) | map(attribute='address') | list
) | length
success_msg: All node IP addresses are unique.
fail_msg: All node IP addresses are not unique.
@@ -181,34 +181,34 @@
ansible.builtin.assert:
that: >
(
(bootstrap_nodes.master + bootstrap_nodes.worker | default([])) | map(attribute='name') | list
(bootstrap_nodes.master + bootstrap_nodes.worker|default([])) | map(attribute='name') | list
) | unique | length
==
(
(bootstrap_nodes.master + bootstrap_nodes.worker | default([])) | map(attribute='name') | list
(bootstrap_nodes.master + bootstrap_nodes.worker|default([])) | map(attribute='name') | list
) | length
success_msg: All node names are unique.
fail_msg: All node names are not unique.
quiet: true
- name: Check if SSH ports are reachable
when: (not ci_test | default(false)) and (not bootstrap_distribution == "talos")
when: (not ci_test|default(false)) and (not bootstrap_distribution == "talos")
ansible.builtin.wait_for:
host: "{{ item.address }}"
port: 22
timeout: 10
connection: local
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker|default([]) }}"
loop_control:
label: "{{ item.address }}"
- name: Check if Talos ports are reachable
when: (not ci_test | default(false)) and (bootstrap_distribution == "talos")
when: (not ci_test|default(false)) and (bootstrap_distribution == "talos")
ansible.builtin.wait_for:
host: "{{ item.address }}"
port: 50000
timeout: 10
connection: local
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker|default([]) }}"
loop_control:
label: "{{ item.address }}"
+1 -1
View File
@@ -43,6 +43,6 @@
that: item.name is match('^[a-z0-9-\.]+$')
success_msg: Node name {{ item.name }} is valid
fail_msg: Node name {{ item.name }} is not valid
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker | default([]) }}"
loop: "{{ bootstrap_nodes.master + bootstrap_nodes.worker|default([]) }}"
loop_control:
label: "{{ item.name }}"