From f72fe9ef66a416e2b47d68a801afe4e84cf03353 Mon Sep 17 00:00:00 2001 From: N Date: Sat, 21 Sep 2019 00:52:51 +0100 Subject: [PATCH] fix(saltbug): file.line is buggy; use file.prepend --- iscsi/defaults.yaml | 8 ++++--- iscsi/initiator/kernel/clean.sls | 4 ++-- iscsi/initiator/kernel/install.sls | 37 +++++++++++------------------- iscsi/osfamilymap.yaml | 6 +++++ iscsi/osfingermap.yaml | 2 ++ iscsi/target/kernel/clean.sls | 10 ++++---- iscsi/target/kernel/install.sls | 33 ++++++++------------------ 7 files changed, 43 insertions(+), 57 deletions(-) diff --git a/iscsi/defaults.yaml b/iscsi/defaults.yaml index e848e97f..64b55a4a 100644 --- a/iscsi/defaults.yaml +++ b/iscsi/defaults.yaml @@ -63,13 +63,13 @@ iscsi: text: 'cfiscsi_load="YES"' ietd: name: iscsi_trgt - text: iscsi_trgt + text: lio: name: target_core_mod - text: target_core_mod + text: fcoe: name: fcoe_target - text: fcoe_target + text: iser: name: ('ib_iser', 'ib_isert', 'rdma_ucm', 'rdma_cm', 'ib_cm',) text: null @@ -103,6 +103,7 @@ iscsi: initiator: enabled: True + loadmodule: False provider: open-iscsi pkghold: False pkgs: @@ -114,6 +115,7 @@ iscsi: target: port: 3260 + loadmodule: False enabled: True provider: lio pkghold: False diff --git a/iscsi/initiator/kernel/clean.sls b/iscsi/initiator/kernel/clean.sls index 217db287..4f2c259c 100644 --- a/iscsi/initiator/kernel/clean.sls +++ b/iscsi/initiator/kernel/clean.sls @@ -8,13 +8,13 @@ {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- set provider = iscsi.initiator.provider %} - {%- if provider in iscsi.config.kmodule %} + {%- if iscsi.target.loadmodule and iscsi.config.kmodule[provider]['name'] %} include: - {{ sls_service_clean }} iscsi-initiator-kernel-clean-cmd-run: cmd.run: - - name: {{ iscsi.kernel.modunload }} {{ iscsi.config.kmodule[provider]['name'] }} + - name: {{ iscsi.kernel.modunload }} {{ iscsi.config.kmodule[provider]['name'] }} || true - onlyif: {{ iscsi.kernel.modquery }} {{ iscsi.config.kmodule[provider]['name'] }} - require: - sls: {{ sls_service_clean }} diff --git a/iscsi/initiator/kernel/install.sls b/iscsi/initiator/kernel/install.sls index eb84081a..83a8ed04 100644 --- a/iscsi/initiator/kernel/install.sls +++ b/iscsi/initiator/kernel/install.sls @@ -8,38 +8,27 @@ {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- set provider = iscsi.initiator.provider %} - {%- if provider in iscsi.config.kmodule %} + {%- if iscsi.initiator.loadmodule and iscsi.config.kmodule[provider]['name'] %} include: - {{ sls_service_install }} -iscsi-initiator-kernel-install-file-line: - file.line: - - onlyif: {{ iscsi.config.name.modprobe and 'text' in iscsi.config.kmodule[provider] }} +iscsi-initiator-kernel-install-file-prepend: + file.prepend: + - onlyif: {{ iscsi.config.name.modprobe and iscsi.config.kmodule[provider]['text'] }} - name: {{ iscsi.config.name.modprobe }} - - content: {{ iscsi.config.kmodule[provider]['text'] }} - - backup: True - {%- if not iscsi.initiator.enabled %} - - mode: delete - cmd.run: - - onlyif: {{ iscsi.config.name.modprobe and iscsi.config.kmodule[provider]['name'] }} - - name: {{ iscsi.kernel.modunload }} {{ iscsi.config.kmodule[provider]['name'] }} - - onlyif: {{ iscsi.kernel.modquery }} {{ iscsi.config.kmodule[provider]['name'] }} - {%- else %} - {%- if grains.os_family in ('FreeBSD',) %} - - mode: ensure - - after: 'autoboot_delay.*' - {%- else %} - - mode: ensure - - create: True - - match: None - {%- endif %} + - text: {{ iscsi.config.kmodule[provider]['text'] }} + - makedirs: True + +iscsi-initiator-kernel-install-cmd-run: + {%- if iscsi.initiator.enabled %} cmd.run: - - onlyif: {{ iscsi.config.name.modprobe and iscsi.config.kmodule[provider]['name'] }} - name: {{ iscsi.kernel.modload }} {{ iscsi.config.kmodule[provider]['name'] }} - unless: {{ iscsi.kernel.modquery }} {{ iscsi.config.kmodule[provider]['name'] }} + {%- else %} + cmd.run: + - name: {{ iscsi.kernel.modunload }} {{ iscsi.config.kmodule[provider]['name'] }} + - onlyif: {{ iscsi.kernel.modquery }} {{ iscsi.config.kmodule[provider]['name'] }} {%- endif %} - - require: - - file: iscsi-initiator-kernel-install-file-line - require_in: - sls: {{ sls_service_install }} diff --git a/iscsi/osfamilymap.yaml b/iscsi/osfamilymap.yaml index f3501824..e351e1c0 100644 --- a/iscsi/osfamilymap.yaml +++ b/iscsi/osfamilymap.yaml @@ -105,12 +105,17 @@ Arch: open-iscsi: - iscsi - iscsid + kmodule: + lio: + name: + text: initiator: make: gitrepo: https://aur.archlinux.org cmd: makepkg -si --noconfirm -f wanted: [] target: + loadmodule: True pkgs: wanted: - linux-lts # For kernel scsi modules @@ -133,6 +138,7 @@ FreeBSD: wanted: - net/open-isns target: + loadmodule: True provider: ctld pkgs: wanted: diff --git a/iscsi/osfingermap.yaml b/iscsi/osfingermap.yaml index 4ae9684b..9fa9e1bc 100644 --- a/iscsi/osfingermap.yaml +++ b/iscsi/osfingermap.yaml @@ -33,6 +33,7 @@ CentOS-7: - libiscsi - libiscsi-utils target: + loadmodule: True pkgs: wanted: - yum-plugin-versionlock @@ -52,6 +53,7 @@ CentOS-8: - libiscsi - libiscsi-utils target: + loadmodule: True pkgs: wanted: - yum-plugin-versionlock diff --git a/iscsi/target/kernel/clean.sls b/iscsi/target/kernel/clean.sls index 89530756..77ad3831 100644 --- a/iscsi/target/kernel/clean.sls +++ b/iscsi/target/kernel/clean.sls @@ -8,24 +8,24 @@ {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- set provider = iscsi.target.provider %} - {%- if provider in iscsi.config.kmodule %} + {%- if iscsi.target.loadmodule and iscsi.config.kmodule[provider]['name'] %} include: - {{ sls_service_clean }} iscsi-target-kernel-clean-cmd-run: cmd.run: - - name: {{ iscsi.kernel.modunload }} {{ iscsi.config.kmodule[provider]['name'] }} + - name: {{ iscsi.kernel.modunload }} {{ iscsi.config.kmodule[provider]['name'] }} || true - onlyif: {{ iscsi.kernel.modquery }} {{ iscsi.config.kmodule[provider]['name'] }} - require: - sls: {{ sls_service_clean }} iscsi-target-kernel-clean-file-line: file.line: - - onlyif: {{ iscsi.config.name.modprobe and 'text' in iscsi.config.kmodule[provider] }} + - onlyif: {{ iscsi.config.name.modprobe and iscsi.config.kmodule[provider]['text'] }} - name: {{ iscsi.config.name.modprobe }} - content: {{ iscsi.config.kmodule[provider]['text'] }} - backup: True - mode: delete - - quiet: True + - quiet: True #<-- not working? - {%- endif %} + {%- endif %} diff --git a/iscsi/target/kernel/install.sls b/iscsi/target/kernel/install.sls index cb7a0622..50fc707b 100644 --- a/iscsi/target/kernel/install.sls +++ b/iscsi/target/kernel/install.sls @@ -8,40 +8,27 @@ {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} {%- set provider = iscsi.target.provider %} - {%- if provider in iscsi.config.kmodule %} + {%- if iscsi.target.loadmodule and iscsi.config.kmodule[provider]['name'] %} include: - {{ sls_service_install }} -iscsi-target-kernel-install-file-line: - file.line: - - onlyif: {{ iscsi.config.name.modprobe and 'text' in iscsi.config.kmodule[provider] }} +iscsi-target-kernel-install-file-prepend: + file.prepend: + - onlyif: {{ iscsi.config.name.modprobe and iscsi.config.kmodule[provider]['text'] }} - name: {{ iscsi.config.name.modprobe }} - - content: {{ iscsi.config.kmodule[provider]['text'] }} - - require_in: - - cmd: iscsi-target-kernel-install-file-line - - backup: True + - text: {{ iscsi.config.kmodule[provider]['text'] }} + - makedirs: True + +iscsi-target-kernel-install-cmd-run: {%- if iscsi.target.enabled %} - {%- if grains.os_family in ('FreeBSD',) %} - - mode: replace - - after: 'autoboot_delay.*' - {%- else %} - - mode: ensure - - create: True - - match: None - {%- endif %} cmd.run: - - onlyif: {{ iscsi.config.name.modprobe and iscsi.config.kmodule[provider]['name'] }} - - name: {{ iscsi.kernel.modload }} {{ iscsi.config.kmodule[provider]['name'] }} + - name: {{ iscsi.kernel.modload }} {{ iscsi.config.kmodule[provider]['name'] }} || true - unless: {{ iscsi.kernel.modquery }} {{ iscsi.config.kmodule[provider]['name'] }} {%- else %} cmd.run: - - onlyif: {{ iscsi.config.name.modprobe and iscsi.config.kmodule[provider]['name'] }} - - name: {{ iscsi.kernel.modunload }} {{ iscsi.config.kmodule[provider]['name'] }} + - name: {{ iscsi.kernel.modunload }} {{ iscsi.config.kmodule[provider]['name'] }} || true - onlyif: {{ iscsi.kernel.modquery }} {{ iscsi.config.kmodule[provider]['name'] }} - - mode: delete {%- endif %} - - require: - - file: iscsi-target-kernel-install-file-line - require_in: - sls: {{ sls_service_install }}