Skip to content

Commit

Permalink
Solve Ansible lint warning in storage preparation area (#317)
Browse files Browse the repository at this point in the history
Use full name for lvol abd lvg Ansible tasks
Fix space and indentation
Add missing task names
  • Loading branch information
mpagot authored Feb 12, 2025
1 parent 70c5550 commit 1f8e955
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export ANSIBLE_ROLES_PATH=<the-dir-where-the-role-is-located>
### Mark temporary workaround for known issues

If Ansible code is added to temporary workaround known issue, already associated to an open ticket, there's a convention to communicate it to openQA.
Use `ansible.buildin.debug` with a specific format.
Use `ansible.builtin.debug` with a specific format.

```yaml
msg: "[OSADO][softfail] [bsc or jsc]#[number] [short description]"
Expand Down
37 changes: 19 additions & 18 deletions ansible/roles/qe_sap_storage/tasks/az_tasks/prepare_storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

# Striped volume
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ sap_storage_az_vmsize }} - {{ item.value.name }} - Striped
when:
- "item.value.numluns != '1'"
block:

# Get LUNs from metadata
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ sap_storage_az_vmsize }} - {{ item.value.name }} Get LUNs from metadata
shell: |
ansible.builtin.shell: |
for i in {1..{{ item.value.numluns }}}
do
{{ item.value.vg }}${i}lun="{{ sap_storage_az_lun }} \
Expand All @@ -20,35 +21,36 @@
args:
executable: /bin/bash
register: pvs_reg

- set_fact:

- name: Recors pvs list
ansible.builtin.set_fact:
pvs_list: "{{ pvs_reg.stdout.split() }}"

# Create Volume Group
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ sap_storage_az_vmsize }} - {{ item.value.name }} Volume Group Striped
lvg:
community.general.lvg:
vg: "{{ item.value.vg }}"
pvs: "{{ pvs_list | join(',') }}"
force: yes
force: true

# Create Logical Group
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ sap_storage_az_vmsize }} - {{ item.value.name }} Logical Volume - Striped
lvol:
community.general.lvol:
vg: "{{ item.value.vg }}"
lv: "{{ item.value.lv }}"
size: 100%VG
opts: "-i{{ item.value.numluns }} -I{{ item.value.stripesize }}"

when:
- "item.value.numluns != '1'"

# Single volume
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ sap_storage_az_vmsize }} - {{ item.value.name }} - Single Volume
when:
- "item.value.numluns == '1'"
block:

# Get LUNs from metadata
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ sap_storage_az_vmsize }} - {{ item.value.name }} Get LUNs from metadata
shell: |
ansible.builtin.shell: |
{{ item.value.vg }}lun="{{ sap_storage_az_lun }} \
`awk '/caching/ { r=""; f=1 } f { r = (r ? r ORS : "") $0 } \
/writeAcceleratorEnabled/ \
Expand All @@ -60,35 +62,34 @@
executable: /bin/bash
register: pvs_reg

- set_fact:
- name: Records pvs
ansible.builtin.set_fact:
pvs_one: "{{ pvs_reg.stdout }}"

# Create Volume Group
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ sap_storage_az_vmsize }} - {{ item.value.name }} Volume Group One
lvg:
community.general.lvg:
vg: "{{ item.value.vg }}"
pvs: "{{ pvs_one }}"
force: yes
force: true

# Create Logical Group
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ sap_storage_az_vmsize }} - {{ item.value.name }} Logical Volume - One
lvol:
community.general.lvol:
vg: "{{ item.value.vg }}"
lv: "{{ item.value.lv }}"
size: 100%VG

when:
- "item.value.numluns == '1'"

# Create Filesystem
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ sap_storage_az_vmsize }} - {{ item.value.name }} Filesystem
filesystem:
community.general.filesystem:
fstype: xfs
dev: "/dev/{{ item.value.vg }}/{{ item.value.lv }}"

# Mount Filesystem
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ sap_storage_az_vmsize }} - {{ item.value.name }} Mount
mount:
ansible.posix.mount:
path: "{{ item.value.directory }}"
fstype: xfs
src: "/dev/mapper/{{ item.value.vg }}-{{ item.value.lv }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
# Remove Logical Volume
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Remove Logical Volume
lvol:
community.general.lvol:
lv: "{{ item.value.lv }}"
vg: "{{ item.value.vg }}"
state: absent
force: yes

# Remove Volume Group
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Remove Volume Group
lvg:
community.general.lvg:
vg: "{{ item.value.vg }}"
state: absent
force: yes
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---

- name: Storage profile details
debug:
ansible.builtin.debug:
msg: "{{ item }} "

- name: Determine the root device
command: "findmnt -n -o SOURCE /"
ansible.builtin.command: "findmnt -n -o SOURCE /"
register: root_device
changed_when: false

Expand All @@ -23,20 +23,20 @@
- name: Adjust PV list for storage profile "{{ item.key }}"
ansible.builtin.set_fact:
adjusted_pv: "{{ item.value.pv | map('regex_replace', '^' ~ root_device_name ~ '$', '/dev/nvme0n1') | list }}"
when:
when:
- root_device_name != '/dev/nvme0n1'
- root_device_name in item.value.pv

- name: Physical Volume list that will be used
debug:
ansible.builtin.debug:
msg: "Using PV list: {{ (adjusted_pv is defined and (adjusted_pv | length) > 0) | ternary(adjusted_pv, item.value.pv) }}"

# Create Volume Group
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Volume Group One
lvg:
- name: SAP Storage Preparation - Volume Group One - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }}
community.general.lvg:
vg: "{{ item.value.vg }}"
pvs: "{{ (adjusted_pv is defined and (adjusted_pv | length) > 0) | ternary(adjusted_pv, item.value.pv) }}"
force: yes
force: true
register: lvg_result
until: lvg_result is successful
retries: 5
Expand All @@ -49,32 +49,32 @@

# Create Logical Group - One
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Logical Volume - One
lvol:
community.general.lvol:
vg: "{{ item.value.vg }}"
lv: "{{ item.value.lv }}"
size: 100%VG
when:
when:
- "item.value.numluns == '1'"

# Create Logical Group - Striped
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Logical Volume - Striped
lvol:
community.general.lvol:
vg: "{{ item.value.vg }}"
lv: "{{ item.value.lv }}"
size: 100%VG
opts: "-i {{ item.value.numluns }} -I {{ item.value.stripesize }}"
when:
when:
- "item.value.numluns != '1'"

# Create Filesystem
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Filesystem
filesystem:
community.general.filesystem:
fstype: xfs
dev: "/dev/{{ item.value.vg }}/{{ item.value.lv }}"

# Mount Filesystem
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Mount
mount:
ansible.posix.mount:
path: "{{ item.value.directory }}"
fstype: xfs
src: "/dev/mapper/{{ item.value.vg }}-{{ item.value.lv }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@

# Remove Logical Volume
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Remove Logical Volume
lvol:
community.general.lvol:
lv: "{{ item.value.lv }}"
vg: "{{ item.value.vg }}"
state: absent
force: yes

# Remove Volume Group
- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Remove Volume Group
lvg:
community.general.lvg:
vg: "{{ item.value.vg }}"
state: absent
force: yes

0 comments on commit 1f8e955

Please sign in to comment.