Skip to content

Commit

Permalink
sap_ha_install_anydb_ibmdb2: linting and sles bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-freeman committed Jul 15, 2024
1 parent c8762a9 commit a2a8545
Show file tree
Hide file tree
Showing 8 changed files with 270 additions and 74 deletions.
44 changes: 34 additions & 10 deletions roles/sap_ha_install_anydb_ibmdb2/tasks/db2_hadr_enable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

# Use the IBM Db2 Command Line Processor
# See IBM Db2 for SAP HADR reference document referred from sap.com - https://ibm.github.io/db2-hadr-wiki/
- name: SAP HA AnyDB - IBM Db2 HADR - Configure Primary Node Replication
# Reasons for noqa:
# - no-changed-when: Db2 CLP will not error if config exists but when will attempt to skip anyway
- name: SAP HA AnyDB - IBM Db2 HADR - Configure Primary Node Replication # noqa no-changed-when
register: __sap_ha_install_anydb_ibmdb2_enable_primary
become: true
become_user: db2{{ sap_ha_install_anydb_ibmdb2_sid | lower }}
args:
Expand All @@ -35,12 +38,18 @@
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_SYNCMODE NEARSYNC
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_SPOOL_LIMIT AUTOMATIC
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_PEER_WINDOW 240
when: sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
when:
- sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
- __sap_ha_install_anydb_ibmdb2_hadr_initial_status.stdout != "HADR_CONNECT_STATUS=CONNECTED"
failed_when: not __sap_ha_install_anydb_ibmdb2_enable_primary.rc == 0 and (not 'command completed successfully' in __sap_ha_install_anydb_ibmdb2_enable_primary.stdout and not __sap_ha_install_anydb_ibmdb2_enable_primary.stderr == "")


# Use the IBM Db2 Command Line Processor
# See IBM Db2 for SAP HADR reference document referred from sap.com - https://ibm.github.io/db2-hadr-wiki/
- name: SAP HA AnyDB - IBM Db2 HADR - Configure Secondary Node
# Reasons for noqa:
# - no-changed-when: Db2 CLP will not error if config exists but when will attempt to skip anyway
- name: SAP HA AnyDB - IBM Db2 HADR - Configure Secondary Node # noqa no-changed-when
register: __sap_ha_install_anydb_ibmdb2_enable_secondary
become: true
become_user: db2{{ sap_ha_install_anydb_ibmdb2_sid | lower }}
args:
Expand All @@ -59,21 +68,30 @@
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_SPOOL_LIMIT AUTOMATIC
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_PEER_WINDOW 240
db2 UPDATE DB CFG FOR $ibmdb2_sid USING INDEXREC RESTART LOGINDEXBUILD ON
when: sap_ha_install_anydb_ibmdb2_hostname_secondary == inventory_hostname_short
when:
- sap_ha_install_anydb_ibmdb2_hostname_secondary == inventory_hostname_short
- __sap_ha_install_anydb_ibmdb2_hadr_initial_status.stdout != "HADR_CONNECT_STATUS=CONNECTED"
failed_when: not __sap_ha_install_anydb_ibmdb2_enable_secondary.rc == 0 and (not 'command completed successfully' in __sap_ha_install_anydb_ibmdb2_enable_secondary.stdout and not __sap_ha_install_anydb_ibmdb2_enable_secondary.stderr == "")

# Use the IBM Db2 Command Line Processor
- name: SAP HA AnyDB - IBM Db2 HADR - Rollforward Secondary Node
# Reasons for noqa:
# - no-changed-when: Db2 CLP error if config exists so prevent with attempt to skip
- name: SAP HA AnyDB - IBM Db2 HADR - Rollforward Secondary Node # noqa no-changed-when
become: true
become_user: db2{{ sap_ha_install_anydb_ibmdb2_sid | lower }}
args:
executable: /bin/csh
ansible.builtin.shell: |
set ibmdb2_sid="{{ sap_ha_install_anydb_ibmdb2_sid }}"
db2 rollforward database $ibmdb2_sid to end of logs
when: sap_ha_install_anydb_ibmdb2_hostname_secondary == inventory_hostname_short
when:
- sap_ha_install_anydb_ibmdb2_hostname_secondary == inventory_hostname_short
- __sap_ha_install_anydb_ibmdb2_hadr_initial_status.stdout != "HADR_CONNECT_STATUS=CONNECTED"

