Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sap_ha_install_anydb_ibmdb2: experimental new role #545

Merged
merged 12 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions roles/sap_ha_install_anydb_ibmdb2/.ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
enable_list:
- yaml
skip_list:
- ignore-errors # We use ignore_errors for all the assert tasks, which should be acceptable
sean-freeman marked this conversation as resolved.
Show resolved Hide resolved
- schema # We want to allow single digit version numbers in a role's meta/main.yml file. This is allowed as per https://galaxy.ansible.com/docs/contributing/creating_role.html and https://galaxy.ansible.com/api/v1/platforms/?page=6.
- name[template] # Allow templating inside name. During dev and qa, it should be possible to identify cases where it doesn't work
22 changes: 22 additions & 0 deletions roles/sap_ha_install_anydb_ibmdb2/.yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-License-Identifier: Apache-2.0
---
# Based on ansible-lint config
extends: default

rules:
braces: {max-spaces-inside: 1, level: error}
brackets: {max-spaces-inside: 1, level: error}
# colons: {max-spaces-after: -1, level: error}
# commas: {max-spaces-after: -1, level: error}
comments: disable
comments-indentation: disable
# document-start: disable
# empty-lines: {max: 3, level: error}
# hyphens: {level: error}
# indentation: disable
# key-duplicates: enable
line-length: disable
# new-line-at-end-of-file: disable
# new-lines: {type: unix}
# trailing-spaces: disable
truthy: disable
82 changes: 82 additions & 0 deletions roles/sap_ha_install_anydb_ibmdb2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
`EXPERIMENTAL`

# sap_ha_install_anydb_ibmdb2 Ansible Role

Ansible Role for instantiation of IBM Db2 'Integrated Linux Pacemaker' HADR cluster

Note: IBM Db2 with 'Integrated Linux Pacemaker' can use two deployment models:
- Mutual Failover option, not covered by this Ansible Role
- High Availability and Disaster Recovery (HADR) option for Idle Standby, initialised by this Ansible Role


## Prerequisites

### Software Installation files

Download IBM Db2 installation media from SAP Download Center on host, and set Ansible Variable `sap_ha_install_anydb_ibmdb2_software_directory` to this path.

### Variables

- `sap_ha_install_anydb_ibmdb2_hostname_primary` with the IBM Db2 Primary node hostname
- `sap_ha_install_anydb_ibmdb2_hostname_secondary` with the IBM Db2 Secondary node hostname
- `sap_ha_install_anydb_ibmdb2_sid` with the IBM Db2 System ID
- `sap_ha_install_anydb_ibmdb2_software_directory` with the IBM Db2 installation media path

These are listed in the default variables file, but commented-out to enforce the required variables:
- [**sap_ha_install_anydb_ibmdb2** default parameters](defaults/main.yml)

## Requirements and Dependencies

This Ansible Role is applicable to IBM Db2 11.5 certified for SAP.

It is applicable to 11.5.9 and later, which provides `db2cm` binary compatibility for AWS, GCP and MS Azure.

### Target host - Infrastructure Platforms

Applicable for:

- Amazon Web Services
- Google Cloud
- Microsoft Azure

### Target host - Operating System requirements

Designed for Linux operating systems, e.g. RHEL (7.x and 8.x) and SLES (15.x).

## Execution

Sample Ansible Playbook Execution:

- Local Host Installation
- `ansible-playbook --connection=local --limit localhost -i "localhost," sap-ha-anydb-ibmdb2-init.yml -e "@inputs/ibmdb2_vars.yml`

- Target Host Installation
- `ansible-playbook -i "<target-host>" sap-ha-anydb-ibmdb2-init.yml -e "@inputs/ibmdb2_vars.yml"`

## Sample Ansible Playbook

```yaml
---
- hosts: all

collections:
- community.sap_install

vars:
sap_ha_install_anydb_ibmdb2_hostname_primary: anydb-primary
sap_ha_install_anydb_ibmdb2_hostname_secondary: anydb-second
sap_ha_install_anydb_ibmdb2_sid: DB2
sap_ha_install_anydb_ibmdb2_software_directory: /software/ibmdb2_extracted

- name: Execute Ansible Role sap_ha_install_anydb_ibmdb2
ansible.builtin.include_role:
name: community.sap_install.sap_ha_install_anydb_ibmdb2
```

## License

Apache license 2.0

## Author Information

Sean Freeman
25 changes: 25 additions & 0 deletions roles/sap_ha_install_anydb_ibmdb2/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: Apache-2.0
---
sean-freeman marked this conversation as resolved.
Show resolved Hide resolved

sap_ha_install_anydb_ibmdb2_sid:

sap_ha_install_anydb_ibmdb2_hostname_primary:
sap_ha_install_anydb_ibmdb2_hostname_secondary:

sap_ha_install_anydb_ibmdb2_software_directory:


sap_ha_install_anydb_ibmdb2_vip_primary_ip_address: ""

sap_ha_install_anydb_ibmdb2_aws_access_key_id: ""
sap_ha_install_anydb_ibmdb2_aws_secret_access_key: ""
sap_ha_install_anydb_ibmdb2_aws_vip_update_rt: ""

