Skip to content

Commit 4714506

Browse files
committed
Fix trivial ansible lint warnings
Remove no more used playbook, fix ansible-lint version used in the github workflow, tune the yamllint to be compliant with Ansible (remove warning about it reported by ansible-lint), add global exception about role-name[path] as it require project folder structure change, and last but not least fix some warnings.
1 parent afa2e18 commit 4714506

File tree

9 files changed

+49
-64
lines changed

9 files changed

+49
-64
lines changed

.ansible-lint

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ exclude_paths:
33
- ansible/playbooks/registration_role.yaml
44
- ansible/playbooks/vars/hana_media.yaml
55
- ansible/playbooks/vars/hana_vars.yaml
6+
warn_list:
7+
- role-name[path]

.github/workflows/ansible.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
- name: Install all requirements
2222
run: |
2323
python3 -m pip install --upgrade -r requirements.txt
24-
python3 -m pip install ansible-lint==25.6.1
24+
# 25.1.3 is the newes version that support ansible-core 2.16.8 we are using right now
25+
python3 -m pip install ansible-lint==25.1.3
2526
ansible-galaxy install -r requirements.yml
2627
2728
- name: Run ansible static tests

.yamllint.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
extends: default
22

33
rules:
4-
line-length: disable
4+
line-length: disable
5+
comments:
6+
min-spaces-from-content: 1
7+
comments-indentation: false
8+
braces:
9+
max-spaces-inside: 1
10+
octal-values:
11+
forbid-implicit-octal: true
12+
forbid-explicit-octal: true
13+

ansible/playbooks/additional_fence_agent_tasks.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

ansible/playbooks/ptf_installation.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
ptf_dir: "/tmp/ptf_dir"
1212

1313
tasks:
14-
1514
- name: Create directory for PTF installation
16-
file:
15+
ansible.builtin.file:
1716
path: "{{ ptf_dir }}"
1817
state: directory
1918
mode: '0755'
2019

2120
- name: Convert comma-separated string to list
22-
set_fact:
21+
ansible.builtin.set_fact:
2322
az_blobs: "{{ ptf_files | split(',') }}"
2423
when: sas_token is defined
2524

@@ -38,46 +37,49 @@
3837
with_items: "{{ az_blobs }}"
3938
when: sas_token is defined
4039

41-
- name: Download PTF files recursively with wget
42-
command: "wget --no-directories --recursive --reject 'index.html*' --user={{ ptf_user }} --password={{ ptf_password }} --no-parent {{ ptf_url }}"
40+
- name: Download PTF files recursively with wget # noqa: command-instead-of-module
41+
ansible.builtin.command: "wget --no-directories --recursive --reject 'index.html*' --user={{ ptf_user }} --password={{ ptf_password }} --no-parent {{ ptf_url }}"
4342
args:
4443
chdir: "{{ ptf_dir }}"
44+
register: wget_ret
45+
changed_when: wget_ret.rc == 0
4546
when:
4647
- sas_token is not defined
4748
- ptf_user is defined
4849
- ptf_password is defined
4950
- ptf_url is defined
5051

5152
- name: List downloaded files
52-
command: "ls -la"
53+
ansible.builtin.command: "ls -la"
5354
args:
5455
chdir: "{{ ptf_dir }}"
56+
changed_when: false
5557
register: download_list
5658

5759
- name: Display downloaded files
58-
debug:
60+
ansible.builtin.debug:
5961
var: download_list.stdout_lines
6062

6163
- name: Find downloaded RPM files
62-
find:
64+
ansible.builtin.find:
6365
paths: "{{ ptf_dir }}"
6466
patterns: "*.rpm"
6567
register: rpm_files
6668

6769
- name: Display found RPM files
68-
debug:
70+
ansible.builtin.debug:
6971
var: rpm_files.files
7072

7173
- name: Filter out src.rpm files
72-
set_fact:
74+
ansible.builtin.set_fact:
7375
filtered_rpm_files: "{{ rpm_files.files | selectattr('path', 'search', '^(?!.*src\\.rpm$).*') | list }}"
7476

7577
- name: Display filtered RPM files
76-
debug:
78+
ansible.builtin.debug:
7779
var: filtered_rpm_files
7880

7981
- name: Install PTF RPM packages
80-
zypper:
82+
community.general.zypper:
8183
name: "{{ item.path }}"
8284
state: present
8385
disable_gpg_check: true

ansible/playbooks/sap-hana-download-media.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121
-o tsv
2222
delegate_to: 127.0.0.1
2323
no_log: true
24-
run_once: true
24+
run_once: true # noqa: run-once[task] fine to ignore as not using
2525
register: az_account_key
26+
changed_when: az_account_key.rc == 0
2627
when: az_sas_token is not defined or az_sas_token == ""
2728

