Skip to content

Commit

Permalink
Release main-2.1.0
Browse files Browse the repository at this point in the history
Signed-off-by: kksat <22549266+kksat@users.noreply.github.com>
  • Loading branch information
kksat committed Nov 26, 2024
1 parent b6b696c commit 794fae9
Show file tree
Hide file tree
Showing 63 changed files with 702 additions and 359 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ SAP Operations Collection Release Notes

.. contents:: Topics

v2.1.0
======

Release Summary
---------------

Lifecycle release

Minor Changes
-------------

- clarify copyright information in license notice for some files

v2.0.1
======

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTORS.license
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SPDX-License-Identifier: GPL-3.0-only
SPDX-FileCopyrightText: 2024 Red Hat, Project Atmosphere
SPDX-FileCopyrightText: 2024 Kirill Satarin (@kksat)

Copyright 2024 Red Hat, Project Atmosphere
Copyright 2024 Kirill Satarin (@kksat)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU
General Public License as published by the Free Software Foundation, version 3 of the License.
Expand Down
34 changes: 30 additions & 4 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2023 Red Hat, Project Atmosphere
# SPDX-FileCopyrightText: 2023 Kirill Satarin (@kksat)
#
# Copyright 2023 Red Hat, Project Atmosphere
# Copyright 2023 Kirill Satarin (@kksat)
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, version 3 of the License.
Expand All @@ -24,7 +24,7 @@ namespace: sap

name: sap_operations

version: 2.0.1
version: 2.1.0

readme: README.md

Expand Down Expand Up @@ -113,7 +113,6 @@ build_ignore:
- plugins/test/me_valid_alias.py

- roles/pcs_config_checks
- roles/pcs_group_check
- plugins/filter/combine_default.py

- plugins/modules/hana_restore.py
Expand Down Expand Up @@ -220,3 +219,30 @@ build_ignore:

