Skip to content

Commit

Permalink
sap_ha_install_anydb_ibmdb2: append tasks for cfg and start db2 hadr
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-freeman committed Jun 30, 2024
1 parent 79dd556 commit 368c613
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 13 deletions.
4 changes: 4 additions & 0 deletions roles/sap_ha_install_anydb_ibmdb2/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ 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
85 changes: 85 additions & 0 deletions roles/sap_ha_install_anydb_ibmdb2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,91 @@
- "{{ 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


- name: SAP HA AnyDB - IBM Db2 HADR - Include tasks for Passwordless SSH
ansible.builtin.import_tasks: passwordless_ssh.yml

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---

- name: SAP HA AnyDB - IBM Db2 HADR (Google Cloud) - Fence Agent Packages
ansible.builtin.package:
name:
- fence-agents-gce
# - resource-agents-gcp
state: present
# - name: SAP HA AnyDB - IBM Db2 HADR (Google Cloud) - Fence Agent Packages
# ansible.builtin.package:
# name:
# - fence-agents-gce
# - resource-agents-gcp
# state: present


- name: SAP HA AnyDB - IBM Db2 HADR (Google Cloud) - GCloud Repo Key
Expand Down Expand Up @@ -47,13 +47,14 @@
/db2/$ibmdb2_instance/sqllib/bin/db2cm -create -primaryVIP "{{ sap_ha_install_anydb_ibmdb2_vip_primary_ip_address }}" -db $ibmdb2_sid -instance $ibmdb2_instance
failed_when: not __sap_ha_install_anydb_ibmdb2_config_gcp_1.rc == 0 and not 'ip address is pingable' in __sap_ha_install_anydb_ibmdb2_config_gcp_1.stdout

# # Setting to be performed on both Primary and Secondary node
# - name: SAP HA AnyDB - IBM Db2 HADR (Google Cloud) - Primary and Secondary Node - Provide GCloud CLI credentials
# register: __sap_ha_install_anydb_ibmdb2_config_gcp_credentials
# when:
# - __sap_ha_install_anydb_ibmdb2_platform == "cloud_gcp_ce_vm"
# ansible.builtin.shell: |
# gcloud auth activate-service-account --key-file=file.json --project=name
# Setting to be performed on both Primary and Secondary node
- name: SAP HA AnyDB - IBM Db2 HADR (Google Cloud) - Primary and Secondary Node - Provide GCloud CLI credentials
register: __sap_ha_install_anydb_ibmdb2_config_gcp_credentials
when:
- __sap_ha_install_anydb_ibmdb2_platform == "cloud_gcp_ce_vm"
ansible.builtin.shell: |
gcloud auth activate-service-account --key-file="{{ sap_ha_install_anydb_ibmdb2_gcp_credentials_json_file }}" --project="{{ sap_ha_install_anydb_ibmdb2_gcp_project }}"
gcloud debug targets list --quiet
# # VERIFY - Missing fence_gce ?
# # db2cm script must run as root
Expand Down

0 comments on commit 368c613

Please sign in to comment.