blob: 63b01cb12077ff24e27d00efc8c1bb3df2b39a3f [file] [log] [blame]
Mohammed Naserab3d88b2023-04-09 17:27:05 -04001# Copyright (c) 2023 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15- name: Detect if the "lpfc" module is loaded
16 ansible.builtin.stat:
17 path: /sys/module/lpfc
18 register: _lpfc_module
19
20- name: Install the configuration file and reboot if necessary
21 when: _lpfc_module.stat.exists
22 block:
23 - name: Install the configuration file
24 ansible.builtin.template:
25 src: lpfc.conf.j2
26 dest: /etc/modprobe.d/lpfc.conf
27 owner: root
28 group: root
29 mode: "0644"
30 register: _lpfc_module_conf
31
32 - name: Get the values for the module parameters
33 ansible.builtin.slurp:
34 src: /sys/module/lpfc/parameters/{{ item }}
35 register: _lpfc_module_parameters
36 loop:
37 - lpfc_lun_queue_depth
38 - lpfc_sg_seg_cnt
39 - lpfc_max_luns
40 - lpfc_enable_fc4_type
41
Mohammed Naser09570b82023-04-09 22:01:24 +000042 - name: Detect if the run-time module parameters are set correctly
Mohammed Naserab3d88b2023-04-09 17:27:05 -040043 ansible.builtin.assert:
44 quiet: true
45 that:
46 - item.content | b64decode | trim | int == lookup('vars', item.item)
47 fail_msg: >-
48 The module parameter {{ item.item }} is not set correctly, expected:
49 {{ lookup('vars', item.item) }}, got: {{ item.content | b64decode | trim }}
50 loop: "{{ _lpfc_module_parameters.results }}"
51 loop_control:
52 label: "{{ item.item }}"
53 register: _lpfc_module_parameters_assert
54 failed_when: false
55 changed_when: _lpfc_module_parameters_assert.failed
56
Mohammed Naser09570b82023-04-09 22:01:24 +000057 - name: Update "initramfs" if the configuration file has changed
58 ansible.builtin.command:
59 cmd: update-initramfs -k all -u
60 changed_when: _lpfc_module_conf.changed or _lpfc_module_parameters_assert.changed
61 when: _lpfc_module_conf.changed or _lpfc_module_parameters_assert.changed
62
Mohammed Naserab3d88b2023-04-09 17:27:05 -040063 - name: Reboot the system if the configuration file has changed
64 ansible.builtin.include_role:
65 name: reboot
66 when: _lpfc_module_conf.changed or _lpfc_module_parameters_assert.changed