Skip to content

Commit ab5df8b

Browse files
committed
Fix generic Ansible lint warnings
1 parent c88bc87 commit ab5df8b

5 files changed

Lines changed: 61 additions & 15 deletions

File tree

ansible/playbooks/sap-hana-cluster.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@
3535
state: started
3636
enabled: true
3737

38+
# When the stonith device is changed the file /var/lib/sbd is changed
39+
- name: Write stonith status file
40+
ansible.builtin.file:
41+
path: "{{ item.path }}"
42+
state: "{{ item.state }}"
43+
owner: root
44+
group: root
45+
mode: '0700'
46+
with_items:
47+
- {'path': '/var/lib/qedep', 'state': 'directory'}
48+
- {'path': '/var/lib/qedep/sbd', 'state': 'touch'}
49+
3850
pre_tasks:
3951
- name: Detect cloud platform
4052
ansible.builtin.include_tasks:
@@ -90,6 +102,8 @@
90102
crm resource
91103
refresh
92104
{{ ms_saphanactl }}
105+
register: refresh_ms_result
106+
changed_when: refresh_ms_result.rc == 0
93107
when: is_primary
94108

95109
- name: MS Resource Maintenance off
@@ -99,9 +113,12 @@
99113
maintenance
100114
{{ ms_saphanactl }}
101115
off
116+
register: maintenance_off_result
117+
changed_when: maintenance_off_result.rc == 0
102118
when: is_primary
103119

104120
- name: Wait for cluster to settle
105121
ansible.builtin.command:
106122
cmd: cs_wait_for_idle -s 5
123+
changed_when: false
107124
when: is_primary

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
2-
- hosts: hana
2+
- name: SAP Hana system replication hoks
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,6 +27,10 @@
2627
{{ __sapcontrol }}
2728
-nr {{ sap_hana_install_instance_number }}
2829
-function StopWait 600 10
30+
register: stop_hana_result
31+
changed_when:
32+
- stop_hana_result.rc == 0
33+
- "'OK' in stop_hana_result.stdout"
2934

3035
- name: Start HANA Primary
3136
ansible.builtin.command: # StartWait will timeout after 600 seconds.
@@ -34,6 +39,10 @@
3439
-nr {{ sap_hana_install_instance_number }}
3540
-function StartWait 600 10
3641
when: is_primary
42+
register: start_hana_primary_result
43+
changed_when:
44+
- start_hana_primary_result.rc == 0
45+
- "'OK' in start_hana_primary_result.stdout"
3746

3847
- name: Start HANA Secondary
3948
ansible.builtin.command: # StartWait will timeout after 600 seconds.
@@ -42,6 +51,10 @@
4251
-nr {{ sap_hana_install_instance_number }}
4352
-function StartWait 600 10
4453
when: not is_primary
54+
register: start_hana_secondary_result
55+
changed_when:
56+
- start_hana_secondary_result.rc == 0
57+
- "'OK' in start_hana_secondary_result.stdout"
4558

4659
tasks:
4760
- name: Assert that required variables are defined

ansible/playbooks/tasks/aws-cluster-bootstrap.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@
231231
- name: Enable SBD [sbd]
232232
ansible.builtin.command:
233233
cmd: crm configure primitive rsc_iscsi_sbd stonith:external/sbd
234+
register: enable_sbd_result
235+
changed_when: enable_sbd_result.rc == 0
234236
when:
235237
- sbd_stonith | string | lower == 'false'
236238
- use_sbd | default(false) | bool
@@ -253,6 +255,7 @@
253255
- not (use_sbd | default(false) | bool)
254256
- ansible_distribution_major_version == '12'
255257
register: stonith_config_result
258+
changed_when: stonith_config_result.rc == 0
256259
failed_when: >
257260
stonith_config_result.stderr_lines | select("match", "ERROR") | reject("match", "ERROR: warning") | list | length > 0
258261
@@ -263,11 +266,14 @@
263266
- not (use_sbd | default(false) | bool)
264267
- ansible_distribution_major_version != '12'
265268
register: stonith_config_result
269+
changed_when: stonith_config_result.rc == 0
266270
failed_when: "'ERROR' in stonith_config_result.stderr"
267271