# Use the IBM Db2 Command Line Processor
- name: SAP HA AnyDB - IBM Db2 HADR - Start Secondary Standby Node
# Reasons for noqa:
# - no-changed-when: Db2 CLP error if config exists so prevent with attempt to skip
- name: SAP HA AnyDB - IBM Db2 HADR - Start Secondary Standby Node # noqa no-changed-when
become: true
become_user: db2{{ sap_ha_install_anydb_ibmdb2_sid | lower }}
args:
Expand All @@ -82,11 +100,15 @@
set ibmdb2_sid="{{ sap_ha_install_anydb_ibmdb2_sid }}"
db2 deactivate db $ibmdb2_sid
db2 start hadr on db $ibmdb2_sid as standby
when: sap_ha_install_anydb_ibmdb2_hostname_secondary == inventory_hostname_short
when:
- sap_ha_install_anydb_ibmdb2_hostname_secondary == inventory_hostname_short
- __sap_ha_install_anydb_ibmdb2_hadr_initial_status.stdout != "HADR_CONNECT_STATUS=CONNECTED"


# Use the IBM Db2 Command Line Processor
- name: SAP HA AnyDB - IBM Db2 HADR - Start Primary Node
# Reasons for noqa:
# - no-changed-when: Db2 CLP error if config exists so prevent with attempt to skip
- name: SAP HA AnyDB - IBM Db2 HADR - Start Primary Node # noqa no-changed-when
become: true
become_user: db2{{ sap_ha_install_anydb_ibmdb2_sid | lower }}
args:
Expand All @@ -95,4 +117,6 @@
set ibmdb2_sid="{{ sap_ha_install_anydb_ibmdb2_sid }}"
db2 deactivate db $ibmdb2_sid
db2 start hadr on db $ibmdb2_sid as primary
when: sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
when:
- sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
- __sap_ha_install_anydb_ibmdb2_hadr_initial_status.stdout != "HADR_CONNECT_STATUS=CONNECTED"
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
file_type: file
patterns:
- "*.rpm"
excludes:
- "*debuginfo*"
- "*debugsource*"
# Should not be required, but db2installPCMK script will attempt to install all RPMs and fail on GPG Check
# excludes:
# - "*debuginfo*"
# - "*debugsource*"
register: __sap_ha_install_anydb_ibmdb2_pcmk_rpm_files

- name: SAP HA AnyDB - IBM Db2 HADR - Install all IBM Db2 'Integrated Linux Pacemaker' RPMs for RHEL
Expand All @@ -37,6 +38,29 @@
disable_gpg_check: true
when: ansible_os_family == 'RedHat'

# For SLES 15, various Zypper errors will occur when 'Integrated Linux Pacemaker' RPMs attempt installation, such as:
### the installed cluster-glue-libs** obsoletes 'libglue2 < **' provided by the to be installed libglue2**.db2pcmk.**
### the installed pacemaker-libs** obsoletes 'libpacemaker3 < **' provided by the to be installed libpacemaker3**db2pcmk**
### the to be installed libqb-devel**db2pcmk** requires 'libqb100 = **db2pcmk', but this requirement cannot be provided not installable providers: libqb100**db2pcmk**
### nothing provides 'cluster-glue = **db2pcmk' needed by the to be installed libglue-devel**db2pcmk**
### nothing provides 'libqb100 = **db2pcmk' needed by the to be installed libqb-devel**db2pcmk**
# Removing these packages will remove SLES Hawk2 and SLES Package Pattern for HA (patterns-ha-ha_sles) including pacemaker-libs etc
### cluster-glue (replaced by cluster-glue*.rpm from db2pcmk)
### crmsh (replaced by crmsh*.rpm from db2pcmk)
# Removing these packages will remove LVM Locking Daemon (lvm2-lockd), Corosync, SLES Hawk2 and SLES Package Pattern for HA (patterns-ha-ha_sles) including pacemaker-libs etc
### ibcmap4 libcorosync_common4 libcpg4 libsam4 libvotequorum8 (replaced by corosynclib*.rpm from db2pcmk)
### libqb100 (replaced by libqb100*.rpm from db2pcmk)
- name: SAP HA AnyDB - IBM Db2 HADR - Remove conflict default RPMs with db2pcmk RPMs for SLES
community.general.zypper:
name:
- cluster-glue
- crmsh
- ibcmap4
- libqb100
state: absent
disable_gpg_check: true
when: ansible_os_family == 'Suse'

