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
8 changed files with 50 additions and 2 deletions

View File

@ -71,7 +71,7 @@ local PipelineDeployment(scenario='rocky9') = {
'linting',
],
trigger: {
ref: ['refs/heads/main', 'refs/tags/**'],
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
},
};

View File

@ -62,6 +62,7 @@ trigger:
ref:
- refs/heads/main
- refs/tags/**
- refs/pull/**
depends_on:
- linting
@ -147,6 +148,6 @@ depends_on:
---
kind: signature
hmac: f96521e29a09a85e7e86b421ac16ceeaffcdc3645d76dfdeda7e4adf46bb42d0
hmac: 051c4db5d5ce34efd5e5e54a2c57fbfb7f8ee2f491013a788f7e9d58eba160fb
...

View File

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

View File

@ -8,3 +8,13 @@
listen: __k3s_restart
become: True
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 }}"
k3s_node_labels:
node.kubernetes.io/exclude-from-external-load-balancers: "true"
k3s_iscsi_enabled: True
pre_tasks:
- name: Override host variables
set_fact:

View File

@ -14,6 +14,12 @@ def test_k3s_running_and_enabled(host):
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):
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

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
when: k3s_server | bool
- include_tasks: setup.yml
- include_tasks: iscsi.yml
when: k3s_iscsi_enabled | bool