sap_ha_install_anydb_ibmdb2_msazure_tenant_id: ""
sap_ha_install_anydb_ibmdb2_msazure_app_client_id: ""
sap_ha_install_anydb_ibmdb2_msazure_app_client_secret: ""
sap_ha_install_anydb_ibmdb2_msazure_lb_health_check_port: 62700

sap_ha_install_anydb_ibmdb2_gcp_credentials_json_file: ""
sap_ha_install_anydb_ibmdb2_gcp_project: ""
sap_ha_install_anydb_ibmdb2_gcp_lb_health_check_port: 62700
14 changes: 14 additions & 0 deletions roles/sap_ha_install_anydb_ibmdb2/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: Apache-2.0
---
galaxy_info:
namespace: community
author: Sean Freeman
description: HA for SAP AnyDB - IBM Db2
company: Red Hat, Inc.
sean-freeman marked this conversation as resolved.
Show resolved Hide resolved
license: Apache-2.0
min_ansible_version: 2.9
sean-freeman marked this conversation as resolved.
Show resolved Hide resolved
platforms:
- name: EL
sean-freeman marked this conversation as resolved.
Show resolved Hide resolved
versions: [ 8, 9 ]
galaxy_tags: [ 'sap', 'anydb', 'ibmdb2', 'ibm', 'db2', 'rhel', 'redhat', 'sles', 'suse' ]
dependencies: []
3 changes: 3 additions & 0 deletions roles/sap_ha_install_anydb_ibmdb2/meta/runtime.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
---
requires_ansible: '>=2.12.0'
98 changes: 98 additions & 0 deletions roles/sap_ha_install_anydb_ibmdb2/tasks/db2_hadr_enable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# SPDX-License-Identifier: Apache-2.0
---

# See IBM Db2 documentation 'HADR and network address translation (NAT) support' - https://www.ibm.com/docs/en/db2/11.5?topic=support-hadr-nat
# These are the HADR Ports used for internode communication, and are unrelated to Health Check probe port from a Load Balancer
- name: SAP HA AnyDB - IBM Db2 HADR - Append IBM Db2 HA Ports to /etc/services
ansible.builtin.lineinfile:
path: /etc/services
line: "{{ item }}"
state: present
loop:
- "{{ sap_ha_install_anydb_ibmdb2_sid }}_HADR_1\t55001/tcp\t# DB2 HA Port 1" # DB2 HADR local service (env var db2hadrlocalsvc / HADR_LOCAL_SVC)
- "{{ sap_ha_install_anydb_ibmdb2_sid }}_HADR_2\t55002/tcp\t# DB2 HA Port 2" # DB2 HADR remote service (env var db2hadrremotesvc / HADR_REMOTE_SVC)
when: (sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short) or (sap_ha_install_anydb_ibmdb2_hostname_secondary == inventory_hostname_short)


# 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
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 }}"
set anydb_primary="{{ sap_ha_install_anydb_ibmdb2_hostname_primary }}"
set anydb_secondary="{{ sap_ha_install_anydb_ibmdb2_hostname_secondary }}"
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_LOCAL_HOST $anydb_primary
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_LOCAL_SVC "$ibmdb2_sid"_HADR_1
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_REMOTE_HOST $anydb_secondary
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_REMOTE_SVC "$ibmdb2_sid"_HADR_2
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_REMOTE_INST db2$ibmdb2_sid
db2 UPDATE DB CFG FOR $ibmdb2_sid USING INDEXREC RESTART LOGINDEXBUILD ON
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_TIMEOUT 120
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


# 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
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 }}"
set anydb_primary="{{ sap_ha_install_anydb_ibmdb2_hostname_primary }}"
set anydb_secondary="{{ sap_ha_install_anydb_ibmdb2_hostname_secondary }}"
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_LOCAL_HOST $anydb_secondary
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_LOCAL_SVC "$ibmdb2_sid"_HADR_2
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_REMOTE_HOST $anydb_primary
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_REMOTE_SVC "$ibmdb2_sid"_HADR_1
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_REMOTE_INST db2$ibmdb2_sid
db2 UPDATE DB CFG FOR $ibmdb2_sid USING HADR_TIMEOUT 120
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
db2 UPDATE DB CFG FOR $ibmdb2_sid USING INDEXREC RESTART LOGINDEXBUILD ON
when: sap_ha_install_anydb_ibmdb2_hostname_secondary == inventory_hostname_short

# Use the IBM Db2 Command Line Processor
- name: SAP HA AnyDB - IBM Db2 HADR - Rollforward Secondary Node
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

# Use the IBM Db2 Command Line Processor
- name: SAP HA AnyDB - IBM Db2 HADR - Start Secondary Standby Node
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 deactivate db $ibmdb2_sid
db2 start hadr on db $ibmdb2_sid as standby
when: sap_ha_install_anydb_ibmdb2_hostname_secondary == inventory_hostname_short


# Use the IBM Db2 Command Line Processor
- name: SAP HA AnyDB - IBM Db2 HADR - Start Primary Node
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 deactivate db $ibmdb2_sid
db2 start hadr on db $ibmdb2_sid as primary
when: sap_ha_install_anydb_ibmdb2_hostname_primary == inventory_hostname_short
Loading
Loading