- name: SAP HA AnyDB - IBM Db2 HADR - Install all IBM Db2 'Integrated Linux Pacemaker' RPMs for SLES
community.general.zypper:
name: "{{ __sap_ha_install_anydb_ibmdb2_pcmk_rpm_files.files | map(attribute='path') | list | sort }}"
Expand All @@ -45,12 +69,15 @@
when: ansible_os_family == 'Suse'

# SAP Note 3100287 - DB6: Db2 Support for Pacemaker Cluster Software
- name: SAP HA AnyDB - IBM Db2 HADR - Verify IBM Db2 'Integrated Linux Pacemaker' is installed
# Reasons for noqa:
# - command-instead-of-module: Shell commands to match IBM Db2 documentation
# - no-changed-when: Command is check only and performs no action
- name: SAP HA AnyDB - IBM Db2 HADR - Verify IBM Db2 'Integrated Linux Pacemaker' is installed # noqa command-instead-of-module no-changed-when
register: __sap_ha_install_anydb_ibmdb2_pcmk_version_check
ansible.builtin.shell: |
rpm -q corosync | grep -I db2pcmk
rpm -q pacemaker | grep -I db2pcmk
rpm -q crmsh | grep -I db2pcmk
set -o pipefail && rpm -q corosync | grep -I db2pcmk
set -o pipefail && rpm -q pacemaker | grep -I db2pcmk
set -o pipefail && rpm -q crmsh | grep -I db2pcmk
- name: SAP HA AnyDB - IBM Db2 HADR - Display IBM Db2 'Integrated Linux Pacemaker' installation details
ansible.builtin.debug:
Expand Down Expand Up @@ -85,11 +112,16 @@

# - name: SAP HA AnyDB - IBM Db2 HADR - Verify /usr/lib/ocf/resource.d/heartbeat contains Db2agents (db2hadr, db2inst, db2ethmon)

- name: SAP HA AnyDB - IBM Db2 HADR - Execute db2installPCMK shell script
# Expect return code 0 if success, or return code 99 if no actions taken (i.e. all RPMs installed already)
# Reasons for noqa:
# - no-changed-when: Db2 command will perform no changes unless required but uses not standard rc code so attempt to skip
- name: SAP HA AnyDB - IBM Db2 HADR - Execute db2installPCMK shell script # noqa no-changed-when
ansible.builtin.shell: |
{{ __sap_ha_install_anydb_ibmdb2_pcmk.files[0].path }} -i
register: __sap_ha_install_anydb_ibmdb2_pcmk_binary_db2cppcmk_run
failed_when: not __sap_ha_install_anydb_ibmdb2_pcmk_binary_db2cppcmk_run.rc == 0 and not 'Online Pacemaker service detected' in __sap_ha_install_anydb_ibmdb2_pcmk_binary_db2cppcmk_run.stdout
failed_when:
- (__sap_ha_install_anydb_ibmdb2_pcmk_binary_db2cppcmk_run.rc != 99 and __sap_ha_install_anydb_ibmdb2_pcmk_binary_db2cppcmk_run.rc != 0)
- not 'Online Pacemaker service detected' in __sap_ha_install_anydb_ibmdb2_pcmk_binary_db2cppcmk_run.stdout

- name: SAP HA AnyDB - IBM Db2 HADR - Identify db2cppcmk shell script
ansible.builtin.find:
Expand All @@ -104,12 +136,17 @@
msg: IBM Db2 resource agent scripts (db2cppcmk) utility is not available, cannot find file db2cppcmk
when: not (__sap_ha_install_anydb_ibmdb2_pcmk_binary_db2cppcmk.files | length > 0)

