feat: add option to prepare iscsid to support storage providers #2

Merged
xoxys merged 3 commits from setup-iscsid into main 2023-01-10 07:42:14 +00:00
6 changed files with 47 additions and 0 deletions
Showing only changes of commit 18bd2e60bc - Show all commits

View File

@ -53,3 +53,5 @@ k3s_server_resource_creations: []
k3s_server_resource_patches: [] k3s_server_resource_patches: []
k3s_node_labels: {} k3s_node_labels: {}
k3s_iscsi_enabled: False

View File

@ -8,3 +8,13 @@
listen: __k3s_restart listen: __k3s_restart
become: True become: True
become_user: root become_user: root
- name: Restart iscsid service
service:
name: iscsid
state: restarted
daemon_reload: yes
enabled: yes
listen: __iscsid_restart
become: True
become_user: root

View File

@ -30,6 +30,7 @@
# token: "{{ hcloud_token | b64encode }}" # token: "{{ hcloud_token | b64encode }}"
k3s_node_labels: k3s_node_labels:
node.kubernetes.io/exclude-from-external-load-balancers: "true" node.kubernetes.io/exclude-from-external-load-balancers: "true"
k3s_iscsi_enabled: True
pre_tasks: pre_tasks:
- name: Override host variables - name: Override host variables
set_fact: set_fact:

View File

@ -14,6 +14,12 @@ def test_k3s_running_and_enabled(host):
assert k3s.is_enabled assert k3s.is_enabled
def test_iscsid_running_and_enabled(host):
k3s = host.service("iscsid")
assert k3s.is_running
assert k3s.is_enabled
def test_k3s_node_ready(host): def test_k3s_node_ready(host):
jsonpth = '{range .items[*]}{@.metadata.name}:{range @.status.conditions[?(@.type=="Ready")]}{@.type}={@.status};{end}{end}' # noqa jsonpth = '{range .items[*]}{@.metadata.name}:{range @.status.conditions[?(@.type=="Ready")]}{@.type}={@.status};{end}{end}' # noqa
nodes = host.run(f"k3s kubectl get nodes -o jsonpath='{jsonpth}'").stdout nodes = host.run(f"k3s kubectl get nodes -o jsonpath='{jsonpth}'").stdout

26
tasks/iscsi.yml Normal file
View File

@ -0,0 +1,26 @@
---
- block:
- name: Ensure iscsi is installed
package:
name: "{{ item }}"
state: present
loop:
- iscsi-initiator-utils
- name: Configure iscsi-initiator
copy:
content: "InitiatorName=$(/sbin/iscsi-iname)"
dest: /etc/iscsi/initiatorname.iscsi
owner: root
group: root
mode: 0644
notify: __iscsid_restart
- name: Ensure iscsid service is up and running
service:
name: iscsid
daemon_reload: True
enabled: True
state: started
become: True
become_user: root

View File

@ -5,3 +5,5 @@
- include_tasks: init.yml - include_tasks: init.yml
when: k3s_server | bool when: k3s_server | bool
- include_tasks: setup.yml - include_tasks: setup.yml
- incluse_tasks: iscsi.yml
when: k3s_iscsi_enabled | bool