2829
- name: "Set expiry"
2930
ansible.builtin.command: "date -u +'%Y-%m-%dT%H:%MZ' -d '+3 hours'"
3031
delegate_to: 127.0.0.1
31-
run_once: true
32+
run_once: true # noqa: run-once[task] fine to ignore as not using
3233
register: expiry
34+
changed_when: true
3335
when: az_sas_token is not defined or az_sas_token == ""
3436

3537
- name: Generate SAS token
@@ -44,15 +46,15 @@
4446
delegate_to: 127.0.0.1
4547
changed_when: false
4648
no_log: true
47-
run_once: true
49+
run_once: true # noqa: run-once[task] fine to ignore as not using
4850
register: az_sas_token_output
4951
when: az_sas_token is not defined or az_sas_token == ""
5052

5153
- name: Set az_sas_token fact
5254
ansible.builtin.set_fact:
5355
az_sas_token: "{{ az_sas_token_output.stdout }}"
5456
delegate_to: 127.0.0.1
55-
run_once: true
57+
run_once: true # noqa: run-once[task] fine to ignore as not using
5658
when: az_sas_token is not defined or az_sas_token == ""
5759

5860
- name: Create software directory
@@ -61,7 +63,7 @@
6163
state: directory
6264
owner: root
6365
group: root
64-
mode: 0755
66+
mode: "0755"
6567
become: true
6668
become_user: root
6769

@@ -71,7 +73,7 @@
7173
dest: "{{ hana_download_path + '/' + item | split('/') | last }}"
7274
owner: root
7375
group: root
74-
mode: 0600
76+
mode: "0600"
7577
timeout: "{{ url_timeout }}"
7678
register: result
7779
until: result is succeeded

ansible/playbooks/sap-hana-system-replication-hooks.yaml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
2-
- hosts: hana
2+
- name: SAP Hana System Replication Hooks
3+
hosts: hana
34
remote_user: cloudadmin
45
become: true
56
become_user: root
67

78
pre_tasks:
89
- name: Source hana install variables
9-
include_vars: ./vars/hana_vars.yaml
10+
ansible.builtin.include_vars: ./vars/hana_vars.yaml
1011

1112
vars:
1213
is_primary: "{{ ansible_play_hosts[0] == inventory_hostname }}"
@@ -26,22 +27,17 @@
2627
{{ __sapcontrol }}
2728
-nr {{ sap_hana_install_instance_number }}
2829
-function StopWait 600 10
30+
register: stopwait
31+
changed_when: stopwait.rc == 0 # Sucessfull output is like "\n24.06.2025 23:38:21\nStop\nOK\n\n24.06.2025 23:38:41\nStopWait\nOK"
2932

30-
- name: Start HANA Primary
33+
- name: Start HANA
3134
ansible.builtin.command: # StartWait will timeout after 600 seconds.
3235
cmd: >-
3336
{{ __sapcontrol }}
3437
-nr {{ sap_hana_install_instance_number }}
3538
-function StartWait 600 10
36-
when: is_primary
37-
38-
- name: Start HANA Secondary
39-
ansible.builtin.command: # StartWait will timeout after 600 seconds.
40-
cmd: >-
41-
{{ __sapcontrol }}
42-
-nr {{ sap_hana_install_instance_number }}
43-
-function StartWait 600 10
44-
when: not is_primary
39+
register: startwait
40+
changed_when: startwait.rc == 0 # Sucessfull output is like "\n24.06.2025 23:38:42\nStart\nOK\n\n24.06.2025 23:39:52\nStartWait\nOK"
4541

4642
tasks:
4743
- name: Assert that required variables are defined

ansible/playbooks/sap-hana-system-replication.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
- hosts: hana
2+
- name: SAP Hana System Replication
3+
hosts: hana
34
remote_user: cloudadmin
45
become: true
56
become_user: root
@@ -11,7 +12,7 @@
1112
when: ansible_play_hosts | length != 2
1213

1314
- name: Load HANA vars
14-
include_vars: ./vars/hana_vars.yaml
15+
ansible.builtin.include_vars: ./vars/hana_vars.yaml
1516

1617
vars:
1718
install_path: /var/lib/qedep
@@ -52,7 +53,7 @@
5253

5354
- name: Execute hana system replication role
5455
ansible.builtin.include_role:
55-
role: ../roles/sap_ha_install_hana_hsr
56+
name: ../roles/sap_ha_install_hana_hsr
5657
when: hsr_configured == 'absent'
5758

5859
- name: Write status file

ansible/playbooks/tasks/iscsi-server-sbd-prep.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
sap_storage_cloud_type: 'generic'
6161
sap_storage_sap_type: 'sap_hana'
6262
sap_storage_action: 'prepare'
63-
include_role:
63+
ansible.buildin.include_role:
6464
name: ../roles/qe_sap_storage
6565

6666
- name: Configure HANA SBD target

0 commit comments

Comments
 (0)