- name: SAP HA AnyDB - IBM Db2 HADR - Execute db2cppcmk shell script
# db2cppcmk script must run as root
# Reasons for noqa:
# - no-changed-when: Db2 command will perform no changes unless required
- name: SAP HA AnyDB - IBM Db2 HADR - Execute db2cppcmk shell script # noqa no-changed-when
ansible.builtin.shell: |
{{ __sap_ha_install_anydb_ibmdb2_pcmk_binary_db2cppcmk.files[0].path }} -i
# db2cm script must run as root
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Create Linux Pacemaker cluster using db2cm
# Reasons for noqa:
# - no-changed-when: Db2 command will error if already exists and not perform changes
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Create Linux Pacemaker cluster using db2cm # noqa no-changed-when
register: __sap_ha_install_anydb_ibmdb2_config1
when:
- sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
Expand All @@ -126,41 +163,47 @@
/db2/$ibmdb2_instance/sqllib/bin/db2cm -create -cluster -domain db2pcmkcluster -host $anydb_primary -publicEthernet $anydb_primary_nic -host $anydb_secondary -publicEthernet $anydb_secondary_nic -remote_cmd "ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
failed_when: not __sap_ha_install_anydb_ibmdb2_config1.rc == 0 and not 'make sure there is no cluster on any of the hosts' in __sap_ha_install_anydb_ibmdb2_config1.stdout

# db2cm script must run as root
# Setting to be performed on both Primary and Secondary node
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Update corosync totem token timeout after creating cluster
register: __sap_ha_install_anydb_ibmdb2_config1
# when:
# - sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
# Corosync setting to be performed on both Primary and Secondary node
# Reasons for noqa:
# - command-instead-of-module: Shell commands to match IBM Db2 documentation
# - no-changed-when: sed will not change anything if already changed
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Update corosync totem token timeout after creating cluster # noqa command-instead-of-module no-changed-when
register: __sap_ha_install_anydb_ibmdb2_config2
ansible.builtin.shell: |
sed -i 's/token: 10000/token: 30000/g' /etc/corosync/corosync.conf
failed_when: not __sap_ha_install_anydb_ibmdb2_config1.rc == 0 and not 'make sure there is no cluster on any of the hosts' in __sap_ha_install_anydb_ibmdb2_config1.stdout
failed_when: not __sap_ha_install_anydb_ibmdb2_config2.rc == 0 and not 'make sure there is no cluster on any of the hosts' in __sap_ha_install_anydb_ibmdb2_config2.stdout

# db2cm script must run as root
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Create Primary Node instance config in Linux Pacemaker cluster using db2cm
register: __sap_ha_install_anydb_ibmdb2_config2
# Reasons for noqa:
# - no-changed-when: Db2 command will error if already exists and not perform changes
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Create Primary Node instance config in Linux Pacemaker cluster using db2cm # noqa no-changed-when
register: __sap_ha_install_anydb_ibmdb2_config3
when:
- sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
ansible.builtin.shell: |
export ibmdb2_instance="db2{{ sap_ha_install_anydb_ibmdb2_sid | lower }}"
export anydb_primary="{{ sap_ha_install_anydb_ibmdb2_hostname_primary }}"
/db2/$ibmdb2_instance/sqllib/bin/db2cm -create -instance $ibmdb2_instance -host $anydb_primary
failed_when: not __sap_ha_install_anydb_ibmdb2_config2.rc == 0 and not 'already exists in the resource model' in __sap_ha_install_anydb_ibmdb2_config2.stdout
failed_when: not __sap_ha_install_anydb_ibmdb2_config3.rc == 0 and not 'already exists in the resource model' in __sap_ha_install_anydb_ibmdb2_config3.stdout

# db2cm script must run as root
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Create Secondary Node instance config in Linux Pacemaker cluster using db2cm
register: __sap_ha_install_anydb_ibmdb2_config3
# Reasons for noqa:
# - no-changed-when: Db2 command will error if already exists and not perform changes
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Create Secondary Node instance config in Linux Pacemaker cluster using db2cm # noqa no-changed-when
register: __sap_ha_install_anydb_ibmdb2_config4
when:
- sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
ansible.builtin.shell: |
export ibmdb2_instance="db2{{ sap_ha_install_anydb_ibmdb2_sid | lower }}"
export anydb_secondary="{{ sap_ha_install_anydb_ibmdb2_hostname_secondary }}"
/db2/$ibmdb2_instance/sqllib/bin/db2cm -create -instance $ibmdb2_instance -host $anydb_secondary
failed_when: not __sap_ha_install_anydb_ibmdb2_config3.rc == 0 and not 'already exists in the resource model' in __sap_ha_install_anydb_ibmdb2_config3.stdout
failed_when: not __sap_ha_install_anydb_ibmdb2_config4.rc == 0 and not 'already exists in the resource model' in __sap_ha_install_anydb_ibmdb2_config4.stdout