268272
- name: Set stonith-timeout [sdb]
269273
ansible.builtin.command:
270274
cmd: crm configure property stonith-timeout=144
275+
register: set_stonith_timeout_sdb_result
276+
changed_when: set_stonith_timeout_sdb_result.rc == 0
271277
when:
272278
- stonith_timeout != '144'
273279
- use_sbd | default(false) | bool
@@ -279,6 +285,8 @@
279285
crm configure property
280286
$id="cib-bootstrap-options"
281287
stonith-timeout=600s
288+
register: set_stonith_timeout_aws_result
289+
changed_when: set_stonith_timeout_aws_result.rc == 0
282290
when:
283291
- stonith_timeout != '600s'
284292
- is_primary
@@ -290,6 +298,8 @@
290298
crm configure property
291299
$id="cib-bootstrap-options"
292300
stonith-enabled=true
301+
register: enable_stonith_result
302+
changed_when: enable_stonith_result.rc == 0
293303
when:
294304
- stonith_enabled | string | lower != 'true'
295305
- is_primary
@@ -300,6 +310,8 @@
300310
crm configure property
301311
$id="cib-bootstrap-options"
302312
stonith-action=off
313+
register: disable_stonith_action_result
314+
changed_when: disable_stonith_action_result.rc == 0
303315
when:
304316
- stonith_action != 'off'
305317
- is_primary
@@ -314,6 +326,7 @@
314326
- resource_stickiness != '1000'
315327
- is_primary
316328
register: reg_rsc_defaults
329+
changed_when: reg_rsc_defaults.rc == 0
317330
until: reg_rsc_defaults.rc == 0
318331
retries: 10
319332
delay: 10
@@ -324,13 +337,17 @@
324337
crm configure rsc_defaults
325338
$id="rsc-options"
326339
migration-threshold=5000
340+
register: set_migration_threshold_result
341+
changed_when: set_migration_threshold_result.rc == 0
327342
when:
328343
- migration_threshold != '5000'
329344
- is_primary
330345

331346
- name: Set op_defaults timeout
332347
ansible.builtin.command:
333348
cmd: crm configure op_defaults timeout=600
349+
register: set_op_defaults_timeout_result
350+
changed_when: set_op_defaults_timeout_result.rc == 0
334351
when:
335352
- op_default_timeout != '600'
336353
- is_primary
@@ -348,6 +365,8 @@
348365
op start interval=0 timeout=180
349366
op stop interval=0 timeout=180
350367
op monitor interval=60 timeout=60
368+
register: configure_cluster_ip_result
369+
changed_when: configure_cluster_ip_result.rc == 0
351370
when:
352371
- rsc_ip | length == 0
353372
- is_primary
@@ -372,6 +391,7 @@
372391
rsc_ip_{{ sap_hana_install_sid }}_HDB{{ sap_hana_install_instance_number }}
373392
{{ primary_hostname }}
374393
register: reg_move_cmd
394+
changed_when: reg_move_cmd.rc == 0
375395
when:
376396
- is_primary
377397
- reg_vip_location.stdout | trim | split(' ') | last != primary_hostname
@@ -385,6 +405,7 @@
385405
crm resource locate
386406
rsc_ip_{{ sap_hana_install_sid }}_HDB{{ sap_hana_install_instance_number }}
387407
register: reg_vip_location2
408+
changed_when: false
388409
when:
389410
- is_primary
390411
- reg_vip_location.stdout | trim | split(' ') | last != primary_hostname

ansible/playbooks/tasks/gcp-cluster-bootstrap.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@
339339
- resource_stickiness != '1000'
340340
- is_primary
341341
register: reg_rsc_defaults
342+
changed_when: reg_rsc_defaults.rc == 0
342343
until: reg_rsc_defaults.rc == 0
343344
retries: 10
344345
delay: 10
@@ -400,6 +401,7 @@
400401
rsc_ip_{{ sap_hana_install_sid }}_HDB{{ sap_hana_install_instance_number }}
401402
{{ primary_hostname }}
402403
register: reg_move_cmd
404+
changed_when: reg_move_cmd.rc == 0
403405
when:
404406
- is_primary
405407
- reg_vip_location.stdout | trim | split(' ') | last != primary_hostname
@@ -413,6 +415,7 @@
413415
crm resource locate
414416
rsc_ip_{{ sap_hana_install_sid }}_HDB{{ sap_hana_install_instance_number }}
415417
register: reg_vip_location2
418+
changed_when: false
416419
when:
417420
- is_primary
418421
- reg_vip_location.stdout | trim | split(' ') | last != primary_hostname

ansible/playbooks/tasks/rebuild-stonith.yaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
ansible.builtin.command:
2121
cmd: "crm resource stop {{ sbd_device_name }}"
2222
register: sbd_status
23+
changed_when: true
2324
when: sbd_device_status == 'Started' or sbd_device_status == 'running'
2425

2526
- name: Remove stonith device
2627
ansible.builtin.command:
2728
cmd: "crm configure delete {{ sbd_device_name }}"
29+
register: remove_stonith_result
30+
changed_when: remove_stonith_result.rc == 0
2831
when: sbd_device_name != 'NOresourcesconfigured' # If no stonith was found 'NOresourcesconfigured' should be registered in {{ sbd_device_name }}
2932

3033
- name: Create new SBD stonith device
@@ -38,16 +41,5 @@
3841
pcmk_delay_max="15"
3942
op monitor interval="600" timeout="15"
4043
register: create_stonith
41-
42-
# When the stonith device is changed the file /var/lib/sbd is changed
43-
- name: Write status file
44-
ansible.builtin.file:
45-
path: "{{ item.path }}"
46-
state: "{{ item.state }}"
47-
owner: root
48-
group: root
49-
mode: '0700'
50-
when: create_stonith.changed
51-
with_items:
52-
- {'path': '/var/lib/qedep', 'state': 'directory'}
53-
- {'path': '/var/lib/qedep/sbd', 'state': 'touch'}
44+
changed_when: create_stonith.rc == 0
45+
notify: Write stonith status file

0 commit comments

Comments
 (0)