diff --git a/.ansible-lint b/.ansible-lint index 5be5b00..6328eba 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -18,6 +18,7 @@ exclude_paths: # sap_rfc role is excluded because it is no longer supported. - roles/sap_rfc + skip_list: # We don't want to enforce new Ansible versions for Galaxy: - meta-runtime[unsupported-version] @@ -29,15 +30,3 @@ skip_list: - schema # Allow templating inside name because it creates more detailed output: - name[template] - - # TODO: Review and remove after all roles are reworked and cleaned up! - - empty-string-compare - - indentation - - line-length - - command-instead-of-module # Using command rather than module - - command-instead-of-shell # Use shell only when shell functionality is required - - experimental # all rules tagged as experimental - - no-changed-when # Commands should not change things if nothing needs doing - - no-handler # Tasks that run when changed should likely be handlers - - risky-shell-pipe # Shells that use pipes should set the pipefail option - - unnamed-task # All tasks should be named diff --git a/.github/workflows/ansible-lint-config b/.github/workflows/ansible-lint-config deleted file mode 100644 index 69435ba..0000000 --- a/.github/workflows/ansible-lint-config +++ /dev/null @@ -1,10 +0,0 @@ ---- - -skip_list: - - command-instead-of-module - - command-instead-of-shell - - line-length - - risky-shell-pipe - - no-changed-when - - no-handler - - ignore-errors diff --git a/.github/workflows/ansible-lint-sap_control.yml b/.github/workflows/ansible-lint-sap_control.yml new file mode 100644 index 0000000..1f91969 --- /dev/null +++ b/.github/workflows/ansible-lint-sap_control.yml @@ -0,0 +1,36 @@ +--- +name: Ansible Lint - sap_control + +on: + push: + branches: + - main + - dev + paths: + - 'roles/sap_control/**' + pull_request: + branches: + - main + - dev + paths: + - 'roles/sap_control/**' + + workflow_dispatch: + +jobs: + ansible-lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + # Use @v25 to automatically track the latest release from the year 2025. + # ansible-lint uses Calendar Versioning (e.g., v25.9.0 -> YYYY.MM.PATCH). + # Avoid using @main, which can introduce breaking changes unexpectedly. + - uses: ansible/ansible-lint@v25 + with: + # v25.7.0 no longer uses 'working_directory' and role path is set in 'args'. + # Role specific .ansible-lint can be added with argument '-c'. + args: roles/sap_control + # Use the shared requirements file from the collection root for dependency context. + requirements_file: ./requirements.yml diff --git a/.github/workflows/ansible-lint-sap_firewall.yml b/.github/workflows/ansible-lint-sap_firewall.yml new file mode 100644 index 0000000..bfb28a2 --- /dev/null +++ b/.github/workflows/ansible-lint-sap_firewall.yml @@ -0,0 +1,36 @@ +--- +name: Ansible Lint - sap_firewall + +on: + push: + branches: + - main + - dev + paths: + - 'roles/sap_firewall/**' + pull_request: + branches: + - main + - dev + paths: + - 'roles/sap_firewall/**' + + workflow_dispatch: + +jobs: + ansible-lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + # Use @v25 to automatically track the latest release from the year 2025. + # ansible-lint uses Calendar Versioning (e.g., v25.9.0 -> YYYY.MM.PATCH). + # Avoid using @main, which can introduce breaking changes unexpectedly. + - uses: ansible/ansible-lint@v25 + with: + # v25.7.0 no longer uses 'working_directory' and role path is set in 'args'. + # Role specific .ansible-lint can be added with argument '-c'. + args: roles/sap_firewall + # Use the shared requirements file from the collection root for dependency context. + requirements_file: ./requirements.yml diff --git a/.github/workflows/ansible-lint-sap_hana_backint.yml b/.github/workflows/ansible-lint-sap_hana_backint.yml new file mode 100644 index 0000000..2fdaaa7 --- /dev/null +++ b/.github/workflows/ansible-lint-sap_hana_backint.yml @@ -0,0 +1,36 @@ +--- +name: Ansible Lint - sap_hana_backint + +on: + push: + branches: + - main + - dev + paths: + - 'roles/sap_hana_backint/**' + pull_request: + branches: + - main + - dev + paths: + - 'roles/sap_hana_backint/**' + + workflow_dispatch: + +jobs: + ansible-lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + # Use @v25 to automatically track the latest release from the year 2025. + # ansible-lint uses Calendar Versioning (e.g., v25.9.0 -> YYYY.MM.PATCH). + # Avoid using @main, which can introduce breaking changes unexpectedly. + - uses: ansible/ansible-lint@v25 + with: + # v25.7.0 no longer uses 'working_directory' and role path is set in 'args'. + # Role specific .ansible-lint can be added with argument '-c'. + args: roles/sap_hana_backint + # Use the shared requirements file from the collection root for dependency context. + requirements_file: ./requirements.yml diff --git a/.github/workflows/ansible-lint-sap_hana_sr_takeover.yml b/.github/workflows/ansible-lint-sap_hana_sr_takeover.yml new file mode 100644 index 0000000..ec04857 --- /dev/null +++ b/.github/workflows/ansible-lint-sap_hana_sr_takeover.yml @@ -0,0 +1,36 @@ +--- +name: Ansible Lint - sap_hana_sr_takeover + +on: + push: + branches: + - main + - dev + paths: + - 'roles/sap_hana_sr_takeover/**' + pull_request: + branches: + - main + - dev + paths: + - 'roles/sap_hana_sr_takeover/**' + + workflow_dispatch: + +jobs: + ansible-lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + # Use @v25 to automatically track the latest release from the year 2025. + # ansible-lint uses Calendar Versioning (e.g., v25.9.0 -> YYYY.MM.PATCH). + # Avoid using @main, which can introduce breaking changes unexpectedly. + - uses: ansible/ansible-lint@v25 + with: + # v25.7.0 no longer uses 'working_directory' and role path is set in 'args'. + # Role specific .ansible-lint can be added with argument '-c'. + args: roles/sap_hana_sr_takeover + # Use the shared requirements file from the collection root for dependency context. + requirements_file: ./requirements.yml diff --git a/.github/workflows/ansible-lint-sap_profile_update.yml b/.github/workflows/ansible-lint-sap_profile_update.yml new file mode 100644 index 0000000..0546bea --- /dev/null +++ b/.github/workflows/ansible-lint-sap_profile_update.yml @@ -0,0 +1,36 @@ +--- +name: Ansible Lint - sap_profile_update + +on: + push: + branches: + - main + - dev + paths: + - 'roles/sap_profile_update/**' + pull_request: + branches: + - main + - dev + paths: + - 'roles/sap_profile_update/**' + + workflow_dispatch: + +jobs: + ansible-lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + # Use @v25 to automatically track the latest release from the year 2025. + # ansible-lint uses Calendar Versioning (e.g., v25.9.0 -> YYYY.MM.PATCH). + # Avoid using @main, which can introduce breaking changes unexpectedly. + - uses: ansible/ansible-lint@v25 + with: + # v25.7.0 no longer uses 'working_directory' and role path is set in 'args'. + # Role specific .ansible-lint can be added with argument '-c'. + args: roles/sap_profile_update + # Use the shared requirements file from the collection root for dependency context. + requirements_file: ./requirements.yml diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index 9a83c9a..ba2473f 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -1,17 +1,24 @@ -name: Ansible Lint +--- +name: Ansible Lint - Collection -on: [push, pull_request] +on: + schedule: + # This is 03:05 UTC, which is 5:05 AM in Prague/CEST. + - cron: '5 3 * * 1' + + workflow_dispatch: jobs: ansible-lint: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v3 - - run: | - pip3 install ansible-lint - ansible-lint -p roles/ -c .github/workflows/ansible-lint-config + - uses: actions/checkout@v5 -# Static: use Ansible Community Edition 4.8.0, with lowest compatible Ansible Core 2.11.6 and use Ansible-lint 5.2.1 + # Use @v25 to automatically track the latest release from the year 2025. + # ansible-lint uses Calendar Versioning (e.g., v25.9.0 -> YYYY.MM.PATCH). + # Avoid using @main, which can introduce breaking changes unexpectedly. + - uses: ansible/ansible-lint@v25 + with: + # Use the shared requirements file from the collection root for dependency context. + requirements_file: ./requirements.yml diff --git a/.github/workflows/ansible-test-sanity.yml b/.github/workflows/ansible-test-sanity.yml new file mode 100644 index 0000000..3f5ccf6 --- /dev/null +++ b/.github/workflows/ansible-test-sanity.yml @@ -0,0 +1,84 @@ +--- +# Always check ansible-core support matrix before configuring units matrix. +# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix + +name: Ansible Test - Sanity + +on: + schedule: + # This is 01:05 UTC, which is 3:05 AM in Prague/CEST + - cron: '5 3 * * 1' + + pull_request: + branches: + - main + - dev + + workflow_dispatch: + +jobs: + sanity-supported: + runs-on: ubuntu-latest + name: Sanity (Supported Ⓐ${{ matrix.ansible }}) + strategy: + fail-fast: false # Disabled so we can see all failed combinations. + # Define a build matrix to test compatibility across multiple Ansible versions. + # Each version listed below will spawn a separate job that runs in parallel. + matrix: + ansible: + # Supported versions (must pass) + - 'stable-2.18' # Python 3.11 - 3.13 + - 'stable-2.19' # Python 3.11 - 3.13 + - 'devel' # Test against the upcoming development version. + steps: + - uses: actions/checkout@v5 + + - name: ansible-test - sanity + uses: ansible-community/ansible-test-gh-action@release/v1 + with: + ansible-core-version: ${{ matrix.ansible }} + testing-type: sanity + + sanity-eol: + runs-on: ubuntu-latest + # This job only runs if the supported tests pass + needs: sanity-supported + name: Sanity (EOL Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) + continue-on-error: true # This entire job is allowed to fail + strategy: + fail-fast: false # Disabled so we can see all failed combinations. + # Define a build matrix to test compatibility across multiple Ansible versions. + # Each version listed below will spawn a separate job that runs in parallel. + matrix: + ansible: + - 'stable-2.14' # Python 3.9 - 3.11 + - 'stable-2.15' # Python 3.9 - 3.11 + - 'stable-2.16' # Python 3.10 - 3.12 + - 'stable-2.17' # Python 3.10 - 3.12 + python: + - '3.9' + - '3.10' + - '3.11' + - '3.12' + exclude: + # Exclusions for incompatible Python versions. + - ansible: 'stable-2.14' + python: '3.12' + + - ansible: 'stable-2.15' + python: '3.12' + + - ansible: 'stable-2.16' + python: '3.9' + + - ansible: 'stable-2.17' + python: '3.9' + steps: + - uses: actions/checkout@v5 + + - name: ansible-test - sanity + uses: ansible-community/ansible-test-gh-action@release/v1 + with: + ansible-core-version: ${{ matrix.ansible }} + target-python-version: ${{ matrix.python }} + testing-type: sanity diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 0000000..5ff7bc8 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,25 @@ +--- +name: CodeSpell + +on: + push: + branches: + - dev + pull_request: + branches: + - dev + + workflow_dispatch: + +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + - uses: codespell-project/actions-codespell@v2 + with: + # lowercase only + ignore_words_list: aas,hsa,te,chage,addopt,sybsystem,uptodate,pase,enque diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89cc398..cdf88a7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ exclude: '^$' fail_fast: true repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.3.0 hooks: - id: end-of-file-fixer - id: check-merge-conflict @@ -14,24 +14,26 @@ repos: - id: check-executables-have-shebangs name: "Executable text files have shebangs" - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + files: .*\.(xml|yaml|yml|md|adoc)$ - id: check-xml - id: check-yaml args: - "-m" -# - repo: https://github.com/adrienverge/yamllint.git -# rev: v1.26.3 -# hooks: -# - id: yamllint -# exclude: > -# (?x)^( -# examples/playbooks/templates/.*| -# examples/other/some.j2.yaml -# )$ -# files: \.(yaml|yml)$ -# types: [file, yaml] -# entry: yamllint --strict + # - repo: https://github.com/adrienverge/yamllint.git + # rev: v1.26.3 + # hooks: + # - id: yamllint + # exclude: > + # (?x)^( + # examples/playbooks/templates/.*| + # examples/other/some.j2.yaml + # )$ + # files: \.(yaml|yml)$ + # types: [file, yaml] + # entry: yamllint --strict - repo: https://github.com/ansible-community/ansible-lint.git - rev: v5.3.1 # put latest release tag from https://github.com/ansible-community/ansible-lint/releases/ + rev: v6.22.1 # put latest release tag from https://github.com/ansible-community/ansible-lint/releases/ hooks: - id: ansible-lint files: \.(yaml|yml)$ diff --git a/.yamllint b/.yamllint index 2672e37..ee4457c 100644 --- a/.yamllint +++ b/.yamllint @@ -1,13 +1,27 @@ +# SPDX-License-Identifier: Apache-2.0 --- -ignore: | - .github - .tox - +# 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: + require-starting-space: false + min-spaces-from-content: 1 + 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 - document-start: disable - braces: disable - comments-indentation: disable + octal-values: + forbid-implicit-octal: true + forbid-explicit-octal: true diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 982bda3..85e3815 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,69 @@ Community SAP_OPERATIONS Release Notes .. contents:: Topics +v2.0.0 +====== + +Release Summary +--------------- + +Complete redesign and rework of all Ansible Roles in Collection. + +Minor Changes +------------- + +- collection - Remove non-SAP roles and obsolete roles (https://github.com/sap-linuxlab/community.sap_operations/pull/43) +- collection - Prepare for release 2.0.0 and housekeeping (https://github.com/sap-linuxlab/community.sap_operations/pull/55) +- sap_profile_update - Complete redesign and rework (https://github.com/sap-linuxlab/community.sap_operations/pull/47) +- sap_control - Complete redesign and rework (https://github.com/sap-linuxlab/community.sap_operations/pull/48) +- sap_hana_backint - Complete redesign and rework (https://github.com/sap-linuxlab/community.sap_operations/pull/50) +- sap_rfc - Deprecate the role and update linting to ignore it (https://github.com/sap-linuxlab/community.sap_operations/pull/51) +- sap_hana_sr_takeover - Complete redesign and rework (https://github.com/sap-linuxlab/community.sap_operations/pull/52) + +Bugfixes +-------- + +- sap_facts - Fix issue 31 by adding restart parameter (https://github.com/sap-linuxlab/community.sap_operations/pull/54) + + +v1.0.0 +====== + +Release Summary +--------------- + +Re-release under 1.0.0 to conform with Galaxy version requirements. + + +v0.9.2 +====== + +Release Summary +--------------- + +Improvements to sap_control role and various bug fixes. + +Minor Changes +------------- + +- Stage changes to main by @rainerleber (https://github.com/sap-linuxlab/community.sap_operations/pull/32) + +Bugfixes +-------- + +- sap_facts.sh - ps print only executable with path by @jhohwieler (https://github.com/sap-linuxlab/community.sap_operations/pull/28) +- solution to issue#25 by @crweller (https://github.com/sap-linuxlab/community.sap_operations/pull/27) +- Replace ansible.builtin.pause with ansible.builtin.wait_for by @jhohwieler (https://github.com/sap-linuxlab/community.sap_operations/pull/29) + + +v0.9.1 +====== + +Release Summary +--------------- + +Improvements to sap_rfc role and various bug fixes. + v0.9.0 ====== @@ -11,4 +74,4 @@ v0.9.0 Release Summary --------------- -This is the first release of the ``community.sap_operations`` collection. It is the initial relase for the ``community.sap_operations`` collection +Initial release of the community.sap_operations Ansible Collection. diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 0000000..a6db7f5 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,103 @@ +# Contributors to community.sap_operations + +Thank you to all contributors who have helped make this project possible! + +We welcome contributions! Please see our [contributing guidelines](https://sap-linuxlab.github.io/initiative_contributions/) to get started. + +## Maintainers + +The following people are the maintainers of this collection: + +### SUSE + +- [Marcel Mamula](https://github.com/marcelmamula) + + +For specific role maintainers, see the `README.md` file in the corresponding role's directory. + +## All Contributors + +| Name | Commits | Lines Changed | Last Commit | +| ---- | ------- | ------------- | ----------- | +| [Marcel Mamula](https://github.com/marcelmamula) | 27 | 13114 | 2026-02-09 | +| [Rainer Leber](https://github.com/rainerleber) | 27 | 1558 | 2022-05-16 | +| [Sean Freeman](https://github.com/sean-freeman) | 13 | 941 | 2024-01-10 | +| Nicolas Bettembourg | 7 | 207 | 2025-07-23 | +| rickgcv | 5 | 26 | 2023-01-23 | +| CRW | 3 | 36 | 2025-09-08 | +| [Markus Koch](https://github.com/rhmk) | 3 | 594 | 2025-01-14 | +| [Bernd Finger](https://github.com/berndfinger) | 2 | 5235 | 2025-12-15 | +| nbttmbrg | 1 | 44 | 2025-09-11 | +| Jörg Hohwieler | 1 | 2 | 2024-08-19 | +| Carl-Rainer Weller | 1 | 13 | 2024-08-07 | +| Ondra Machacek | 1 | 2 | 2022-05-31 | + +## Contributions by Role + +### Role: sap_profile_update + +| Name | Commits | Lines Changed | Last Commit | +| ---- | ------- | ------------- | ----------- | +| [Marcel Mamula](https://github.com/marcelmamula) | 3 | 950 | 2026-02-06 | +| [Sean Freeman](https://github.com/sean-freeman) | 2 | 6 | 2024-01-10 | +| [Rainer Leber](https://github.com/rainerleber) | 2 | 28 | 2022-05-02 | +| [Markus Koch](https://github.com/rhmk) | 1 | 7 | 2022-09-07 | +| Ondra Machacek | 1 | 2 | 2022-05-31 | +| [Bernd Finger](https://github.com/berndfinger) | 1 | 150 | 2022-01-25 | + +### Role: sap_control + +| Name | Commits | Lines Changed | Last Commit | +| ---- | ------- | ------------- | ----------- | +| [Marcel Mamula](https://github.com/marcelmamula) | 9 | 2297 | 2026-02-09 | +| Nicolas Bettembourg | 5 | 201 | 2025-07-23 | +| CRW | 3 | 36 | 2025-09-08 | +| rickgcv | 3 | 18 | 2023-01-23 | +| [Rainer Leber](https://github.com/rainerleber) | 3 | 100 | 2022-05-03 | +| [Sean Freeman](https://github.com/sean-freeman) | 2 | 21 | 2024-01-10 | +| [Markus Koch](https://github.com/rhmk) | 1 | 8 | 2025-01-14 | +| Carl-Rainer Weller | 1 | 13 | 2024-08-07 | +| [Bernd Finger](https://github.com/berndfinger) | 1 | 397 | 2022-01-25 | + +### Role: sap_firewall + +| Name | Commits | Lines Changed | Last Commit | +| ---- | ------- | ------------- | ----------- | +| [Marcel Mamula](https://github.com/marcelmamula) | 5 | 1307 | 2026-02-06 | +| [Rainer Leber](https://github.com/rainerleber) | 4 | 100 | 2022-05-03 | +| [Sean Freeman](https://github.com/sean-freeman) | 1 | 2 | 2022-12-28 | +| [Markus Koch](https://github.com/rhmk) | 1 | 6 | 2022-09-07 | +| [Bernd Finger](https://github.com/berndfinger) | 1 | 179 | 2022-01-25 | + +### Role: sap_rfc + +| Name | Commits | Lines Changed | Last Commit | +| ---- | ------- | ------------- | ----------- | +| [Sean Freeman](https://github.com/sean-freeman) | 6 | 650 | 2024-01-10 | +| [Marcel Mamula](https://github.com/marcelmamula) | 3 | 59 | 2026-02-09 | +| [Markus Koch](https://github.com/rhmk) | 1 | 12 | 2022-09-07 | + +### Role: sap_hana_backint + +| Name | Commits | Lines Changed | Last Commit | +| ---- | ------- | ------------- | ----------- | +| [Rainer Leber](https://github.com/rainerleber) | 7 | 764 | 2022-05-03 | +| [Marcel Mamula](https://github.com/marcelmamula) | 4 | 4022 | 2026-02-09 | +| [Sean Freeman](https://github.com/sean-freeman) | 3 | 90 | 2023-08-22 | +| [Bernd Finger](https://github.com/berndfinger) | 1 | 1232 | 2022-01-25 | + +### Role: sap_hana_sr_takeover + +| Name | Commits | Lines Changed | Last Commit | +| ---- | ------- | ------------- | ----------- | +| [Marcel Mamula](https://github.com/marcelmamula) | 2 | 885 | 2026-02-06 | +| [Markus Koch](https://github.com/rhmk) | 2 | 298 | 2022-09-07 | +| [Sean Freeman](https://github.com/sean-freeman) | 1 | 66 | 2022-12-28 | + +## Honorable Mentions + +We would like to thank the following people for their original contributions to the code that this collection is based on: + +- Jason Masipiquena (IBM): Origin developer of this Ansible Collection +- Sherard Guico (IBM): Origin technical SAP specialist, installation expertise and primary testing + diff --git a/README.md b/README.md index efc3a36..c62b32c 100644 --- a/README.md +++ b/README.md @@ -1,108 +1,113 @@ -# community.sap_operations Ansible Collection  +# community.sap_operations Ansible Collection -This Ansible Collection executes various SAP Systems operational tasks, which can be used day-to-day individually or combined for more complex regular maintainance automation + -## Functionality +## Description This Ansible Collection executes various SAP Systems operational tasks, including: -- **OS configuration Post-install of SAP Software** - - Create ansible user for managing systems - - Update /etc/hosts file - - Update SSH authorized known hosts file - - Update fapolicy entries based on SAP System instance numbers - - Update firewall port entries based on SAP System instance numbers - - License registration and refresh for RHEL subscription manager -- **SAP administration tasks** - - Start/Stop of SAP HANA and SAP NetWeaver (in any configuration) - - Update SAP profile files - - Execute SAP RFCs - -## Contents - -An Ansible Playbook can call either an Ansible Role, or the individual Ansible Modules: -- **Ansible Roles** (runs multiple Ansible Modules) -- **Ansible Modules** (and adjoining Python/Bash Functions) - -For further information regarding the development, code structure and execution workflow please read the [Development documentation](./docs/DEVELOPMENT.md). - -Within this Ansible Collection, there are various Ansible Roles and Ansible Modules. - -#### Ansible Roles - -| Name | Summary | -| :-- | :-- | -| [sap_control](/roles/sap_control) | starting and stopping SAP systems | -| [sap_firewall](/roles/sap_firewall) | update service `firewalld` for generic / sap nw / sap hana related ports | -| [sap_hana_backint](/roles/sap_hana_backint) | | -| [sap_hana_sr_takeover](/roles/sap_hana_sr_takeover) | | -| [sap_profile_update](/roles/sap_profile_update) | update default and instance profiles | -| [sap_rfc](/roles/sap_rfc) | executes SAP RFCs | - -**Deprecated Roles** -Following Ansible Roles were deprecated: -- os_ansible_user -- os_etchosts -- os_knownhosts -- sap_fapolicy - Alternative role is available in [Linux System Roles](https://github.com/linux-system-roles/fapolicyd). -- sap_rhsm - Alternative role is available in [Linux System Roles](https://github.com/linux-system-roles/rhc). - -#### Ansible Modules - -| Name | Summary | -| :-- | :-- | -| [sap_operations.sap_facts](/docs/module_sap_facts.md) | gather SAP facts in a host (e.g. SAP System IDs and SAP System Instance Numbers of either SAP HANA database server or SAP NetWeaver application server) | -| [sap_operations.sap_monitor_hana_status](/docs/module_sap_monitor.md) | check status of running SAP HANA database server | -| [sap_operations.sap_monitor_nw_status](/docs/module_sap_monitor.md) | check status of running SAP NetWeaver application server | -| [sap_operations.sap_monitor_nw_perf](/docs/module_sap_monitor.md) | check host performance metrics from SAP NetWeaver Primary Application Server (PAS) instance | -| [sap_operations.sap_monitor_nw_response](/docs/module_sap_monitor.md) | check system response time metrics from SAP NetWeaver Primary Application Server (PAS) instance | - -## Execution examples - -There are various methods to execute the Ansible Collection, dependant on the use case. For more information, see [Execution examples with code samples](./docs/EXEC_EXAMPLES.md) and the summary below: - -| Execution Scenario | Use Case | Target | +- Start, Stop and Restart of SAP Systems consisting of SAP Netweaver and SAP HANA. +- Configuration of firewall with predefined ports for SAP products. +- Configuration of SAP HANA Backint backups and their execution and cleanup. +- Manages parameters in SAP profile files. +- Execution of SAP HANA Replication takeover action in replicated environment. + +## Requirements + +| Component | Control Node | Managed Node | | --- | --- | --- | -| Ansible Playbook -> source Ansible Collection -> execute Ansible Task --> run Ansible Module ---> run Python/Bash Functions | Simple executions with a few activities | Localhost or Remote | -| Ansible Playbook -> source Ansible Collection -> execute Ansible Task --> run Ansible Role ---> run Ansible Module ----> run Python/Bash Functions --> run Ansible Role---> ... | Complex executions with various interlinked activities; run in parallel or sequentially | Localhost or Remote | -| Python/Bash Functions | Simple testing or non-Ansible use cases | Localhost | +| Operating System | Any OS | Red Hat Enterprise Linux for SAP Solutions 8.x, 9.x and 10.xSUSE Linux Enterprise Server for SAP applications 15 SP5, 15 SP6, 15 SP7 and 16.0 | +| Python | 3.11 or higher | 3.9 or higher | +| Ansible-Core | 2.18 or higher | N/A | +| Ansible | 12 or higher | N/A | -## Requirements, Dependencies and Testing +> **Managed Node Registration** +> Operating system needs to have access to required package repositories either directly or via subscription registration. -### Operating System requirements +**Additional notes:** -Designed for Linux operating systems, e.g. RHEL and SLES. +- **Version Compatibility:** For a detailed mapping of supported Python versions and Ansible-Core life cycles, refer to the official [Ansible-Core Support Matrix](https://docs.ansible.com/projects/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix). +- **Control Node Permissions:** Ensure the user executing the playbooks has the necessary SSH keys and sudo privileges configured for the target environment. -This role has not been tested and amended for SAP NetWeaver Application Server instantiations on IBM AIX or Windows Server. +## Installation Instructions -Assumptions for executing this role include: -- Registered OS License and OS Package repositories are available (from the relevant content delivery network of the OS vendor) +### Installation +Install this collection with Ansible Galaxy command: +```console +ansible-galaxy collection install community.sap_operations +``` -### Python requirements +### Upgrade +Installed Ansible Collection will not be upgraded automatically when Ansible package is upgraded. -Python 3 from the execution/controller host. +To upgrade the collection to the latest available version, run the following command: +```console +ansible-galaxy collection install community.sap_operations --upgrade +``` -### Testing on execution/controller host +You can also install a specific version of the collection, when you encounter issues with latest version. Please report these issues in affected Role repository if that happens. +Example of downgrading collection to version 1.0.0: +``` +ansible-galaxy collection install community.sap_operations:==1.0.0 +``` -**Tests with Ansible Core release versions:** -- Ansible Core 2.11.5 community edition +See [Installing collections](https://docs.ansible.com/ansible/latest/collections_guide/collections_installing.html) for more details on installation methods. -**Tests with Python release versions:** -- Python 3.9.7 (i.e. CPython distribution) +## Use Cases -**Tests with Operating System release versions:** -- RHEL 8.4 -- macOS 11.6 (Big Sur), with Homebrew used for Python 3.x via PyEnv +### Ansible Roles +| Name | Summary | +| --- | --- | +| [sap_control](https://github.com/sap-linuxlab/community.sap_operations/tree/main/roles/sap_control) | Executes predefined sapcontrol operations | +| [sap_firewall](https://github.com/sap-linuxlab/community.sap_operations/tree/main/roles/sap_firewall) | Configures firewall with recommended rules for SAP Systems or custom ports | +| [sap_hana_backint](https://github.com/sap-linuxlab/community.sap_operations/tree/main/roles/sap_hana_backint) | Executes range of actions to operate SAP HANA Backint Agents across different Cloud platforms | +| [sap_hana_sr_takeover](https://github.com/sap-linuxlab/community.sap_operations/tree/main/roles/sap_hana_sr_takeover) | Executes Takeover operation on SAP HANA System with configured SAP HANA System Replication (HSR) | +| [sap_profile_update](https://github.com/sap-linuxlab/community.sap_operations/tree/main/roles/sap_profile_update) | Manages parameters in SAP profile files | -### Testing on target/remote host +#### Deprecated Roles +| Name | Summary | +| --- | --- | +| os_ansible_user | Removed in favor of built in Ansible Module `ansible.builtin.user` | +| os_etchosts | Removed in favor of Ansible Role [community.sap_install.sap_maintain_etc_hosts](https://github.com/sap-linuxlab/community.sap_install/tree/main/roles/sap_maintain_etc_hosts) | +| os_knownhosts | Removed in favor of built in Ansible Module `ansible.builtin.known_hosts` | +| sap_fapolicy | Removed in favor of Ansible Role [linux_system_roles.fapolicyd](https://github.com/linux-system-roles/fapolicyd) | +| sap_rfc | Deprecated because of SAP discontinued development and maintenance of the PyRFC library in 2024 | +| sap_rhsm | Removed in favor of Ansible Role [linux_system_roles.rhc](https://github.com/linux-system-roles/rhc) | -**Tests with Operating System release versions:** -- RHEL 8.2 for SAP +### Ansible Modules -## License +> **NOTE: All included modules were deprecated in 2.0.0 release.** + +## Testing +This Ansible Collection was tested across different Operating Systems, SAP products and scenarios. You can find examples of some of them below. + +Operating systems: + +- Red Hat Enterprise Linux for SAP Solutions 8.x, 9.x and 10.x +- SUSE Linux Enterprise Server for SAP applications 15 SP7 and 16.0 + +SAP Products: -- [Apache 2.0](./LICENSE) +- SAP S/4HANA AnyPremise 2023 +- SAP BW/4HANA 2023 +- SAP HANA 2.0 SPS08 + +## Contributing +For information on how to contribute, please see our [contribution guidelines](https://sap-linuxlab.github.io/initiative_contributions/). ## Contributors +We welcome contributions to this collection. For a list of all contributors and information on how you can get involved, please see our [CONTRIBUTORS document](./CONTRIBUTORS.md). + +## Support +You can report any issues using [Issues](https://github.com/sap-linuxlab/community.sap_operations/issues) section. + +## Release Notes and Roadmap +You can find the release notes of this collection in [Changelog file](https://github.com/sap-linuxlab/community.sap_operations/blob/main/CHANGELOG.rst) -Contributors to the Ansible Roles within this Ansible Collection, are shown within [/docs/contributors](./docs/CONTRIBUTORS.md). +## Further Information + +### Variable Precedence Rules +Please follow [Ansible Precedence guidelines](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable) on how to pass variables when using this collection. + +## License +[Apache 2.0](https://github.com/sap-linuxlab/community.sap_install/blob/main/LICENSE) diff --git a/changelogs/.plugin-cache.yaml b/changelogs/.plugin-cache.yaml deleted file mode 100644 index 6b724bd..0000000 --- a/changelogs/.plugin-cache.yaml +++ /dev/null @@ -1,22 +0,0 @@ -objects: - role: {} -plugins: - become: {} - cache: {} - callback: {} - cliconf: {} - connection: {} - httpapi: {} - inventory: {} - lookup: {} - module: - sap_pyrfc: - description: Execute RFC calls - name: sap_pyrfc - namespace: '' - version_added: 0.1.0 - netconf: {} - shell: {} - strategy: {} - vars: {} -version: 1.0.0 diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index 98bc574..4f1ac0e 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -1,9 +1,38 @@ ancestor: null releases: 0.9.0: - changes: - release_summary: 'This is the first release of the ``community.sap_operations`` - collection. It is the initial relase for the collection' - fragments: - - 0.9.0.yml release_date: '2022-05-16' + changes: + release_summary: Initial release of the community.sap_operations Ansible Collection + 0.9.1: + release_date: '2024-01-10' + changes: + release_summary: Improvements to sap_rfc role and various bug fixes + 0.9.2: + release_date: '2025-01-27' + changes: + release_summary: Improvements to sap_control role and various bug fixes. + minor_changes: + - Stage changes to main by @rainerleber (https://github.com/sap-linuxlab/community.sap_operations/pull/32) + bugfixes: + - sap_facts.sh - ps print only executable with path by @jhohwieler (https://github.com/sap-linuxlab/community.sap_operations/pull/28) + - solution to issue#25 by @crweller (https://github.com/sap-linuxlab/community.sap_operations/pull/27) + - Replace ansible.builtin.pause with ansible.builtin.wait_for by @jhohwieler (https://github.com/sap-linuxlab/community.sap_operations/pull/29) + 1.0.0: + release_date: '2024-01-10' + changes: + release_summary: Re-release under 1.0.0 to conform with Galaxy version requirements + 2.0.0: + release_date: '2026-02-09' + changes: + release_summary: Complete redesign and rework of all Ansible Roles in Collection + minor_changes: + - collection - Remove non-SAP roles and obsolete roles (https://github.com/sap-linuxlab/community.sap_operations/pull/43) + - collection - Prepare for release 2.0.0 and housekeeping (https://github.com/sap-linuxlab/community.sap_operations/pull/55) + - sap_profile_update - Complete redesign and rework (https://github.com/sap-linuxlab/community.sap_operations/pull/47) + - sap_control - Complete redesign and rework (https://github.com/sap-linuxlab/community.sap_operations/pull/48) + - sap_hana_backint - Complete redesign and rework (https://github.com/sap-linuxlab/community.sap_operations/pull/50) + - sap_rfc - Deprecate the role and update linting to ignore it (https://github.com/sap-linuxlab/community.sap_operations/pull/51) + - sap_hana_sr_takeover - Complete redesign and rework (https://github.com/sap-linuxlab/community.sap_operations/pull/52) + bugfixes: + - sap_facts - Fix issue 31 by adding restart parameter (https://github.com/sap-linuxlab/community.sap_operations/pull/54) \ No newline at end of file diff --git a/changelogs/config.yaml b/changelogs/config.yaml index b846907..ebeceda 100644 --- a/changelogs/config.yaml +++ b/changelogs/config.yaml @@ -1,30 +1,34 @@ +--- + changelog_filename_template: ../CHANGELOG.rst changelog_filename_version_depth: 0 changes_file: changelog.yaml changes_format: combined +ignore_other_fragment_extensions: true keep_fragments: false mention_ancestor: true -flatmap: true new_plugins_after_name: removed_features notesdir: fragments prelude_section_name: release_summary prelude_section_title: Release Summary +sanitize_changelog: true sections: -- - major_changes - - Major Changes -- - minor_changes - - Minor Changes -- - breaking_changes - - Breaking Changes / Porting Guide -- - deprecated_features - - Deprecated Features -- - removed_features - - Removed Features (previously deprecated) -- - security_fixes - - Security Fixes -- - bugfixes - - Bugfixes -- - known_issues - - Known Issues -title: Community SAP_OPERATIONS + - - major_changes + - Major Changes + - - minor_changes + - Minor Changes + - - breaking_changes + - Breaking Changes / Porting Guide + - - deprecated_features + - Deprecated Features + - - removed_features + - Removed Features (previously deprecated) + - - security_fixes + - Security Fixes + - - bugfixes + - Bugfixes + - - known_issues + - Known Issues +title: community.sap_operations trivial_section_name: trivial +use_fqcn: true diff --git a/changelogs/fragments/.keep b/changelogs/fragments/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/changelogs/fragments/37_sap_control_add_system_functions b/changelogs/fragments/37_sap_control_add_system_functions deleted file mode 100644 index a87938f..0000000 --- a/changelogs/fragments/37_sap_control_add_system_functions +++ /dev/null @@ -1,3 +0,0 @@ -minor_changes: - - sap_control - add the mechanisms to handle asynchronous sapcontrol functions - - sap_control - add UpdateSystem, RestartSystem, StartSystem, StopSystem functions diff --git a/changelogs/fragments/39_fixing_sid_selection.yaml b/changelogs/fragments/39_fixing_sid_selection.yaml deleted file mode 100644 index 17a40e3..0000000 --- a/changelogs/fragments/39_fixing_sid_selection.yaml +++ /dev/null @@ -1,3 +0,0 @@ -bugfixes: - - roles/sap_control - fixing sap_sid parameter ignored in sap_control role - (https://github.com/sap-linuxlab/community.sap_operations/issues/38). \ No newline at end of file diff --git a/docs/.gitkeep b/docs/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/CONTRIBUTORS.md b/docs/CONTRIBUTORS.md deleted file mode 100644 index 5950b9f..0000000 --- a/docs/CONTRIBUTORS.md +++ /dev/null @@ -1,8 +0,0 @@ -# Development contributors - -- **IBM Lab for SAP Solutions** - - IBM Consulting - - **Jason Masipiquena** - Developer of Ansible Collection constructs and Ansible Modules, and project owner - - **Sherard Guico** - Sponsor and technical review - - IBM Cloud - - **Sean Freeman** - Reviewer diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md deleted file mode 100644 index f3cb5a8..0000000 --- a/docs/DEVELOPMENT.md +++ /dev/null @@ -1,110 +0,0 @@ - -# Development of community.sap_operations Ansible Collection - -This Ansible Collection is developed with several design principles and code practices. - -## Code structure - -This Ansible Collection directory tree structure is shown below: -```code -collection/ -├── docs/ -├── meta/ -├── plugins/ -│ └── modules/ -│ ├── sap_facts.sh -│ ├── sap_monitor_hana_status.sh -│ ├── sap_monitor_nw_perf.sh -│ ├── sap_monitor_nw_response.sh -│ └── sap_monitor_nw_status.sh -├── roles/ -│ ├── sap_control -│ │ ├── defaults -│ │ │ └── main.yml -│ │ └── tasks -│ │ ├── functions -│ │ │ ├── cleanipc.yml -│ │ │ ├── restart_sapstartsrv.yml -│ │ │ └── sapstartsrv.yml -│ │ ├── main.yml -│ │ ├── prepare.yml -│ │ └── sapcontrol.yml -│ ├── sap_firewall -│ │ ├── defaults -│ │ │ └── main.yml -│ │ └── tasks -│ │ ├── enable_firewall.yml -│ │ ├── generate_ports_generic.yml -│ │ ├── generate_ports_hana.yml -│ │ ├── generate_ports_nw.yml -│ │ ├── main.yml -│ │ └── update_firewall.yml -│ └── sap_profile_update -│ ├── defaults -│ │ └── main.yml -│ └── tasks -│ ├── main.yml -│ └── update_parameter.yml -├── playbooks/ -│ ├── sample-os-yum-update.yml -│ ├── sample-sap-control-all-restart-nw.yml -│ ├── sample-sap-control-all-restart.yml -│ ├── sample-sap-control-single-restart.yml -│ ├── sample-sap-etchosts-update.yml -│ ├── sample-sap-facts.yml -│ ├── sample-sap-fapolicy-all-update.yml -│ ├── sample-sap-firewall-all-update.yml -│ ├── sample-sap-firewall-update.yml -│ ├── sample-sap-hana-status.yml -│ ├── sample-sap-knownhosts-update.yml -│ ├── sample-sap-nw-perf.yml -│ ├── sample-sap-nw-resp.yml -│ ├── sample-sap-nw-status.yml -│ └── sample-sap-profile-update.yml -├── tests/ -├── galaxy.yml -└── README.md -``` - -## Execution logic - -This Ansible Collection is designed to be heavily re-usable for various scenarios where SAP System operational tasks are performed, and avoid encapsulation of commands within Ansible's syntax; this ensures the scripts (and the sequence of commands) could be re-used manually or re-used by another automation framework. - -It is important to understand the execution flow by an Ansible Playbook to either an Ansible Role (with or without embedded Playbooks), an Ansible Task, or an Ansible Module (and contained Script files). Alternatively it is possible to call the script files manually. - -See examples below: - -### Ansible Playbook to call many Ansible Roles (and the contained interlinked Ansible Tasks) -```code -# Produce outcome scenario, using many interlinked tasks -- Run: Ansible Playbook - - Run: Ansible Role - - Ansible Task - - Ansible Playbook 1..n - - Ansible Task - - execute custom Ansible Module - - execute specified Python Module Functions - - call APIs or CLIs/binaries - - Ansible Task - - Ansible Playbook 1..n - - Ansible Task - - subsequent OS commands using output from APIs or CLIs/binaries -``` - -### Ansible Playbook to call single set of Ansible Tasks -```code -# Produce outcome scenario, with single set of tasks -- Run: Ansible Playbook - - Ansible Task - - execute custom Ansible Module - - execute specified Python Module Functions - - call APIs or CLIs/binaries -``` - -### Python Shell to call single Python Function -```code -# Produce outcome scenario manually with singular code execution -- Run: Python Shell - - Import Python Module file for APIs or CLIs/binaries - - Execute specificed Python Functions -``` diff --git a/docs/EXEC_EXAMPLES.md b/docs/EXEC_EXAMPLES.md deleted file mode 100644 index acf1dd0..0000000 --- a/docs/EXEC_EXAMPLES.md +++ /dev/null @@ -1,128 +0,0 @@ -# Execution examples - -## Sample execution workflows - - - -## Execution example with Ansible Playbook calling Ansible Module - -**Ansible Playbook YAML, execute Ansible Module** -```yaml ---- -- hosts: all - become: true - -# Prompt for Ansible Variables - vars_prompt: - - name: sap_facts_param - prompt: "Choose: all, hana, nw" - private: no - - tasks: - - name: Execute sap_facts Ansible Module to gather SAP System facts for the host - community.sap_operations.sap_facts: - param: "{{ sap_facts_param }}" - register: sap_facts_register - - - debug: - msg: "{{ sap_facts_register.sap_facts }}" - - - debug: - msg: "{{ sap_facts_register.sap_hana_sid }}" - - - debug: - msg: "{{ sap_facts_register.sap_nw_sid }}" -``` - -**Execution of Ansible Playbook, with in-line Ansible Inventory of target/remote hosts** - -```shell -# Install from local source directory for Ansible 2.11+ -ansible-galaxy collection install ./community.sap_operations - -# Workaround install from local source directory for Ansible 2.9.x -# mv ./community.sap_operations ~/.ansible/collections/ansible_collections/community - -# SSH Connection details -target_private_key_file="$PWD/vs_rsa" -target_host="10.0.50.5" -target_user="root" - -# Run Ansible Collection to 1 target/remote host -ansible-playbook --timeout 60 ./community.sap_operations/playbooks/sample-sap-facts.yml \ ---connection 'ssh' --user "$target_user" --inventory "$target_host," --private-key "$target_private_key_file" -``` - - -## Execution example with Ansible Playbook calling Ansible Role - -**Ansible Playbook YAML, execute Ansible Role on target/remote host** -```yaml ---- -- hosts: all - become: true - -# Prompt for Ansible Variables - vars_prompt: - - name: sap_sid - prompt: Please enter target SAP System ID (SID) - private: no - -# Define Ansible Variables - vars: - sap_control_function: "restart_sap_nw" - -# Option 1: Use roles declaration - roles: - - { role: community.sap_operations.sap_control } - -# Option 2: Use sequential parse/execution, by using include_role inside Task block - tasks: - - name: Execute Ansible Role to start/stop SAP Systems - ansible.builtin.include_role: - name: { role: community.sap_operations.sap_control } - -# Option 3: Use task block with import_roles - tasks: - - name: Execute Ansible Role to start/stop SAP Systems - import_roles: - name: { role: community.sap_operations.sap_control } -``` - -**Execution of Ansible Playbook, with in-line Ansible Inventory of target/remote hosts with Proxy/Bastion** - -```shell -# Install from local source directory for Ansible 2.11+ -ansible-galaxy collection install ./community.sap_operations - -# Workaround install from local source directory for Ansible 2.9.x -# mv ./community.sap_operations ~/.ansible/collections/ansible_collections/community - -# SSH Connection details -bastion_private_key_file="$PWD/bastion_rsa" -bastion_host="169.0.40.4" -bastion_port="50222" -bastion_user="bastionuser" - -target_private_key_file="$PWD/vs_rsa" -target_host="10.0.50.5" -target_user="root" - -# Run Ansible Collection to target/remote hosts via Proxy/Bastion -ansible-playbook --timeout 60 ./community.sap_operations/playbooks/sample-sap-control-single-restart.yml \ ---connection 'ssh' --user "$target_user" --inventory "$target_host," --private-key "$target_private_key_file" \ ---ssh-extra-args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand='ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'" -``` - -## Execution example with Bash Shell environment - -**Execute Bash Functions** -```shell -# Change directory to Ansible Module (in Bash) source -cd ./plugins/modules - -# Execute Ansible Module, using Arguments in same way passed from Ansible -echo 'param=all' > vars.sh -bash ./sap_facts.sh 'vars.sh' -rm vars.sh -``` diff --git a/docs/diagrams/workflow_module_sap_facts.svg b/docs/diagrams/workflow_module_sap_facts.svg deleted file mode 100644 index db5a5f9..0000000 --- a/docs/diagrams/workflow_module_sap_facts.svg +++ /dev/null @@ -1,3 +0,0 @@ - - -sap_factssap_factsreturn_jsonreturn_jsonhanahananwnwSIDSIDallallget_all_hana_sidget_all_hana_sidget_all_nw_sidget_all_nw_sidget_sid_typeget_sid_typeget_all_nw_nrget_all_nw_nrget_all_hana_nrget_all_hana_nrget_instance_typeget_instance_typeViewer does not support full SVG 1.1 diff --git a/docs/diagrams/workflow_role_sap_control.svg b/docs/diagrams/workflow_role_sap_control.svg deleted file mode 100644 index 7d82f3a..0000000 --- a/docs/diagrams/workflow_role_sap_control.svg +++ /dev/null @@ -1,3 +0,0 @@ - - -Execute function, loop for each SAP systemExecute function, loop for each SAP systemExecute function for single SAP systemExecute function for single SAP systemrestart_all_saprestart_all_sapstart_all_sapstart_all_sapstop_all_sapstop_all_sapstart_all_hanastart_all_hanastart_all_nwstart_all_nwstop_all_nwstop_all_nwstop_all_hanastop_all_hanarestart_all_hanarestart_all_hanarestart_all_nwrestart_all_nwrestart_sap_nwrestart_sap_nwrestart_sap_hanarestart_sap_hanastart_sap_hanastart_sap_hanastart_sap_nwstart_sap_nwstop_sap_nwstop_sap_nwstop_sap_hanastop_sap_hanaViewer does not support full SVG 1.1 diff --git a/docs/diagrams/workflow_role_sap_firewall.svg b/docs/diagrams/workflow_role_sap_firewall.svg deleted file mode 100644 index aab21af..0000000 --- a/docs/diagrams/workflow_role_sap_firewall.svg +++ /dev/null @@ -1,3 +0,0 @@ - - -sap_firewallsap_firewallgenericgenerichanahananwnwgenerate_portsgenerate_portsupdate_firewallupdate_firewallViewer does not support full SVG 1.1 diff --git a/docs/diagrams/workflow_sample_exec_sap_operations_sample.svg b/docs/diagrams/workflow_sample_exec_sap_operations_sample.svg deleted file mode 100644 index a78eb7b..0000000 --- a/docs/diagrams/workflow_sample_exec_sap_operations_sample.svg +++ /dev/null @@ -1,3 +0,0 @@ - - -Workflow samples within this collectioncommunity.sap_operationsWorkflow samples within this collection...Workflow sample in conjunction with other collectioncommunity.sap_launchpadWorkflow sample in conjunction with other collection...sap_factssap_factssap_profile_updatesap_profile_updatesap_control (restart)sap_control (restart)sap_kernel_updatesap_kernel_updatesap_control (restart)sap_control (restart)sap_software_downloadsap_software_downloadsap_firewallsap_firewallsap_controlsap_controlsap_monitoringsap_monitoringsap_monitor_nw_statussap_monitor_nw_statussap_monitor_nw_perfsap_monitor_nw_perfsap_...sap_...Workflow sample in conjunction with 2 other collectionscommunity.sap_launchpadcommunity.sap_installWorkflow sample in conjunction with 2 other collections...sap_hana_installsap_hana_installsap_firewallsap_firewallos_etchostsos_etchostssap_software_downloadsap_software_downloadsap_general_preconfiguresap_general_preconfiguresap_storagesap_storagesap_rhsmsap_rhsmsap_swpmsap_swpmsap_firewallsap_firewallos_etchostsos_etchostsViewer does not support full SVG 1.1 diff --git a/docs/module_sap_facts.md b/docs/module_sap_facts.md deleted file mode 100644 index 7705790..0000000 --- a/docs/module_sap_facts.md +++ /dev/null @@ -1,45 +0,0 @@ -# sap_facts Ansible Module - -- The equivalent of Ansible's `gather_facts`, but for gathering SAP facts -- Scans the host and populates a dictionary list `sap_facts` containing `SID` `Type` `InstanceNumber` `InstanceType` -- This is the foundation of every modules / roles / tasks not just for this Ansbile collection but for any other collections related to SAP --  -- Full list of outputs: - | **Output** | **Info** | **Return Variable** | - | :--- | :--- | :--- | - | sap_nw_sid | List of all SAP NW SIDs | `.sap_nw_sid` | - | sap_hana_sid | List of all SAP HANA SIDs | `.sap_hana_sid` | - | sap_nw_nr | List of all SAP NW instance numbers | `.sap_nw_nr` | - | sap_hana_nr | List of all SAP HANA instance numbers | `.sap_hana_nr` | - | **sap_facts** | Dictionary list of all the details | `.sap_facts` | - -- Sample `sap_facts` dictionary list generated: - - ```yaml - [ - { - "InstanceNumber": "00", - "InstanceType": "HANA", - "SID": "H20", - "Type": "hana" - }, - { - "InstanceNumber": "02", - "InstanceType": "ASCS", - "SID": "S4H", - "Type": "nw" - }, - { - "InstanceNumber": "01", - "InstanceType": "PAS", - "SID": "S4H", - "Type": "nw" - }, - { - "InstanceNumber": "03", - "InstanceType": "WebDisp", - "SID": "WD1", - "Type": "nw" - } - ] - ``` diff --git a/docs/module_sap_monitor.md b/docs/module_sap_monitor.md deleted file mode 100644 index 478bb68..0000000 --- a/docs/module_sap_monitor.md +++ /dev/null @@ -1,133 +0,0 @@ -# sap_monitor Ansible Module - -Ansible modules for SAP healthcheck / monitoring - -- Modules for SAP healthcheck / monitoring -- Please check the documentaion here [SAP Check Documentation](/docs/sap_monitor) -- For technical details, please check the individual `.sh` files here [SAP Check](/plugins/modules) - - -- **sap_monitor_hana_status** - - Checks the status of SAP HANA system - - Returns 'GREEN' 'YELLOW' 'RED' 'GRAY' as returned by `sapcontrol` - - Full list of outputs: - | **Output** | **Info** | **Return Variable** | - | :--- | :--- | :--- | - | sap_status | 'GREEN' 'YELLOW' 'RED' 'GRAY' as returned by `sapcontrol` | `.sap_status` | - - Sample output: - ```yaml - "changed": false, - "sap_status": "GREEN", - "failed": false, - "item": { - "InstanceNumber": "90", - "InstanceType": "HANA", - "SID": "HDX", - "Type": "hana" - }, - "msg": "SAP Check Successful" - ``` - -- **sap_monitor_nw_status** - - Checks the status of SAP Netweaver system - - Returns 'GREEN' 'YELLOW' 'RED' 'GRAY' as returned by `sapcontrol` - - Full list of outputs: - | **Output** | **Info** | **Return Variable** | - | :--- | :--- | :--- | - | sap_status | 'GREEN' 'YELLOW' 'RED' 'GRAY' as returned by `sapcontrol` | `.sap_status` | - - Sample output: - ```yaml - { - "ansible_loop_var": "item", - "changed": false, - "sap_status": "GREEN", - "failed": false, - "item": { - "InstanceNumber": "92", - "InstanceType": "ASCS", - "SID": "S4X", - "Type": "nw" - }, - "msg": "SAP Check Successful" - }, - { - "ansible_loop_var": "item", - "changed": false, - "sap_status": "GREEN", - "failed": false, - "item": { - "InstanceNumber": "91", - "InstanceType": "PAS", - "SID": "S4X", - "Type": "nw" - }, - "msg": "SAP Check Successful" - } - ``` - - -- **sap_monitor_nw_perf** - - Checks performance metrics of an SAP Netweaver ABAP system - - > **_Note:_** The current checklist only contains 4 items at this early stage of development but can be easily improved later - - Current scope: - - Heap Memory - - Extended Memory - - CPU Utilization - - Program Buffer Swap - - (more can be added) - - Full list of outputs: - | **Output** | **Info** | **Return Variable** | - | :--- | :--- | :--- | - | heap_memory | Heap memory | `.heap_memory` | - | extended_memory | Extended memory | `.extended_memory` | - | cpu_util | CPU utilization | `.cpu_util` | - | program_swap | Program buffer swap | `.program_swap` | - - Sample output: - ```yaml - "changed": false, - "cpu_util": "7", - "extended_memory": "19", - "failed": false, - "heap_memory": "0", - "item": { - "InstanceNumber": "91", - "InstanceType": "PAS", - "SID": "S4X", - "Type": "nw" - }, - "msg": "SAP Check Successful", - "program_swap": "0.0 - ``` - -- **sap_monitor_nw_response** - - Checks response times of an SAP Netweaver ABAP system - - > **_Note:_** The current checklist only contains 4 items at this early stage of development but can be easily improved later - - Current scope: - - Dialog Response Time - - Database Response Time - - Front End Response Time - - Program Buffer Swap - - (more can be added) - - Full list of outputs: - | **Output** | **Info** | **Return Variable** | - | :--- | :--- | :--- | - | dialog_response_time | Dialog response time | `.dialog_response_time` | - | database_response_time | Database respone time | `.database_response_time` | - | frontend_response_time | Front end response time | `.frontend_response_time` | - | number_users | Current number of logged in users | `.number_users` | - - Sample output: - ```yaml - "changed": false, - "database_response_time": "177", - "dialog_response_time": "542", - "failed": false, - "frontend_response_time": "211", - "item": { - "InstanceNumber": "91", - "InstanceType": "PAS", - "SID": "S4X", - "Type": "nw" - }, - "msg": "SAP Check Successful", - "number_users": "19" - ``` diff --git a/galaxy.yml b/galaxy.yml index 0030432..cfe5328 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -10,7 +10,7 @@ namespace: community name: sap_operations # The version of the collection. Must be compatible with semantic versioning -version: 0.9.1 +version: 2.0.0 # The path to the Markdown (.md) readme file. This path is relative to the root of the collection readme: README.md @@ -20,30 +20,35 @@ authors: - IBM Lab for SAP Solutions - IBM Cloud for SAP - IBM Consulting for SAP + - Sean Freeman + - Rainer Leber + - Marcel Mamula ### OPTIONAL but strongly recommended # A short summary description of the collection -description: Collection of Ansible Modules and Ansible Roles for SAP system operations +description: Collection of Ansible Roles and Modules for SAP system operations # Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only # accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file' -license: - - Apache-2.0 +# license: +# - Apache-2.0 # The path to the license file for the collection. This path is relative to the root of the collection. This key is # mutually exclusive with 'license' -license_file: '' +license_file: 'LICENSE' # A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character # requirements as 'namespace' and 'name' -tags: [] +tags: + - database + - application + - sap # Collections that this collection requires to be installed for it to be usable. The key of the dict is the # collection label 'namespace.name'. The value is a version range # L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version # range specifiers can be set and are separated by ',' -dependencies: - community.sap_libs: '*' +dependencies: {} # The URL of the originating SCM repository repository: https://github.com/sap-linuxlab/community.sap_operations diff --git a/meta/.gitkeep b/meta/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/meta/runtime.yml b/meta/runtime.yml index 2ee3c9f..5904776 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,2 +1,2 @@ --- -requires_ansible: '>=2.9.10' +requires_ansible: '>=2.16.0' diff --git a/playbooks/sample-os-yum-update.yml b/playbooks/sample-os-yum-update.yml deleted file mode 100644 index 84fb51d..0000000 --- a/playbooks/sample-os-yum-update.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Ansible playbook for yum update ---- - -- name: Yum Update All - hosts: all - become: true - - tasks: - - - name: Yum Update All - block: - - - name: Subscription Manager - Lock Release - command: 'subscription-manager release --set={{ ansible_distribution_version }}' - - - name: Yum update all - command: 'yum --assumeyes update' - - when: ansible_facts['distribution'] == 'RedHat' diff --git a/playbooks/sample-sap-control-all-restart-nw.yml b/playbooks/sample-sap-control-all-restart-nw.yml deleted file mode 100644 index 0a2113a..0000000 --- a/playbooks/sample-sap-control-all-restart-nw.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- hosts: all - become: true - vars: - sap_control_function: "restart_all_nw" - roles: - - { role: community.sap_operations.sap_control } diff --git a/playbooks/sample-sap-control-all-restart.yml b/playbooks/sample-sap-control-all-restart.yml deleted file mode 100644 index 9bb8599..0000000 --- a/playbooks/sample-sap-control-all-restart.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- hosts: all - become: true - vars: - sap_control_function: "restart_all_sap" - roles: - - { role: community.sap_operations.sap_control } diff --git a/playbooks/sample-sap-control-single-restart.yml b/playbooks/sample-sap-control-single-restart.yml deleted file mode 100644 index ab0d5b4..0000000 --- a/playbooks/sample-sap-control-single-restart.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- hosts: all - become: true - -# Prompt for Ansible Variables - vars_prompt: - - name: sap_sid - prompt: Please enter target SAP System ID (SID) - private: no - - vars: - sap_control_function: "restart_sap_nw" - roles: - - { role: community.sap_operations.sap_control } diff --git a/playbooks/sample-sap-etchosts-update.yml b/playbooks/sample-sap-etchosts-update.yml deleted file mode 100644 index 44bf6e9..0000000 --- a/playbooks/sample-sap-etchosts-update.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- hosts: all - become: true - vars: - sap_os_tools_etchosts_entries: - - "10.0.20.4 hana01-lb" - - "10.0.20.5 hana02-lb" - - "10.0.40.8 s4hana01-ascs-pas" - - "10.0.40.9 s4hana01-aas" - sap_os_tools_etchosts_fqdn: "example.com" - roles: - - { role: community.sap_operations.os_etchosts } diff --git a/playbooks/sample-sap-facts.yml b/playbooks/sample-sap-facts.yml deleted file mode 100644 index e219506..0000000 --- a/playbooks/sample-sap-facts.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- hosts: all - become: true - -# Prompt for Ansible Variables - vars_prompt: - - name: sap_facts_param - prompt: "Choose: all, hana, nw" - private: no - - tasks: - - name: Execute sap_facts Ansible Module to gather SAP System facts for the host - community.sap_operations.sap_facts: - param: "{{ sap_facts_param }}" - register: sap_facts_register - - - debug: - msg: "{{ sap_facts_register.sap_facts }}" - - - debug: - msg: "{{ sap_facts_register.sap_hana_sid }}" - - - debug: - msg: "{{ sap_facts_register.sap_nw_sid }}" diff --git a/playbooks/sample-sap-fapolicy-all-update.yml b/playbooks/sample-sap-fapolicy-all-update.yml deleted file mode 100644 index f94666d..0000000 --- a/playbooks/sample-sap-fapolicy-all-update.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -- hosts: all - become: true - - vars: - sap_fapolicy_user_generic_list: - - "root" - - "sapadm" - - "uuidd" - - tasks: - - # Update fapolicy for generic users - - name: Fapolicy Update - generic - vars: - sap_fapolicy_type: "generic" - ansible.builtin.include_role: - name: community.sap_operations.sap_fapolicy - loop: "{{ sap_fapolicy_user_generic_list }}" - loop_control: - loop_var: sap_fapolicy_user - - - name: Run sap_facts module to gather SAP facts - community.sap_operations.sap_facts: - param: "all" - register: sap_facts_register - - # Update fapolicy for SAP users - - name: Fapolicy Update - SAP Users - vars: - sap_fapolicy_sid: "{{ item.Type }}" - sap_fapolicy_type: "{{ item.Type }}" - ansible.builtin.include_role: - name: community.sap_operations.sap_fapolicy - loop: "{{ sap_facts_register.sap_facts }}" diff --git a/playbooks/sample-sap-firewall-all-update.yml b/playbooks/sample-sap-firewall-all-update.yml deleted file mode 100644 index efecca8..0000000 --- a/playbooks/sample-sap-firewall-all-update.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- hosts: all - become: true - - tasks: - - - name: Run sap_facts module to gather SAP facts - community.sap_operations.sap_facts: - param: "all" - register: sap_facts_register - - - name: Firewall Update - vars: - sap_firewall_type: "{{ item.Type }}" - sap_firewall_instance_nr: "{{ item.InstanceNumber }}" - ansible.builtin.include_role: - name: community.sap_operations.sap_firewall - loop: "{{ sap_facts_register.sap_facts }}" diff --git a/playbooks/sample-sap-firewall-update.yml b/playbooks/sample-sap-firewall-update.yml deleted file mode 100644 index a7f4e70..0000000 --- a/playbooks/sample-sap-firewall-update.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -- hosts: all - become: true - vars: - sap_firewall_ports: - - "1128" - - "1129" - sap_firewall_type: "generic" - roles: - - { role: community.sap_operations.sap_firewall } diff --git a/playbooks/sample-sap-hana-backint-clean.yml b/playbooks/sample-sap-hana-backint-clean.yml deleted file mode 100644 index 41c6919..0000000 --- a/playbooks/sample-sap-hana-backint-clean.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- hosts: all - become: true - vars: - backup_function: 'clean' - sap_hana_sid: 'H01' - target_platform: 'ibm_cos_s3' - roles: - - { role: ../roles/sap_hana_backint } diff --git a/playbooks/sample-sap-hana-backint-execute.yml b/playbooks/sample-sap-hana-backint-execute.yml deleted file mode 100644 index bd0d1bd..0000000 --- a/playbooks/sample-sap-hana-backint-execute.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- hosts: all - become: true - vars: - backup_function: 'execute' - sap_hana_sid: 'H01' - target_platform: 'ibm_cos_s3' - roles: - - { role: ../roles/sap_hana_backint } diff --git a/playbooks/sample-sap-hana-backint-setup.yml b/playbooks/sample-sap-hana-backint-setup.yml deleted file mode 100644 index fb05d74..0000000 --- a/playbooks/sample-sap-hana-backint-setup.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- hosts: all - become: true - vars: - backup_function: 'setup' - sap_hana_sid: 'H01' - target_platform: 'ibm_cos_s3' - roles: - - { role: ../roles/sap_hana_backint } diff --git a/playbooks/sample-sap-hana-status.yml b/playbooks/sample-sap-hana-status.yml deleted file mode 100644 index 5fa292c..0000000 --- a/playbooks/sample-sap-hana-status.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- hosts: all - become: true - - tasks: - - - name: Run sap_facts module to gather SAP facts - community.sap_operations.sap_facts: - param: "hana" - register: sap_facts_register - - - name: Run sap_monitor_hana_status module - community.sap_operations.sap_monitor_hana_status: - hana_sid: "{{ item.SID }}" - hana_instance_number: "{{ item.InstanceNumber }}" - register: sap_monitor_hana_status_register - loop: "{{ sap_facts_register.sap_facts }}" - - - debug: - msg: - - "{{ sap_monitor_hana_status_register }}" diff --git a/playbooks/sample-sap-knownhosts-update.yml b/playbooks/sample-sap-knownhosts-update.yml deleted file mode 100644 index da38a0f..0000000 --- a/playbooks/sample-sap-knownhosts-update.yml +++ /dev/null @@ -1,12 +0,0 @@ -# Ansible playbook to update known hosts file - $HOME/.ssh/known_hosts ---- - -- name: Store known hosts of 'all' the hosts in the inventory file - hosts: localhost - connection: local - - vars: - ssh_known_hosts: "{{ groups['all'] }}" - - roles: - - { role: community.sap_operations.os_knownhosts } diff --git a/playbooks/sample-sap-nw-perf.yml b/playbooks/sample-sap-nw-perf.yml deleted file mode 100644 index 3d561fc..0000000 --- a/playbooks/sample-sap-nw-perf.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- hosts: all - become: true - - tasks: - - - name: Run sap_facts module to gather SAP facts - community.sap_operations.sap_facts: - param: "nw" - register: sap_facts_register - - - name: Run sap_monitor_nw_perf module - community.sap_operations.sap_monitor_nw_perf: - nw_sid: "{{ item.SID }}" - nw_instance_number: "{{ item.InstanceNumber }}" - nw_instance_type: "{{ item.InstanceType }}" - register: sap_monitor_nw_status_register - loop: "{{ sap_facts_register.sap_facts }}" - when: - - "'PAS' in item.InstanceType" - - - debug: - msg: - - "{{ sap_monitor_nw_status_register }}" diff --git a/playbooks/sample-sap-nw-resp.yml b/playbooks/sample-sap-nw-resp.yml deleted file mode 100644 index 71ea07b..0000000 --- a/playbooks/sample-sap-nw-resp.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- hosts: all - become: true - - tasks: - - - name: Run sap_facts module to gather SAP facts - community.sap_operations.sap_facts: - param: "nw" - register: sap_facts_register - - - name: Run sap_monitor_nw_response module - community.sap_operations.sap_monitor_nw_response: - nw_sid: "{{ item.SID }}" - nw_instance_number: "{{ item.InstanceNumber }}" - nw_instance_type: "{{ item.InstanceType }}" - register: sap_monitor_nw_status_register - loop: "{{ sap_facts_register.sap_facts }}" - when: - - "'PAS' in item.InstanceType" - - - debug: - msg: - - "{{ sap_monitor_nw_status_register }}" diff --git a/playbooks/sample-sap-nw-status.yml b/playbooks/sample-sap-nw-status.yml deleted file mode 100644 index d549fab..0000000 --- a/playbooks/sample-sap-nw-status.yml +++ /dev/null @@ -1,22 +0,0 @@ ---- -- hosts: all - become: true - - tasks: - - - name: Run sap_facts module to gather SAP facts - community.sap_operations.sap_facts: - param: "nw" - register: sap_facts_register - - - name: Run sap_monitor_nw_status module - community.sap_operations.sap_monitor_nw_status: - nw_sid: "{{ item.SID }}" - nw_instance_number: "{{ item.InstanceNumber }}" - nw_instance_type: "{{ item.InstanceType }}" - register: sap_monitor_nw_status_register - loop: "{{ sap_facts_register.sap_facts }}" - - - debug: - msg: - - "{{ sap_monitor_nw_status_register }}" diff --git a/playbooks/sample-sap-profile-update.yml b/playbooks/sample-sap-profile-update.yml deleted file mode 100644 index c314535..0000000 --- a/playbooks/sample-sap-profile-update.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -- hosts: all - become: true - -# Prompt for Ansible Variables - vars_prompt: - - name: sap_sid - prompt: Please enter target SAP System ID (SID) - private: no - - vars: - sap_update_profile_default_profile_params: - - sapgui/user_scripting = TRUE - - ssl/ciphersuites = 135:PFS:HIGH::EC_P256:EC_HIGH - - ssl/client_ciphersuites = 150:PFS:HIGH::EC_P256:EC_HIGH - sap_update_profile_instance_profile_params: - - PHYS_MEMSIZE = 32768 - - icm/server_port_0 = PROT=HTTP,PORT=80$$,PROCTIMEOUT=600,TIMEOUT=3600 - - icm/server_port_1 = PROT=HTTPS,PORT=443$$,PROCTIMEOUT=600,TIMEOUT=3600 - - icm/server_port_2 = PROT=SMTP,PORT=25$$,PROCTIMEOUT=120,TIMEOUT=120 - - - tasks: - - - name: Run sap_facts module to gather SAP facts - community.sap_operations.sap_facts: - param: "{{ sap_sid }}" - register: sap_facts_register - - # SAP Profile Update - - name: SAP Profile Update - vars: - sap_update_profile_sid: "{{ item.SID }}" - sap_update_profile_instance_nr: "{{ item.InstanceNumber }}" - ansible.builtin.include_role: - name: community.sap_operations.sap_profile_update - loop: "{{ sap_facts_register.sap_facts }}" diff --git a/playbooks/sample-sap-rfc.yml b/playbooks/sample-sap-rfc.yml deleted file mode 100644 index 45721ba..0000000 --- a/playbooks/sample-sap-rfc.yml +++ /dev/null @@ -1,55 +0,0 @@ ---- -- hosts: all - become: true - - vars: - suser_id: 'S00000000' - suser_password: 'password' - sap_nwrfc_sdk: nwrfc750P_10-70002752.zip - reuse_connection: - ashost: s4hana.poc.cloud - sysid: TDT - sysnr: "01" - client: "400" - user: DDIC - passwd: Password1 - lang: EN -# trace: 3 -# saprouter: /H/111.22.33.44/S/3299/W/e5ngxs/H/555.66.777.888/H/ -# gwhost: gateway.poc.cloud -# ghserv: gateway.poc.cloud - - tasks: - - - name: Run SAP RFC - STFC_CONNECTION - vars: - pyrfc_first_run: yes - target_function: STFC_CONNECTION - target_parameters: - REQUTEXT: 'Hello SAP!' - target_connection: "{{ reuse_connection }}" - ansible.builtin.include_role: - name: community.sap_operations.sap_rfc - register: sap_rfc_output1 - - - name: DEBUG - Output of STFC_CONNECTION - debug: - msg: "{{ sap_rfc_output1 }}" - - - name: Run SAP RFC - STFC_STRUCTURE - vars: - pyrfc_first_run: no - target_function: STFC_STRUCTURE - target_parameters: - IMPORTSTRUCT: - RFCINT1: 128 - RFCTABLE: - - COLUMN0: test - target_connection: "{{ reuse_connection }}" - ansible.builtin.include_role: - name: community.sap_operations.sap_rfc - register: sap_rfc_output2 - - - name: DEBUG - Output of STFC_STRUCTURE - debug: - msg: "{{ sap_rfc_output2 }}" diff --git a/plugins/.gitkeep b/plugins/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/inventory/.gitkeep b/plugins/inventory/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/module_utils/.gitkeep b/plugins/module_utils/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/modules/.gitkeep b/plugins/modules/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/modules/README.md b/plugins/modules/README.md deleted file mode 100644 index 46104bf..0000000 --- a/plugins/modules/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Ansible Modules documentation - -Each Ansible Module has documentation underneath `/docs`. diff --git a/plugins/modules/sap_facts.sh b/plugins/modules/sap_facts.sh deleted file mode 100755 index c302097..0000000 --- a/plugins/modules/sap_facts.sh +++ /dev/null @@ -1,527 +0,0 @@ -#!/bin/bash -# ===================================================================== -# -# sap_facts.sh -# Authored by - Jason Masipiquena -# - IBM - Lab for SAP Solutions -# -# Bash script designed to be used as an Ansible module -# Gathers SAP facts in a host -# - SAP HANA -# - SIDs -# - Instance Numbers (one per SID) -# - SAP NW -# - SIDs -# - Instance Numbers (can be more than one per SID) -# - Instance Types (ASCS, PAS, ERS, etc) -# Input: -# - param (all | nw | hana | ) -# - restart_sapstartsrv (true | false) - default false -# Output: -# - sap_nw_sid - list of all SAP NW SIDs - access from Ansible via .sap_nw_sid -# - sap_hana_sid - list of all SAP HANA SIDs - access from Ansible via .sap_hana_sid -# - sap_nw_nr - list of all SAP NW instance numbers - access from Ansible via .sap_nw_nr -# - sap_hana_nr - list of all SAP HANA instance numbers - access from Ansible via .sap_hana_nr -# - sap_facts - dictionary list of all the details - access from Ansible via .sap_facts -# -# ===================================================================== - -# ===================================================================== -# Functions -# ===================================================================== -# get_all_hana_sid -# get_all_nw_sid -# get_sid_type -# get_all_nw_nr -# get_hana_nr -# get_all_hana_nr -# get_instance_type -# check_sapstartsrv -# start_sapstartsrv -# check_sapcontrol -# array_to_json -# arrays_to_dictionary -# process_final_results -# return_ansible - -# Loops through /hana/shared for all SIDs and exports results to global array HANA_SID_ARRAY -function get_all_hana_sid(){ - - unset HANA_SID_ARRAY - export HANA_SID_ARRAY - - if [ -d /hana/shared ]; then - # /hana/shared directory exists - while read LINE - do - ### Check to see if /usr/sap/SID exists. If not then its probably not used anymore / its not a SID so ignore - if [ -d /usr/sap/$LINE ]; then - # $LINE is an HDB system - HANA_SID_ARRAY+=( "$LINE" ) - else - # $LINE not in /usr/sap - : - fi - done < <(ls -1 /hana/shared) - ## process substitution otherwise the variable values wont appear outside loop - else - # /hana/shared directory doesnt exist - unset HANA_SID_ARRAY - fi - - # Check if HANA SID detected - if [[ -z "${HANA_SID_ARRAY[@]}" ]]; then - # HANA_SID_ARRAY is empty, no HANA SID found - RETURN_MESSAGE="${RETURN_MESSAGE} - ""HANA SID not found" - else - # Proceed with getting instance numbers - RETURN_MESSAGE="${RETURN_MESSAGE} - ""HANA SID found" - get_all_hana_nr - fi -} - -# Loops through /sapmnt for all SIDs and exports results to global array NW_SID_ARRAY -function get_all_nw_sid(){ - - unset NW_SID_ARRAY - export NW_SID_ARRAY - - if [ -d /sapmnt ]; then - # /sapmnt directory exists - while read LINE - do - ### Check to see if /usr/sap/SID exists. If not then its probably not used anymore / its not a SID so ignore - if [ -d /usr/sap/$LINE ]; then - # "$LINE is a SAP system" - NW_SID_ARRAY+=( "$LINE" ) - else - ### Check to see if /sapmnt/SID/sap_bobj exists to see if its a bobj system - if [ -d /sapmnt/$LINE/sap_bobj ]; then - # $LINE is a bobj system - NW_SID_ARRAY+=( "$LINE" ) - else - # $LINE not a SID" - : - fi - fi - done < <(ls -1 /sapmnt) - ## process substitution otherwise the variable values wont appear outside loop - else - # /sapmnt directory doesnt exist - unset NW_SID_ARRAY - fi - - if [[ -z "${NW_SID_ARRAY[@]}" ]]; then - # NW_SID_ARRAY is empty, no NW SID found - RETURN_MESSAGE="${RETURN_MESSAGE} - ""NW SID not found" - else - # Proceed with getting instance numbers - RETURN_MESSAGE="${RETURN_MESSAGE} - ""NW SID found" - get_all_nw_nr - fi -} - -# Check SID if it's NW or HANA -function get_sid_type() { - local PARAM=$1 - - ### Check to see if /usr/sap/SID exists. If not then its probably not used anymore / its not a SID so ignore - if [ -d /hana/shared/$PARAM ]; then - # $SID is an HDB system - HANA_SID_ARRAY+=( "$PARAM" ) - RETURN_MESSAGE="- SID: $PARAM found - hana" - get_all_hana_nr - elif [ -d /sapmnt/$PARAM ]; then - NW_SID_ARRAY+=( "$PARAM" ) - RETURN_MESSAGE="- SID: $PARAM found - nw" - get_all_nw_nr - else - RETURN_MESSAGE="- SID: $PARAM not found" - return_ansible failed - fi - -} - -# Loops through NW_SID_ARRAY populated by function get_all_nw_sid and get NW instance numbers -function get_all_nw_nr(){ - - unset NW_NR_ARRAY - export NW_NR_ARRAY - - for i in "${NW_SID_ARRAY[@]}" - do - SID=$(echo $i) - SIDADM=${SID,,}adm - - while read LINE - do - - ## Get the first character and the last two characters - LASTTWO=$(echo ${LINE: -2}) - FIRST=$(echo ${LINE:0:1}) - - if [[ $LASTTWO =~ ^[0-9]+$ ]];then - NR=$LASTTWO - check_sapstartsrv $SIDADM $SID $NR - sapcontrol_test=`check_sapcontrol $SIDADM $SID $NR` - if [[ $sapcontrol_test == "fail" ]]; then - # sapcontrol not working - # invalid SAP system - # ignore this instance number - : - else - # sapcontrol is working - # valid SAP system - # add this instance number in NW_NR_ARRAY - NW_NR_ARRAY+=( "$LASTTWO" ) - fi - else - : - fi - done < <(ls -1 /usr/sap/$SID) - done - -} - -# Returns instance number of SAP HANA -function get_hana_nr(){ - # $1 - SID - local NR=$(ls -1 /usr/sap/$1 | grep HDB | sed 's/...//' | head -1) - HANA_NR_ARRAY+=( "$NR" ) -} - - -# Loops through HANA_SID_ARRAY populated by function get_all_hana_sid and get HANA instance numbers -function get_all_hana_nr(){ - - unset HANA_NR_ARRAY - export HANA_NR_ARRAY - - for i in "${HANA_SID_ARRAY[@]}" - do - local SID=$(echo $i) - local SIDADM=${SID,,}adm - local NR=$(ls -1 /usr/sap/$SID | grep HDB | sed 's/...//' | head -1) - - check_sapstartsrv $SIDADM $SID $NR - sapcontrol_test=`check_sapcontrol $SIDADM $SID $NR` - if [[ $sapcontrol_test == "fail" ]]; then - # sapcontrol not working - # invalid SAP system - # ignore this instance number - : - else - # sapcontrol is working - # valid SAP system - # add this instance number in HANA_NR_ARRAY - HANA_NR_ARRAY+=( "$NR" ) - fi - done -} - -# remove_failed_sids() { - -# for target in "${NW_SID_ARRAY_DELETE[@]}"; do -# for i in "${!NW_SID_ARRAY[@]}"; do -# if [[ ${NW_SID_ARRAY[i]} = $target ]]; then -# unset 'NW_SID_ARRAY[i]' -# fi -# done -# done - -# for target in "${HANA_SID_ARRAY_DELETE[@]}"; do -# for i in "${!HANA_SID_ARRAY[@]}"; do -# if [[ ${HANA_SID_ARRAY[i]} = $target ]]; then -# unset 'HANA_SID_ARRAY[i]' -# fi -# done -# done - -# echo ${HANA_SID_ARRAY[@]} -# echo ${HANA_SID_ARRAY[@]} - -# } - -# Returns instance type of passed instance number -get_instance_type() { - - local INS=$1 - local FIRST=$(echo ${INS:0:1}) - local NR="" - local INS_TYPE="" - - if [[ $FIRST = "D" ]]; then - # It's a PAS - INS_TYPE="PAS" - elif [[ $FIRST = "A" ]]; then - # It's an ASCS - INS_TYPE="ASCS" - elif [[ $FIRST = "W" ]]; then - # It's a Webdisp - INS_TYPE="WebDisp" - elif [[ $FIRST = "J" ]]; then - # It's a Java - INS_TYPE="Java" - elif [[ $FIRST = "S" ]]; then - # It's an SCS - INS_TYPE="SCS" - elif [[ $FIRST = "E" ]]; then - # It's an ERS - INS_TYPE="ERS" - elif [[ $FIRST = "H" ]]; then - # It's a HANA system - INS_TYPE="HANA" - else - # Unknown instance type - INS_TYPE="XXX" - fi - - echo $INS_TYPE - -} - -# Check if sapstartsrv is running -function check_sapstartsrv(){ - # $1 - SIDADM - # $2 - SID - # $3 - NR - - ## Count the number of sapstartsrv processes - SAPSTARTSRV=$(ps -eo exe | grep $2 | grep $3 | grep sapstartsrv | wc -l) - - if [[ $SAPSTARTSRV = 0 ]]; then - ## No sapstartsrv process running - attempt to start - if [[ "${restart_sapstartsrv,,}" == "true" ]]; then - start_sapstartsrv $1 $2 $3 - fi - elif [[ $SAPSTARTSRV -gt 1 ]]; then - if [[ "${restart_sapstartsrv,,}" == "true" ]]; then - # Multiple sapstartsrv processes running for a given instance number - # Stop all corresponding sapstartsrv processes - for i in $SAPSTARTSRV - do - su - $1 -c "sapcontrol -nr $3 -function StopService $2" - done - # Start sapstartsrv - start_sapstartsrv $1 $2 $3 - fi - else - # sapstartsrv is ok - : - fi -} - -# Start sapstartsrv for given SID and NR -function start_sapstartsrv(){ - # $1 - SIDADM - # $2 - SID - # $3 - NR - su - $1 -c "sapcontrol -nr $3 -function StartService $2" -} - -# Check sapcontrol on an instance number -function check_sapcontrol(){ - # $1 - SIDADM - # $2 - SID - # $3 - NR - local sapcontrol_test=`su - $1 -c "sapcontrol -nr $3 -function GetInstanceProperties"` - if [[ $sapcontrol_test == *"FAIL"* ]]; then - # sapcontrol not working - echo "fail" - else - # sapcontrol is working - echo "ok" - fi - -} - -# Convert array to json format -function array_to_json() { - echo -n '[' - while [ $# -gt 0 ]; do - x=${1//\\/\\\\} - echo -n \"${x//\"/\\\"}\" - [ $# -gt 1 ] && echo -n ', ' - shift - done - echo ']' -} - -# Convert all arrays to json dictionary format -function arrays_to_dictionary() { - i=0 - echo -n '[' - - while [ $# -gt 0 ]; do - - echo -n '{' - - x=${1//\\/\\\\} - echo -n \"InstanceNumber\": \"${x//\"/\\\"}\" - echo -n ', ' - echo -n \"InstanceType\": \"${DICT_ALL_INS_TYPE_ARRAY[i]//\"/\\\"}\" - echo -n ', ' - echo -n \"SID\": \"${DICT_ALL_SID_ARRAY[i]//\"/\\\"}\" - echo -n ', ' - echo -n \"Type\": \"${DICT_ALL_TYPE_ARRAY[i]//\"/\\\"}\" - echo -n '}' - - [ $# -gt 1 ] && echo -n ', ' - - shift - - i=$((i+1)) - done - - echo ']' - -} - -# Process results for Ansible -function process_final_results(){ - - # Declare dictionary variables - unset DICT_ALL_NR_ARRAY - unset DICT_ALL_TYPE_ARRAY - unset DICT_ALL_INS_TYPE_ARRAY - unset DICT_ALL_SID_ARRAY - unset DICT_ALL_NW_SID_ARRAY - unset DICT_ALL_HANA_SID_ARRAY - export DICT_ALL_NR_ARRAY - export DICT_ALL_TYPE_ARRAY - export DICT_ALL_INS_TYPE_ARRAY - export DICT_ALL_SID_ARRAY - export DICT_ALL_NW_SID_ARRAY - export DICT_ALL_HANA_SID_ARRAY - - # Check NW and HANA arrays if empty - if [[ -z "${HANA_NR_ARRAY[@]}" ]]; then - RETURN_MESSAGE="${RETURN_MESSAGE} - ""No valid HANA Systems found" - else - : - fi - - if [[ -z "${NW_NR_ARRAY[@]}" ]]; then - RETURN_MESSAGE="${RETURN_MESSAGE} - ""No valid NW Systems found" - else - : - fi - - if [[ -z "${NW_NR_ARRAY[@]}" ]] && [[ -z "${HANA_NR_ARRAY[@]}" ]]; then - RETURN_MESSAGE="${RETURN_MESSAGE} - ""No valid Systems found" - else - : - fi - - # Append all NW NR to final NR dictionary array - for index in "${!NW_NR_ARRAY[@]}" - do - DICT_ALL_NR_ARRAY+=( "${NW_NR_ARRAY[index]}" ) - DICT_ALL_TYPE_ARRAY+=( "nw" ) - done - - # Append all HANA NR to final NR dictionary array - for index in "${!HANA_NR_ARRAY[@]}" - do - DICT_ALL_NR_ARRAY+=( "${HANA_NR_ARRAY[index]}" ) - DICT_ALL_TYPE_ARRAY+=( "hana" ) - done - - # Get instance information of all instance numbers - for index in "${!DICT_ALL_NR_ARRAY[@]}" - do - - local NR=$(echo ${DICT_ALL_NR_ARRAY[index]}) - local SID=$(/usr/sap/hostctrl/exe/sapcontrol -nr $NR -function GetInstanceProperties | grep SAPSYSTEMNAME | awk '{ print $3 }') - local INS=$(/usr/sap/hostctrl/exe/sapcontrol -nr $NR -function GetInstanceProperties | grep INSTANCE_NAME | awk '{ print $3 }') - - # Get instance type - local INS_TYPE=`get_instance_type $INS` - - DICT_ALL_INS_TYPE_ARRAY+=( "${INS_TYPE}" ) - - if [[ ${INS_TYPE} == "HANA" ]]; then - # Append all HANA SID - DICT_ALL_HANA_SID_ARRAY+=( "${SID}" ) - else - # Append all NW SID - DICT_ALL_NW_SID_ARRAY+=( "${SID}" ) - fi - - # Append all SID - DICT_ALL_SID_ARRAY+=( "${SID}" ) - - done - - # Trim SID Arrays to get only unique SIDs - IFS=" " read -r -a DICT_ALL_NW_SID_ARRAY <<< "$(tr ' ' '\n' <<< "${DICT_ALL_NW_SID_ARRAY[@]}" | sort -u | tr '\n' ' ')" - IFS=" " read -r -a DICT_ALL_HANA_SID_ARRAY <<< "$(tr ' ' '\n' <<< "${DICT_ALL_HANA_SID_ARRAY[@]}" | sort -u | tr '\n' ' ')" - - # Process lists for all SIDs - DICT_ALL_NW_SID_JSON=`array_to_json "${DICT_ALL_NW_SID_ARRAY[@]}"` - DICT_ALL_HANA_SID_JSON=`array_to_json "${DICT_ALL_HANA_SID_ARRAY[@]}"` - - # Process lists for all NRs - DICT_ALL_NW_NR_JSON=`array_to_json "${NW_NR_ARRAY[@]}"` - DICT_ALL_HANA_NR_JSON=`array_to_json "${HANA_NR_ARRAY[@]}"` - - # Process dictionaries for sap_facts - DICT_ALL_NR_JSON=`array_to_json "${DICT_ALL_NR_ARRAY[@]}"` - DICT_ALL_SID_JSON=`array_to_json "${DICT_ALL_SID_ARRAY[@]}"` - DICT_ALL_INS_TYPE_JSON=`array_to_json "${DICT_ALL_INS_TYPE_ARRAY[@]}"` - DICT_ALL_TYPE_JSON=`array_to_json "${DICT_ALL_TYPE_ARRAY[@]}"` - - # Process all arrays for final json dictionary - SAP_FACTS_DICTIONARY=`arrays_to_dictionary ${DICT_ALL_NR_ARRAY[@]}` - - # Return values for Ansible - return_ansible success - -} - -# Return values for Ansible -function return_ansible(){ - - local result=$1 - - if [ $result = "success" ]; then - printf '{"changed": %s, "failed": %s, "msg": "%s", "sap_nw_sid": %s, "sap_hana_sid": %s, "sap_nw_nr": %s, "sap_hana_nr": %s, "sap_facts": %s}' \ - false false "SAP Information Gathering Successful $RETURN_MESSAGE" "$DICT_ALL_NW_SID_JSON" "$DICT_ALL_HANA_SID_JSON" "$DICT_ALL_NW_NR_JSON" "$DICT_ALL_HANA_NR_JSON" "$SAP_FACTS_DICTIONARY" - else - printf '{"changed": %s, "failed": %s, "msg": "%s", "sap_nw_sid": %s, "sap_hana_sid": %s, "sap_nw_nr": %s, "sap_hana_nr": %s, "sap_facts": %s}' \ - false true "SAP Information Gathering Failed $RETURN_MESSAGE" "$DICT_ALL_NW_SID_JSON" "$DICT_ALL_HANA_SID_JSON" "$DICT_ALL_NW_NR_JSON" "$DICT_ALL_HANA_NR_JSON" "$SAP_FACTS_DICTIONARY" - fi - - exit - -} - -# ===================================================================== -# Main -# ===================================================================== -main () { - - # For blank input, default param="all" - if [ -z "$param" ]; then - param="all" - fi - - if [ $param = "all" ]; then - get_all_hana_sid - get_all_nw_sid - elif [ $param = "hana" ]; then - get_all_hana_sid - elif [ $param = "nw" ]; then - get_all_nw_sid - else - # It must be a SID - get_sid_type $param - fi - - process_final_results - -} - -# For Ansible module, source $1 will take all the input parameters -source $1 -main diff --git a/plugins/modules/sap_monitor_hana_status.sh b/plugins/modules/sap_monitor_hana_status.sh deleted file mode 100644 index 7b02601..0000000 --- a/plugins/modules/sap_monitor_hana_status.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# ===================================================================== -# -# sap_monitor_hana_status.sh -# Authored by - Jason Masipiquena -# - IBM - Lab for SAP Solutions -# -# Bash script designed to be used as an Ansible module -# Check status of SAP HANA system -# Input: -# - hana_sid -# - hana_instance_number -# Output: -# - GREEN YELLOW RED GRAY (based on the status from sapcontrol) -# - Access the result from Ansible via .sap_status -# -# ===================================================================== - -# ===================================================================== -# Functions -# ===================================================================== -# check_is_hdb_up -# return_ansible - -# Checks if SAP HANA system is up -function check_is_hdb_up(){ - # $1 - SIDADM - # $2 - SID - # $3 - NR - local STATUS=$(su - $1 -c "sapcontrol -nr $3 -function GetSystemInstanceList | grep HDB") - STATUS=$(echo $STATUS | awk '{ print $7 }') - echo $STATUS -} - - -# Return values for Ansible -function return_ansible(){ - - local result=$1 - - if [ $result = "success" ]; then - printf '{"changed": %s, "failed": %s, "msg": "%s", "sap_status": "%s"}' \ - false false "SAP Check $RETURN_MESSAGE" "$STATUS" - else - printf '{"changed": %s, "failed": %s, "msg": "%s", "sap_status": "%s"}' \ - false true "SAP Check Failed" "$STATUS" - fi - - exit - -} - - -# ===================================================================== -# Main -# ===================================================================== -main () { - - export RETURN_MESSAGE="Successful" - - # These values are from Ansible - export SID=$(echo ${hana_sid}) - export NR=$(echo ${hana_instance_number}) - - export SIDADM=$(echo ${SID,,}adm) - export HOSTNAME=$(uname -n) - - export STATUS=$(check_is_hdb_up $SIDADM $SID $NR) - - return_ansible success - -} - -# For Ansible module, source $1 will take all the input parameters -source $1 -main diff --git a/plugins/modules/sap_monitor_nw_perf.sh b/plugins/modules/sap_monitor_nw_perf.sh deleted file mode 100644 index f1d886b..0000000 --- a/plugins/modules/sap_monitor_nw_perf.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash -# ===================================================================== -# -# sap_monitor_nw_perf.sh -# Authored by - Jason Masipiquena -# - IBM - Lab for SAP Solutions -# -# Bash script designed to be used as an Ansible module -# Checks SAP NW (PAS) performance metrics -# Input: -# - nw_sid -# - nw_instance_number -# - nw_instance_type -# Output: -# - heap_memory - Heap memory - access from Ansible via .heap_memory -# - extended_memory - Extended memory - access from Ansible via .extended_memory -# - cpu_util - CPU utilization - access from Ansible via .cpu_util -# - program_swap - Program buffer swap - access from Ansible via .program_swap -# -# ===================================================================== - -# ===================================================================== -# Functions -# ===================================================================== -# get_heap_mem -# get_ext_mem -# get_cpu_util -# get_program_buffer_swap -# result_to_dictionary -# return_ansible - -# Returns SAP NW (PAS) heap memory -function get_heap_mem(){ - # $1 - NR - local HEAPMEM=$(/usr/sap/hostctrl/exe/sapcontrol -nr $1 -function GetAlertTree | grep HeapAct | head -1 | awk '{ print $4 }') - echo $HEAPMEM -} - -# Returns SAP NW (PAS) extended memory -function get_ext_mem(){ - # $1 - NR - local EXTMEM=$(/usr/sap/hostctrl/exe/sapcontrol -nr $1 -function GetAlertTree | grep EsAct | head -1 | awk '{ print $4 }') - echo $EXTMEM -} - -# Returns SAP NW (PAS) CPU utilization -function get_cpu_util(){ - # $1 - NR - local CPUUTIL=$(/usr/sap/hostctrl/exe/sapcontrol -nr $1 -function GetAlertTree | grep CPU_Utilization | head -1 | awk '{ print $4 }') - echo $CPUUTIL -} - -# Returns SAP NW (PAS) program buffer swap -function get_program_buffer_swap(){ - # $1 - NR - local PROGRAMSWAP=$(/usr/sap/hostctrl/exe/sapcontrol -nr $1 -function GetAlertTree | grep Program | grep Swap | head -1 | awk '{ print $4 }') - echo $PROGRAMSWAP -} - -# Process results to json format -function result_to_dictionary() { - - echo -n '{' - - echo -n \"HeapMemory\": \"${HEAPMEM//\"/\\\"}\" - echo -n ', ' - echo -n \"ExtendedMemory\": \"${EXTMEM//\"/\\\"}\" - echo -n ', ' - echo -n \"CpuUtil\": \"${CPUUTIL//\"/\\\"}\" - echo -n ', ' - echo -n \"ProgramSwap\": \"${PROGRAMSWAP//\"/\\\"}\" - - echo -n '}' - -} - -# Return values for Ansible -function return_ansible(){ - - local result=$1 - - if [ $result = "success" ]; then - printf '{"changed": %s, "failed": %s, "msg": "%s", "heap_memory": "%s", "extended_memory": "%s", "cpu_util": "%s", "program_swap": "%s"}' \ - false false "SAP Check $RETURN_MESSAGE" "$HEAPMEM" "$EXTMEM" "$CPUUTIL" "$PROGRAMSWAP" - else - printf '{"changed": %s, "failed": %s, "msg": "%s", "heap_memory": "%s", "extended_memory": "%s", "cpu_util": "%s", "program_swap": "%s"}' \ - false true "SAP Check Failed" "$HEAPMEM" "$EXTMEM" "$CPUUTIL" "$PROGRAMSWAP" - fi - - exit - -} - - -# ===================================================================== -# Main -# ===================================================================== -main () { - - export RETURN_MESSAGE="Successful" - - # These values are from Ansible - export SID=$(echo ${nw_sid}) - export NR=$(echo ${nw_instance_number}) - export TYPE=$(echo ${nw_instance_type}) - - export SIDADM=$(echo ${SID,,}adm) - export HOSTNAME=$(uname -n) - - export CPUUTIL=$(get_cpu_util $NR) - export HEAPMEM=$(get_heap_mem $NR) - export EXTMEM=$(get_ext_mem $NR) - export PROGRAMSWAP=$(get_program_buffer_swap $NR) - - RESULTS_DICTIONARY=`result_to_dictionary` - return_ansible success - -} - -# For Ansible module, source $1 will take all the input parameters -source $1 -main diff --git a/plugins/modules/sap_monitor_nw_response.sh b/plugins/modules/sap_monitor_nw_response.sh deleted file mode 100644 index ce0fbb9..0000000 --- a/plugins/modules/sap_monitor_nw_response.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash -# ===================================================================== -# -# sap_monitor_nw_response.sh -# Authored by - Jason Masipiquena -# - IBM - Lab for SAP Solutions -# -# Bash script designed to be used as an Ansible module -# Checks SAP NW (PAS) response times -# Input: -# - nw_sid -# - nw_instance_number -# - nw_instance_type -# Output: -# - dialog_response_time - Dialog response time - access from Ansible via .dialog_response_time -# - database_response_time - Database response time - access from Ansible via .database_response_time -# - frontend_response_time - Front end response time - access from Ansible via .frontend_response_time -# - number_users - Current number of users logged in - access from Ansible via .number_users -# -# ===================================================================== - -# ===================================================================== -# Functions -# ===================================================================== -# get_dia_resp -# get_db_resp -# get_front_resp -# get_num_users -# result_to_dictionary -# return_ansible - -# Returns SAP NW (PAS) dialog response time -function get_dia_resp(){ - # $1 - NR - local DIARESP=$(/usr/sap/hostctrl/exe/sapcontrol -nr $1 -function GetAlertTree | grep ResponseTimeDialog | head -1 | awk '{ print $4 }') - echo $DIARESP -} - -# Returns SAP NW (PAS) database response time -function get_db_resp(){ - # $1 - NR - local DBRESP=$(/usr/sap/hostctrl/exe/sapcontrol -nr $1 -function GetAlertTree | grep DBRequestTime | head -1 | awk '{ print $4 }') - echo $DBRESP -} - -# Returns SAP NW (PAS) front end response time -function get_front_resp(){ - # $1 - NR - local FRONTRESP=$(/usr/sap/hostctrl/exe/sapcontrol -nr $1 -function GetAlertTree | grep FrontendResponseTime | head -1 | awk '{ print $4 }') - echo $FRONTRESP -} - -# Returns SAP NW (PAS) current number of logged in users -function get_num_users(){ - # $1 - NR - local NUMUSERS=$(/usr/sap/hostctrl/exe/sapcontrol -nr $1 -function GetAlertTree | grep UsersLoggedIn | head -1 | awk '{ print $4 }') - echo $NUMUSERS -} - -# Process results to json format -function result_to_dictionary() { - - echo -n '{' - - echo -n \"DialogResponseTime\": \"${DIARESP//\"/\\\"}\" - echo -n ', ' - echo -n \"DatabaseResponseTime\": \"${DBRESP//\"/\\\"}\" - echo -n ', ' - echo -n \"FrontEndResponseTime\": \"${FRONTRESP//\"/\\\"}\" - echo -n ', ' - echo -n \"NumberUsers\": \"${NUMUSERS//\"/\\\"}\" - - echo -n '}' - -} - -# Return values for Ansible -function return_ansible(){ - - local result=$1 - - if [ $result = "success" ]; then - printf '{"changed": %s, "failed": %s, "msg": "%s", "dialog_response_time": "%s", "database_response_time": "%s", "frontend_response_time": "%s", "number_users": "%s"}' \ - false false "SAP Check $RETURN_MESSAGE" "$DIARESP" "$DBRESP" "$FRONTRESP" "$NUMUSERS" - else - printf '{"changed": %s, "failed": %s, "msg": "%s", "dialog_response_time": "%s", "database_response_time": "%s", "frontend_response_time": "%s", "number_users": "%s"}' \ - false true "SAP Check Failed" "$DIARESP" "$DBRESP" "$FRONTRESP" "$NUMUSERS" - fi - - exit - -} - - -# ===================================================================== -# Main -# ===================================================================== -main () { - - export RETURN_MESSAGE="Successful" - - # These values are from Ansible - export SID=$(echo ${nw_sid}) - export NR=$(echo ${nw_instance_number}) - export TYPE=$(echo ${nw_instance_type}) - - export SIDADM=$(echo ${SID,,}adm) - export HOSTNAME=$(uname -n) - - export DIARESP=$(get_dia_resp $NR) - export DBRESP=$(get_db_resp $NR) - export FRONTRESP=$(get_front_resp $NR) - export NUMUSERS=$(get_num_users $NR) - - RESULTS_DICTIONARY=`result_to_dictionary` - return_ansible success - -} - -# For Ansible module, source $1 will take all the input parameters -source $1 -main diff --git a/plugins/modules/sap_monitor_nw_status.sh b/plugins/modules/sap_monitor_nw_status.sh deleted file mode 100644 index 6be4b5e..0000000 --- a/plugins/modules/sap_monitor_nw_status.sh +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/bash -# ===================================================================== -# -# sap_monitor_nw_status.sh -# Authored by - Jason Masipiquena -# - IBM - Lab for SAP Solutions -# -# Bash script designed to be used as an Ansible module -# Check status of SAP NW system -# Input: -# - nw_sid -# - nw_instance_number -# - nw_instance_type -# Output: -# - GREEN YELLOW RED GRAY (based on the status from sapcontrol) -# - Access the result from Ansible via .sap_status -# -# ===================================================================== - -# ===================================================================== -# Functions -# ===================================================================== -# check_is_nw_up -# return_ansible - -# Checks if SAP NW system is up -function check_is_nw_up(){ - # $1 - SIDADM - # $2 - NR - # $3 - Type of instance - INS_TYPE=$3 - INS_GREP="" - - if [[ $INS_TYPE = "PAS" ]]; then - INS_GREP="ABAP" - elif [[ $INS_TYPE = "ASCS" ]]; then - INS_GREP="MESSAGE" - elif [[ $INS_TYPE = "WebDisp" ]]; then - INS_GREP="WEBDISP" - elif [[ $INS_TYPE = "Java" ]]; then - INS_GREP="J2EE" - elif [[ $INS_TYPE = "SCS" ]]; then - INS_GREP="MESSAGE" - elif [[ $INS_TYPE = "ERS" ]]; then - INS_GREP="ENQUE" - else - INS_GREP="XXX" - fi - - local STATUS=$(su - $1 -c "sapcontrol -nr $2 -function GetSystemInstanceList | grep $INS_GREP") - STATUS=$(echo $STATUS | awk '{ print $7 }') - echo $STATUS -} - -# Return values for Ansible -function return_ansible(){ - - local result=$1 - - if [ $result = "success" ]; then - printf '{"changed": %s, "failed": %s, "msg": "%s", "sap_status": "%s"}' \ - false false "SAP Check $RETURN_MESSAGE" "$STATUS" - else - printf '{"changed": %s, "failed": %s, "msg": "%s", "sap_status": "%s"}' \ - false true "SAP Check Failed" "$STATUS" - fi - - exit - -} - - -# ===================================================================== -# Main -# ===================================================================== -main () { - - export RETURN_MESSAGE="Successful" - - # These values are from Ansible - export SID=$(echo ${nw_sid}) - export NR=$(echo ${nw_instance_number}) - export TYPE=$(echo ${nw_instance_type}) - - export SIDADM=$(echo ${SID,,}adm) - export HOSTNAME=$(uname -n) - - export STATUS=$(check_is_nw_up $SIDADM $NR $TYPE) - - return_ansible success - -} - -# For Ansible module, source $1 will take all the input parameters -source $1 -main diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..1d00cb5 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,4 @@ +--- +# There are no requirements defined for collection. +collections: [] +roles: [] diff --git a/roles/sap_control/tasks/actions/async_monitor.yml b/roles/sap_control/tasks/actions/async_monitor.yml index 4f4f467..e581959 100644 --- a/roles/sap_control/tasks/actions/async_monitor.yml +++ b/roles/sap_control/tasks/actions/async_monitor.yml @@ -5,7 +5,7 @@ when: - sap_control_function is match('restart|update') block: - - name: SAP Control - Get initial system state for instance - {{ command_item['nr'] }} # noqa no-changed-when + - name: SAP Control - Get initial system state for instance - {{ command_item['nr'] }} ansible.builtin.shell: cmd: >- source ~/.profile && diff --git a/roles/sap_control/tasks/actions/sapcontrol.yml b/roles/sap_control/tasks/actions/sapcontrol.yml index 5a2d97e..d35aafd 100644 --- a/roles/sap_control/tasks/actions/sapcontrol.yml +++ b/roles/sap_control/tasks/actions/sapcontrol.yml @@ -7,6 +7,9 @@ User: {{ command_item['user'] }} Command: {{ command_item['command'] }} +# Reason for noqa: +# - command-instead-of-shell: Command is executed as shell to ensure correct environment with 'source ~/.profile &&'. +# - no-changed-when: This is flexible task that can support information gathering functions without marking the playbook as changed. - name: SAP Control - Execute sapcontrol command for instance - {{ command_item['nr'] }} # noqa command-instead-of-shell no-changed-when ansible.builtin.shell: cmd: "{{ command_item['command'] }}" diff --git a/roles/sap_control/tasks/actions/sapstartsrv.yml b/roles/sap_control/tasks/actions/sapstartsrv.yml index da10c82..7b8f3eb 100644 --- a/roles/sap_control/tasks/actions/sapstartsrv.yml +++ b/roles/sap_control/tasks/actions/sapstartsrv.yml @@ -20,6 +20,8 @@ 'FAIL' in __sap_control_register_sapstartsrv_check.stdout or 'NIECONN_REFUSED' in __sap_control_register_sapstartsrv_check.stdout block: + # Reason for noqa: Ignore errors will skip already stopped service so it should not mark task as changed. + # We will determine if we made changes based on the recheck after stop/start attempts. - name: SAP Control - Stop 'sapstartsrv' service for instance - {{ __command_nr }} # noqa no-changed-when ansible.builtin.shell: cmd: >- @@ -32,6 +34,8 @@ register: __sap_control_register_sapstartsrv_stop ignore_errors: true + # Reason for noqa: Ignore errors will skip already started service so it should not mark task as changed. + # We will determine if we made changes based on the recheck after stop/start attempts. - name: SAP Control - Start 'sapstartsrv' service for instance - {{ __command_nr }} # noqa no-changed-when ansible.builtin.shell: cmd: >- diff --git a/roles/sap_control/vars/main.yml b/roles/sap_control/vars/main.yml index 7adf2aa..b73d73f 100644 --- a/roles/sap_control/vars/main.yml +++ b/roles/sap_control/vars/main.yml @@ -307,5 +307,5 @@ __sap_control_type_dict: "W": "WebDisp" # W## -> WebDispatcher "J": "Java" # J## (J##, JEM##) -> Java Application Server "S": "SCS" # SCS## -> SCS (Java Central Services) - "E": "ERS" # ERS## -> ERS (Enque Replication Server) + "E": "ERS" # ERS## -> ERS (Enqueue Replication Server) "H": "HDB" # HDB## (for HANA DB) - Added for completeness diff --git a/roles/sap_firewall/handlers/main.yml b/roles/sap_firewall/handlers/main.yml index fb2e795..7e8dbcc 100644 --- a/roles/sap_firewall/handlers/main.yml +++ b/roles/sap_firewall/handlers/main.yml @@ -6,3 +6,4 @@ ansible.builtin.command: cmd: firewall-cmd --reload when: sap_firewall_end_status == 'enabled' | d('enabled') + changed_when: true diff --git a/roles/sap_firewall/tasks/configure_preset.yml b/roles/sap_firewall/tasks/configure_preset.yml index f397f44..9b958d4 100644 --- a/roles/sap_firewall/tasks/configure_preset.yml +++ b/roles/sap_firewall/tasks/configure_preset.yml @@ -69,10 +69,13 @@ register: __sap_firewall_register_copy_service changed_when: __sap_firewall_register_copy_service.changed - - name: SAP Firewall - Reload firewalld after applying new service file - {{ __sap_firewall_preset.preset }} + # Reason for noqa: Handler cannot be used here, because reload has to be done now, not at end of role execution. + # Configuration step will fail if firewalld is not aware of new service file. + - name: SAP Firewall - Reload firewalld after applying new service file - {{ __sap_firewall_preset.preset }} # noqa no-handler ansible.builtin.command: cmd: firewall-cmd --reload when: __sap_firewall_register_copy_service.changed + changed_when: true - name: SAP Firewall - Remove temporary service file - {{ __sap_firewall_preset.preset }} ansible.builtin.file: diff --git a/roles/sap_hana_backint/tasks/backup/backup_tenant.yml b/roles/sap_hana_backint/tasks/backup/backup_tenant.yml index fe254eb..748d8dc 100644 --- a/roles/sap_hana_backint/tasks/backup/backup_tenant.yml +++ b/roles/sap_hana_backint/tasks/backup/backup_tenant.yml @@ -13,6 +13,7 @@ become: true become_user: "{{ __sap_hana_backint_sidadm_user }}" register: __sap_hana_backint_register_tenant_backup + changed_when: true - name: SAP HANA Backint - Backup - Fail if Tenant backup command failed ansible.builtin.fail: diff --git a/roles/sap_hana_backint/tasks/clean/clean_tenant.yml b/roles/sap_hana_backint/tasks/clean/clean_tenant.yml index fe5b5aa..f856f69 100644 --- a/roles/sap_hana_backint/tasks/clean/clean_tenant.yml +++ b/roles/sap_hana_backint/tasks/clean/clean_tenant.yml @@ -15,6 +15,7 @@ become: true become_user: "{{ __sap_hana_backint_sidadm_user }}" register: __sap_hana_backint_register_tenant_clean + changed_when: true - name: SAP HANA Backint - Clean - Fail if Tenant cleanup script failed ansible.builtin.fail: diff --git a/roles/sap_hana_backint/tasks/clean/main.yml b/roles/sap_hana_backint/tasks/clean/main.yml index 2bcb738..3086201 100644 --- a/roles/sap_hana_backint/tasks/clean/main.yml +++ b/roles/sap_hana_backint/tasks/clean/main.yml @@ -46,6 +46,7 @@ become: true become_user: "{{ __sap_hana_backint_sidadm_user }}" register: __sap_hana_backint_register_systemdb_clean + changed_when: true - name: SAP HANA Backint - Clean - Fail if SYSTEMDB cleanup script failed ansible.builtin.fail: diff --git a/roles/sap_hana_backint/tasks/setup/hdbsql_alter.yml b/roles/sap_hana_backint/tasks/setup/hdbsql_alter.yml index 80fd8bf..2f3a34d 100644 --- a/roles/sap_hana_backint/tasks/setup/hdbsql_alter.yml +++ b/roles/sap_hana_backint/tasks/setup/hdbsql_alter.yml @@ -26,5 +26,6 @@ stdin_add_newline: true become: true become_user: "{{ __sap_hana_backint_sidadm_user }}" + changed_when: true # No fail module is included because failed command will show usable output. diff --git a/roles/sap_hana_backint/tasks/setup/platform_aws_s3.yml b/roles/sap_hana_backint/tasks/setup/platform_aws_s3.yml index a425fdb..15b1aec 100644 --- a/roles/sap_hana_backint/tasks/setup/platform_aws_s3.yml +++ b/roles/sap_hana_backint/tasks/setup/platform_aws_s3.yml @@ -77,6 +77,7 @@ cmd: "{{ sap_hana_backint_aws_s3_definition['python_path'] }} -c \"import zstandard; print('zstandard is installed')\"" register: __sap_hana_backint_register_zstd_check ignore_errors: true + changed_when: false - name: SAP HANA Backint - Setup - AWS S3 - Fail if zstandard Python library is not installed ansible.builtin.fail: @@ -191,7 +192,8 @@ - name: Block to catch wrong python version errors block: - - name: SAP HANA Backint - Setup - AWS S3 - Execute script create_hdbbackint.py + # Reason for noqa: Command is executed as shell to ensure correct environment, because Python ENV is unset and overridden. + - name: SAP HANA Backint - Setup - AWS S3 - Execute script create_hdbbackint.py # noqa command-instead-of-shell ansible.builtin.shell: cmd: "{{ sap_hana_backint_aws_s3_definition['python_path'] }} create_hdbbackint.py" args: @@ -201,6 +203,7 @@ environment: PYTHONPATH: "" PYTHONHOME: "" + changed_when: true rescue: - name: SAP HANA Backint - Setup - AWS S3 - Fail due to Python version error diff --git a/roles/sap_hana_backint/tasks/setup/platform_azure_backup_rsv.yml b/roles/sap_hana_backint/tasks/setup/platform_azure_backup_rsv.yml index d90cd4c..6cabc55 100644 --- a/roles/sap_hana_backint/tasks/setup/platform_azure_backup_rsv.yml +++ b/roles/sap_hana_backint/tasks/setup/platform_azure_backup_rsv.yml @@ -33,6 +33,7 @@ # Script requires root user. become: true register: __sap_hana_backint_register_azure_script + changed_when: true rescue: - name: SAP HANA Backint - Setup - Azure RSV - Fail if pre-registration script failed diff --git a/roles/sap_hana_backint/tasks/setup/platform_gcs.yml b/roles/sap_hana_backint/tasks/setup/platform_gcs.yml index 442c795..40fdcd3 100644 --- a/roles/sap_hana_backint/tasks/setup/platform_gcs.yml +++ b/roles/sap_hana_backint/tasks/setup/platform_gcs.yml @@ -49,6 +49,7 @@ become: true become_user: "{{ __sap_hana_backint_sidadm_user }}" register: __sap_hana_backint_register_installbackint + changed_when: true # Alternative symlink: {{ __sap_hana_backint_opt_path }}/hdbconfig/parameters.json @@ -81,6 +82,7 @@ become: true become_user: "{{ __sap_hana_backint_sidadm_user }}" register: __sap_hana_backint_register_configurebackint + changed_when: true - name: SAP HANA Backint - Setup - GCS - Configure hanacleaner.py script diff --git a/roles/sap_hana_backint/tasks/setup/platform_ibm_cos_s3.yml b/roles/sap_hana_backint/tasks/setup/platform_ibm_cos_s3.yml index d12380e..879166e 100644 --- a/roles/sap_hana_backint/tasks/setup/platform_ibm_cos_s3.yml +++ b/roles/sap_hana_backint/tasks/setup/platform_ibm_cos_s3.yml @@ -80,6 +80,7 @@ cmd: "{{ sap_hana_backint_ibm_cos_s3_definition['python_path'] }} -c \"import zstandard; print('zstandard is installed')\"" register: __sap_hana_backint_register_zstd_check ignore_errors: true + changed_when: false - name: SAP HANA Backint - Setup - IBM COS S3 - Fail if zstandard Python library is not installed ansible.builtin.fail: @@ -194,7 +195,8 @@ - name: Block to catch wrong python version errors block: - - name: SAP HANA Backint - Setup - IBM COS S3 - Execute script create_hdbbackint.py + # Reason for noqa: Command is executed as shell to ensure correct environment, because Python ENV is unset and overridden. + - name: SAP HANA Backint - Setup - IBM COS S3 - Execute script create_hdbbackint.py # noqa command-instead-of-shell ansible.builtin.shell: cmd: "{{ sap_hana_backint_ibm_cos_s3_definition['python_path'] }} create_hdbbackint.py" args: @@ -204,6 +206,7 @@ environment: PYTHONPATH: "" PYTHONHOME: "" + changed_when: true rescue: - name: SAP HANA Backint - Setup - IBM COS S3 - Fail due to Python version error diff --git a/roles/sap_hana_backint/templates/hdbbackint_ibm_cos_s3.j2 b/roles/sap_hana_backint/templates/hdbbackint_ibm_cos_s3.j2 index 7c33704..6399ccf 100644 --- a/roles/sap_hana_backint/templates/hdbbackint_ibm_cos_s3.j2 +++ b/roles/sap_hana_backint/templates/hdbbackint_ibm_cos_s3.j2 @@ -6,7 +6,7 @@ provider = ibm auth = key bucket = {{ sap_hana_backint_ibm_cos_s3_definition['bucket'] }} region = {{ sap_hana_backint_ibm_cos_s3_definition['region'] }} -# Mandatory 3 parameters for IBM COS, endpoint is dependant on bucket location +# Mandatory 3 parameters for IBM COS, endpoint is dependent on bucket location api_key = {{ sap_hana_backint_ibm_cos_s3_definition['api_key'] }} resource_instance_id = {{ sap_hana_backint_ibm_cos_s3_definition['resource_instance_id'] }} endpoint_url = {{ sap_hana_backint_ibm_cos_s3_definition['endpoint_url'] }} diff --git a/roles/sap_hana_sr_takeover/tasks/detection/main.yml b/roles/sap_hana_sr_takeover/tasks/detection/main.yml index a6de21f..b20effa 100644 --- a/roles/sap_hana_sr_takeover/tasks/detection/main.yml +++ b/roles/sap_hana_sr_takeover/tasks/detection/main.yml @@ -2,7 +2,8 @@ --- # This role does not support operating clustered SAP HANA due to complexity and importance. -- name: SAP HANA SR Takeover - Detect if cluster services are enabled and active +# Reason for noqa: Systemctl module does not allow for this detection in loop, only controlling services. +- name: SAP HANA SR Takeover - Detect if cluster services are enabled and active # noqa command-instead-of-module ansible.builtin.command: cmd: "systemctl {{ service_item.cmd }} {{ service_item.service }}" loop: diff --git a/roles/sap_hana_sr_takeover/tasks/takeover.yml b/roles/sap_hana_sr_takeover/tasks/takeover.yml index 91f5426..0b1466c 100644 --- a/roles/sap_hana_sr_takeover/tasks/takeover.yml +++ b/roles/sap_hana_sr_takeover/tasks/takeover.yml @@ -39,6 +39,7 @@ become: true become_user: "{{ __sap_hana_sr_takeover_sidadm_user }}" register: __sap_hana_sr_takeover_register_sr_takeover + changed_when: true rescue: - name: SAP HANA SR Takeover - Fail if takeover command has failed @@ -82,6 +83,7 @@ register: __sap_hana_sr_takeover_register_stop_hana when: - __sap_hana_sr_takeover_fact_is_running + changed_when: true - name: SAP HANA SR Takeover - Register source primary node to target primary node ansible.builtin.shell: @@ -92,6 +94,7 @@ become_user: "{{ __sap_hana_sr_takeover_sidadm_user }}" register: __sap_hana_sr_takeover_register_sr_register failed_when: false + changed_when: true - name: SAP HANA SR Takeover - Fail if registration command has failed ansible.builtin.fail: diff --git a/roles/sap_profile_update/tasks/update/update_profile.yml b/roles/sap_profile_update/tasks/update/update_profile.yml index d19a37e..76b0247 100644 --- a/roles/sap_profile_update/tasks/update/update_profile.yml +++ b/roles/sap_profile_update/tasks/update/update_profile.yml @@ -39,9 +39,13 @@ # 4. Restart sapstartsrv when profile was changed for instance profile, not default. - name: SAP Profile Update - Restart sapstartsrv if profile file was modified ansible.builtin.command: - cmd: "/usr/sap/hostctrl/exe/sapcontrol -nr {{ __sap_profile_update_profile.instance_number }} -function RestartService" + cmd: >- + /usr/sap/hostctrl/exe/sapcontrol + -nr {{ __sap_profile_update_profile.instance_number }} + -function RestartService when: - sap_profile_update_restart_sapstartsrv | d(false) - __sap_profile_update_profile.type == 'instance' - __sap_profile_update_register_profile_before.stat.mtime != __sap_profile_update_register_profile_after.stat.mtime become: true + changed_when: true diff --git a/roles/sap_profile_update/tasks/validation/validate_profile.yml b/roles/sap_profile_update/tasks/validation/validate_profile.yml index 82b2092..4e7f9cc 100644 --- a/roles/sap_profile_update/tasks/validation/validate_profile.yml +++ b/roles/sap_profile_update/tasks/validation/validate_profile.yml @@ -66,7 +66,7 @@ Please check that the SAP HANA installation path is correct and that SAP HANA is installed properly. - name: SAP Profile Update - Get Instance Profile path from sapcontrol - ansible.builtin.shell: + ansible.builtin.command: cmd: >- /usr/sap/hostctrl/exe/sapcontrol -nr {{ __sap_profile_update_validate_profile.instance_number }} diff --git a/roles/sap_rfc/README.md b/roles/sap_rfc/README.md index ac52766..cb3ef73 100644 --- a/roles/sap_rfc/README.md +++ b/roles/sap_rfc/README.md @@ -28,11 +28,11 @@ The Ansible Task variables define the RFC actions to be executed. Examples are g ### Dependencies on other Ansible Roles -To execute successfully, this Ansible Role is dependant on the Ansible Collections: +To execute successfully, this Ansible Role is dependent on the Ansible Collections: - `community.sap_launchpad` on first run - `community.sap_libs` for every run -The first run will setup Python altinstall, subsequent runs on the same host will re-use the Python altinstall where PyRFC enabled. This is to protect the System default Python installation from additional or altered versions of Python Packages. +The first run will setup Python `altinstall`, subsequent runs on the same host will reuse the Python `altinstall` where PyRFC enabled. This is to protect the System default Python installation from additional or altered versions of Python Packages. ### Operating System @@ -47,10 +47,41 @@ Assumptions for executing this role include: ## Examples -A sample [Ansible Playbook for using the sap_rfc Ansible Role](../../playbooks/sample-sap-rfc.yml) is provided, which provides: +The following example executes remote function `STFC_CONNECTION`. + +```yaml +--- +- name: Ansible Play + hosts: all + become: true + tasks: + + - name: Execute Ansible Role sap_rfc + ansible.builtin.include_role: + name: community.sap_operations.sap_rfc + vars: + suser_id: 'My_S-User_ID' + suser_password: 'My_S-User_Password' + sap_nwrfc_sdk: nwrfc750P_10-70002752.zip + target_connection: + ashost: "My_SAP_System_Host" # Example: s4hana.poc.cloud + sysid: "My_SID" # Example: TDT + sysnr: "My_Instance_Number" # Example: "01" + client: "My_Client_ID" # Example: "400" + user: "My_Connection_User" # Example: DDIC + passwd: "My_Connection_User_Password" + lang: EN + target_function: STFC_CONNECTION + target_parameters: + REQUTEXT: 'Hello SAP!' + pyrfc_first_run: yes + register: sap_rfc_output + + - name: Show output of the variable 'sap_rfc_output' + ansible.builtin.debug: + msg: "{{ sap_rfc_output }}" +``` -- Ansible Vars for SAP User ID with download privileges for first-run -- Ansible Vars for SAP System connection details and user authorization The Ansible Role is designed to provide for all different RFCs. Therefore, the RFC parameters _(IMPORTING, EXPORTING, CHANGING)_ can accept the following data types: @@ -58,7 +89,7 @@ The Ansible Role is designed to provide for all different RFCs. Therefore, the R - ABAP Structure - ABAP Table -These RFC parameter data elements are mapped to the equivilant Python data type (e.g. string, integer, dictionary, list). Examples of these are shown below. +These RFC parameter data elements are mapped to the equivalent Python data type (e.g. string, integer, dictionary, list). Examples of these are shown below. ### Examples of Ansible Task variables for different RFC parameters @@ -79,7 +110,7 @@ sap_rfc_target_parameters: - For this input type the PyRFC Python module requires a Python Dictionary. - Ansible Task must declare the parameter name and use a YAML dictionary (key:value) -`Ansible Task code example for ABAP Struture:` +`Ansible Task code example for ABAP Structure:` ```yaml sap_rfc_target_parameters: IMPORTSTRUCT: diff --git a/roles/sap_rfc/SUPPLEMENTARY.md b/roles/sap_rfc/SUPPLEMENTARY.md index ffe07c4..f2f5c34 100644 --- a/roles/sap_rfc/SUPPLEMENTARY.md +++ b/roles/sap_rfc/SUPPLEMENTARY.md @@ -16,7 +16,7 @@ RFC parameters _(IMPORTING, EXPORTING, CHANGING)_ can accept the following data RFC parameters (TABLE) is deprecated and used for backwards compatibility, this can only accept one data type: - ABAP Table -For futher information, refer to [ABAP Programming Language - Built-In Data Types - SAP NetWeaver AS ABAP 7.56](https://help.sap.com/doc/abapdocu_756_index_htm/7.56/en-us/abenbuilt_in_types_complete.htm). +For further information, refer to [ABAP Programming Language - Built-In Data Types - SAP NetWeaver AS ABAP 7.56](https://help.sap.com/doc/abapdocu_756_index_htm/7.56/en-us/abenbuilt_in_types_complete.htm). ## Context of SAP NWRFC SDK and PyRFC diff --git a/tests/.gitkeep b/tests/.gitkeep deleted file mode 100644 index e69de29..0000000