# Use the IBM Db2 Command Line Processor
# Setting to be performed on both Primary and Secondary node
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Update IBM Db2 HADR config with greater timeout allowance using db2cm
# Reasons for noqa:
# - no-changed-when: Db2 CLP will not error if config exists but when will attempt to skip anyway
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Update IBM Db2 HADR config with greater timeout allowance using db2cm # noqa no-changed-when
register: __sap_ha_install_anydb_ibmdb2_config5
# when:
# - sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
Expand All @@ -175,8 +218,10 @@

# Use the IBM Db2 Command Line Processor
# Address SQL1363W - database must be shutdown and reactivated before the configuration parameter changes become effective
- name: SAP HA AnyDB - IBM Db2 HADR - Primary and Secondary Node - Shutdown and Reactivate
register: __sap_ha_install_anydb_ibmdb2_config5
# Reasons for noqa:
# - no-changed-when: Db2 CLP error if config exists so prevent with attempt to skip
- name: SAP HA AnyDB - IBM Db2 HADR - Primary and Secondary Node - Shutdown and Reactivate # noqa no-changed-when
register: __sap_ha_install_anydb_ibmdb2_config6
# when:
# - sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
become: true
Expand All @@ -187,22 +232,30 @@
set ibmdb2_sid="{{ sap_ha_install_anydb_ibmdb2_sid }}"
db2 deactivate db $ibmdb2_sid
db2 activate db $ibmdb2_sid
failed_when: not __sap_ha_install_anydb_ibmdb2_config5.rc == 0 and not 'command completed successfully' in __sap_ha_install_anydb_ibmdb2_config5.stdout
failed_when: not __sap_ha_install_anydb_ibmdb2_config6.rc == 0 and not 'command completed successfully' in __sap_ha_install_anydb_ibmdb2_config6.stdout

# db2cm script must run as root
# Ensure parameter HADR_PEER_WINDOW is set, otherwise will clustering-supported-cluster-management-software
# "Error: Please configure HADR_PEER_WINDOW for <db_sid> on instance <db_instance> on <db_host> to a value of at least 60 seconds."
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Create IBM Db2 RDBMS instance config in Linux Pacemaker cluster using db2cm
register: __sap_ha_install_anydb_ibmdb2_config4
# Reasons for noqa:
# - no-changed-when: Db2 CLP error if config exists so prevent with attempt to skip
- name: SAP HA AnyDB - IBM Db2 HADR - Primary Node - Create IBM Db2 RDBMS instance config in Linux Pacemaker cluster using db2cm # noqa no-changed-when
register: __sap_ha_install_anydb_ibmdb2_config7
when:
- sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
ansible.builtin.shell: |
export ibmdb2_sid="{{ sap_ha_install_anydb_ibmdb2_sid }}"
export ibmdb2_instance="db2{{ sap_ha_install_anydb_ibmdb2_sid | lower }}"
/db2/$ibmdb2_instance/sqllib/bin/db2cm -create -db $ibmdb2_sid -instance $ibmdb2_instance
failed_when: not __sap_ha_install_anydb_ibmdb2_config4.rc == 0 and not 'already exists in the resource model' in __sap_ha_install_anydb_ibmdb2_config4.stdout
failed_when: not __sap_ha_install_anydb_ibmdb2_config7.rc == 0 and not 'already exists in the resource model' in __sap_ha_install_anydb_ibmdb2_config7.stdout

- name: SAP HA AnyDB - IBM Db2 HADR - Configure Linux Pacemaker on target infrastructure platform using db2cm
ansible.builtin.include_tasks: "platform/db2cm_{{ __sap_ha_install_anydb_ibmdb2_platform }}.yml"
when: __sap_ha_install_anydb_ibmdb2_platform is defined

- name: SAP HA AnyDB - IBM Db2 HADR - Warning if target infrastructure platform not detected
ansible.builtin.debug:
msg: WARNING - IBM Db2 HADR is only partially activated, the Infrastructure Platform could not be detected and additional steps are likely required.
when: __sap_ha_install_anydb_ibmdb2_platform is undefined

# end of block
Loading

0 comments on commit a2a8545

Please sign in to comment.