- roles/prepare_container
- roles/prepare_container/*

- roles/subscription_manager
- roles/subscription_manager/*

- roles/sap_operations
- roles/sap_operations/*

- plugins/filter/inifile_params.py

- roles/ssfs_sync
- roles/ssfs_sync/*

- roles/cluster_preconfigure
- roles/cluster_preconfigure/*

- roles/firewall
- roles/firewall/*

- roles/hana_sudoers
- roles/hana_sudoers/*
- roles/sapinst
- roles/sapinst/*

- roles/swpm_download_service
- roles/swpm_download_service/*

- plugins/modules/hana_system_replication_info.py
232 changes: 232 additions & 0 deletions plugins/action/LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions plugins/doc_fragments/abap_rfc_doc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2023 Red Hat, Project Atmosphere
# SPDX-FileCopyrightText: 2023 Kirill Satarin (@kksat)
#
# Copyright 2023 Red Hat, Project Atmosphere
# Copyright 2023 Kirill Satarin (@kksat)
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, version 3 of the License.
Expand Down
102 changes: 102 additions & 0 deletions plugins/doc_fragments/hana.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2024 Kirill Satarin (@kksat)
#
# Copyright 2024 Kirill Satarin (@kksat)
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# You should have received a copy of the GNU General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.


from __future__ import absolute_import, division, print_function

__metaclass__ = type


class ModuleDocFragment(object):
DOCUMENTATION = """
---
options: {}
notes:
- |
Variable binary_path is required, because hdbuserstore command cannot be found in $PATH environment variable.
If running ansible module using become directive with <hanasid>adm user and flag '-i' \
(interactive - meaning load all environment for the user) ansible modules fail.
This is due to the fact that <hanasid>adm user sets environment variables PYTHONHOME and PYTHONPATH \
(to use HANA python, not platform python) that confuses ansible.
And also HANA python might not have all the necessary packages installed to run ansible module.
In that case hdbuserstore command will not be in PATH environment variable for <hanasid>adm user and I(binary_path) has to be provided.
- |
There are several workaround around this unpleasant situation. First one is recommended.
- |
Workaround 1 (recommended)
- Run hdbsuserstore module with <hanasid>adm user with '-i' (interactive) flag like so
- "- name: Set the key mykey"
- "sap.sap_operations.hdbuserstore:"
- " key: mykey"
- " env: localhost:30113"
- " username: myuser"
- " password: mypassword"
- "become: true"
- "become_user: <hanasid>adm"
- "become_flags: -i"
- "vars:"
- " ansible_python_interpreter: '/usr/libexec/platform-python -E'"
- |
Option '-E' for python interpreter will ignore all PYTHON environment variables, so ansible will run platform python without any problems.
Variable I(ansible_python_interpreter) have to be set to value "/usr/libexec/platform-python -E" on all RHEL versions for any ansible module
execution when using become directive for <hanasid>adm user with become flag '-i'.
- |
ansible_python_interpreter: "/usr/libexec/platform-python -E" can be set at task level (as above),\
at play level, or be set as host variable either in inventory file or as task in playbook:
- |
To use other SAP HANA related ansible modules (for instances hana_system_replication_info),\
this is the only option, because other modules might not have parameters to accommodate for binary tool path.
- |
Workaround 2 (only for hdbuserstore module)
- |
Do not use interactive flag when becoming <hanasid>adm user.
- "- name: Set the key mykey"
- "sap.sap_operations.hdbuserstore:"
- " key: mykey"
- " env: localhost:30113"
- " username: myuser"
- " password: mypassword"
- " binary_path: /usr/sap/HAN/SYS/exe/hdb"
- "become: true"
- "become_user: <hanasid>adm"
- |
In that case hdbuserstore command will not be in PATH environment variable for <hanasid>adm user and I(binary_path) has to be provided.
- |
Workaround 3 (only for hdbuserstore module)
- Do not use interactive flag when becoming <hanasid>adm user. But do not want to provide value for variable I(binary_path).
- In that case value for I(binary_path) can be extracted from HANA parameter DIR_EXECUTABLE that one can get with I(parameter_info) module
- "- name: Get DIR_EXECUTABLE"
- "sap.sap_operations.parameter_info:"
- " instance_number: 00"
- " name: DIR_EXECUTABLE"
- "become: true"
- "become_user: <hanasid>adm"
- "register: __DIR_EXECUTABLE"
- "- name: Set the key mykey"
- "sap.sap_operations.hdbuserstore:"
- " key: mykey"
- " env: localhost:30113"
- " username: myuser"
- " password: mypassword"
- " binary_path: '{{ __DIR_EXECUTABLE.parameter_value[0] }}'"
- "become: true"
- "become_user: <hanasid>adm"
"""
4 changes: 2 additions & 2 deletions plugins/doc_fragments/saphost.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-

# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2023 Red Hat, Project Atmosphere
# SPDX-FileCopyrightText: 2023 Kirill Satarin (@kksat)
#
# Copyright 2023 Red Hat, Project Atmosphere
# Copyright 2023 Kirill Satarin (@kksat)
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, version 3 of the License.
Expand Down
4 changes: 2 additions & 2 deletions plugins/filter/valid_sid.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-

# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2023 Red Hat, Project Atmosphere
# SPDX-FileCopyrightText: 2023 Kirill Satarin (@kksat)
#
# Copyright 2023 Red Hat, Project Atmosphere
# Copyright 2023 Kirill Satarin (@kksat)
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, version 3 of the License.
Expand Down
26 changes: 17 additions & 9 deletions plugins/module_utils/abap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2023 Red Hat, Project Atmosphere
# SPDX-FileCopyrightText: 2023 Kirill Satarin (@kksat)
#
# Copyright 2023 Red Hat, Project Atmosphere
# Copyright 2023 Kirill Satarin (@kksat)
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, version 3 of the License.
Expand Down Expand Up @@ -62,11 +62,17 @@
try:
from suds.client import Client
except ImportError:
HAS_SUDS_LIBRARY = False
SUDS_LIBRARY_IMPORT_ERROR = traceback.format_exc()
Client = None
HttpAuthenticated = None
HttpTransport = None
try:
from virtwho.virt.esx.suds.client import Client
except ImportError:
HAS_SUDS_LIBRARY = False
SUDS_LIBRARY_IMPORT_ERROR = traceback.format_exc()
Client = None
HttpAuthenticated = None
HttpTransport = None
else:
HAS_SUDS_LIBRARY = True
SUDS_LIBRARY_IMPORT_ERROR = None
else:
HAS_SUDS_LIBRARY = True
SUDS_LIBRARY_IMPORT_ERROR = None
Expand Down Expand Up @@ -931,7 +937,8 @@ def __exit__(self, exc_type, exc_value, exc_tb):
self.exit_json(**exc_value.kwargs)
else:
self.fail_json(
msg="Exception {0} occurred.".format(exc_type.__class__.__name__),
msg="Exception {0} occurred.".format(
exc_type.__class__.__name__),
exception=str(exc_value),
traceback=traceback.format_tb(exc_tb),
)
Expand All @@ -945,7 +952,8 @@ def convert2ansible(self, result):
result
) # Decimal is not supported by Ansible, converted to string
if isinstance(result, bytes):
return result.decode(encoding="utf-8") # Bytes are decoded to strings
# Bytes are decoded to strings
return result.decode(encoding="utf-8")
else:
for k, v in result.items():
result[k] = self.convert2ansible(v)
Expand Down
33 changes: 33 additions & 0 deletions plugins/module_utils/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2024 Kirill Satarin (@kksat)
#
# Copyright 2024 Kirill Satarin (@kksat)
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# You should have received a copy of the GNU General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.

from __future__ import absolute_import, division, print_function


__metaclass__ = type


def convert_string2bool(value):
if value.lower() == "true":
return True
if value.lower() == "false":
return False
return value
68 changes: 68 additions & 0 deletions plugins/module_utils/hana.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2024 Kirill Satarin (@kksat)
#
# Copyright 2024 Kirill Satarin (@kksat)
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# You should have received a copy of the GNU General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.

from __future__ import absolute_import, division, print_function
from ansible_collections.sap.sap_operations.plugins.module_utils.common import ( # noqa: E501
convert_string2bool,
)
from ansible.module_utils.basic import AnsibleModule
from typing import List
from collections.abc import Callable

HANA_SYSTEM_REPLICATION_INFO_MAPPING = {
"online": "online",
"mode": "mode",
"operation_mode": "operation mode",
"site_id": "site id",
"site_name": "site name",
"is_source_system": "is source system",
"is_secondary_consumer_system": "is secondary/consumer system",
"has_secondaries_consumers_attached": "has secondaries/consumers attached",
"is_takeover_active": "is a takeover active",
"is_primary_suspended": "is primary suspended",
}


def get_hdbnsutil_run_command(module: AnsibleModule) -> Callable:
def hdbnsutil_run_command(args: List[str]) -> tuple[int, str, str]:
rc, stdout, stderr = module.run_command(["hdbnsutil"] + args)
return rc, stdout, stderr

return hdbnsutil_run_command


def get_hana_system_replication_info_from_stdout(stdout: str) -> dict:
"""Parses the stdout of the 'hdbnsutil -sr_state' command and returns a dictionary containing the license information.
Args:
stdout (str): The stdout
Returns:
dict: A dictionary containing the hana system replication configuration information
"""
hana_system_replication_info = dict()
for line in stdout.splitlines():
for key, value in HANA_SYSTEM_REPLICATION_INFO_MAPPING.items():
if value in line:
hana_system_replication_info[key] = convert_string2bool(
line.split(":")[1].strip()
)
return hana_system_replication_info
Loading

0 comments on commit 794fae9

Please sign in to comment.