-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Travis CI User
committed
Nov 13, 2024
1 parent
916f4f1
commit 2b39962
Showing
11 changed files
with
157 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- hosts: hdb_iphost1,hdb_iphost2 | ||
gather_facts: true | ||
pre_tasks: | ||
- name: Import playbook variables | ||
include_vars: "{{ item }}" | ||
loop: | ||
- "saphana-vars.yml" | ||
- "hainfra-vars.yml" | ||
roles: | ||
- hdbpacemakercfg | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
# https://access.redhat.com/solutions/7029705 | ||
|
||
- name: Include OS specific variables | ||
include_vars: "{{ ansible_distribution }}.yml" | ||
|
||
- name: Check the prerequisites | ||
include_tasks: "systemd_use_prerequisites.yml" | ||
|
||
- name: Check if pacemaker.service.d directory exists | ||
stat: | ||
path: "/etc/systemd/system/pacemaker.service.d" | ||
register: pacemaker_service_d_status | ||
when: use_systemd == true | ||
|
||
- name: Create a directory for pacemaker in systemd | ||
file: | ||
path: "/etc/systemd/system/pacemaker.service.d" | ||
state: directory | ||
mode: 0755 | ||
when: use_systemd == true and not pacemaker_service_d_status.stat.exists | ||
|
||
# The name of the service used in Jinja file can be found by running the command: systemd-cgls -u SAP.slice | ||
|
||
- name: Check if pacemaker.conf file exists | ||
stat: | ||
path: "/etc/systemd/system/pacemaker.service.d/{{ hana_sysno }}-pacemaker.conf" | ||
register: pacemaker_conf_status | ||
when: use_systemd == true | ||
|
||
- name: Generate the pacemaker file | ||
template: | ||
src: pacemaker.j2 | ||
dest: "/etc/systemd/system/pacemaker.service.d/{{ hana_sysno }}-pacemaker.conf" | ||
mode: 0644 | ||
when: use_systemd == true and not pacemaker_conf_status.stat.exists | ||
|
||
- name: Activate the file | ||
systemd: | ||
daemon_reload: yes | ||
when: use_systemd == true | ||
... |
49 changes: 49 additions & 0 deletions
49
ansible/roles/hdbpacemakercfg/tasks/systemd_use_prerequisites.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
- name: Check if HANA DB is installed | ||
stat: | ||
path: "/hana/shared/{{ hana_sid|upper }}/exe/linuxx86_64/hdb" | ||
register: hdb_install_status | ||
|
||
- name: Check if systemd usage is allowed for this OS major version | ||
set_fact: | ||
os_vers_ok: true | ||
when: hdb_install_status.stat.exists and (ansible_distribution_major_version | int >= os_release_min | int) | ||
|
||
- name: Run the command to get systemd version | ||
shell: systemctl --version | grep systemd | ||
register: systemd_info | ||
changed_when: False | ||
when: hdb_install_status.stat.exists and os_vers_ok is defined | ||
|
||
- name: Extract systemd version | ||
set_fact: | ||
systemd_vers: "{{ systemd_info.stdout.split(' ')[1] | int }}" | ||
when: systemd_info is defined | ||
|
||
- name: Check if systemd usage is allowed for this systemd version | ||
set_fact: | ||
systemd_vers_ok: true | ||
when: >- | ||
systemd_vers is defined and (systemd_vers | int >= systemd_vers_min) | ||
- name: Run the command to get SAP HANA SP | ||
shell: su - {{ hana_sid | lower }}adm -c "HDB version | grep 'version:'" | ||
register: hdb_versinfo | ||
changed_when: False | ||
when: systemd_vers_ok is defined | ||
|
||
- name: Extract HANA SP | ||
set_fact: | ||
hana_sp: "{{ ((hdb_versinfo.stdout.split('.')[2])[:2]) | int }}" | ||
when: hdb_versinfo is defined | ||
|
||
- name: Check if systemd usage is allowed for this SAP HANA SP | ||
set_fact: | ||
hana_vers_ok: true | ||
when: hana_sp is defined and (hana_sp | int >= hana_sp_min | int) | ||
|
||
- name: Set variable for systemd usage | ||
set_fact: | ||
use_systemd: true | ||
when: hana_vers_ok is defined | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[Unit] | ||
Description=Pacemaker needs the SAP HANA instance service | ||
Wants=SAP{{ hana_sid | upper }}_{{ hana_sysno }}.service | ||
After=SAP{{ hana_sid | upper }}_{{ hana_sysno }}.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
os_release_min: 8 | ||
systemd_vers_min: 239 | ||
hana_sp_min: 7 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
os_release_min: 15 | ||
systemd_vers_min: 234 | ||
hana_sp_min: 7 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.