diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 964c8f6..17d4bcc 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,150 +2,166 @@ **Topics** -- v1\.35\.0 +- v1\.36\.0 - Release Summary -- v1\.34\.0 - - Release Summary - Major Changes -- v1\.33\.1 +- v1\.35\.0 + - Release Summary +- v1\.34\.0 - Release Summary + - Major Changes +- v1\.33\.1 + - Release Summary - Minor Changes - v1\.33\.0 - - Release Summary - - Major Changes -- v1\.32\.0 - Release Summary - Major Changes -- v1\.31\.1 +- v1\.32\.0 - Release Summary + - Major Changes +- v1\.31\.1 + - Release Summary - Minor Changes - v1\.31\.0 - - Release Summary - - Major Changes -- v1\.30\.3 - Release Summary + - Major Changes +- v1\.30\.3 + - Release Summary - Minor Changes - v1\.30\.2 - - Release Summary + - Release Summary - Minor Changes - v1\.30\.1 - - Release Summary + - Release Summary - Minor Changes - v1\.30\.0 - - Release Summary - - Major Changes + - Release Summary + - Major Changes - Minor Changes - v1\.29\.0 - - Release Summary -- v1\.28\.0 - Release Summary - - Major Changes +- v1\.28\.0 + - Release Summary + - Major Changes - Minor Changes - v1\.27\.0 - - Release Summary + - Release Summary - Minor Changes - v1\.26\.0 - - Release Summary -- v1\.25\.0 - Release Summary -- v1\.24\.0 +- v1\.25\.0 - Release Summary -- v1\.23\.1 +- v1\.24\.0 - Release Summary - - Major Changes -- v1\.23\.0 +- v1\.23\.1 - Release Summary - Major Changes -- v1\.22\.1 +- v1\.23\.0 - Release Summary + - Major Changes +- v1\.22\.1 + - Release Summary - Minor Changes - v1\.22\.0 - - Release Summary + - Release Summary - v1\.21\.0 - v1\.20\.0 - - Release Summary - - Major Changes -- v1\.19\.0 - Release Summary - Major Changes -- v1\.18\.0 -- v1\.17\.0 +- v1\.19\.0 - Release Summary - Major Changes +- v1\.18\.0 +- v1\.17\.0 + - Release Summary + - Major Changes - v1\.16\.0 - v1\.15\.1 - - Release Summary + - Release Summary - Minor Changes - v1\.15\.0 - - Release Summary - - Major Changes -- v1\.14\.1 - Release Summary + - Major Changes +- v1\.14\.1 + - Release Summary - Minor Changes - v1\.14\.0 - v1\.13\.0 - - Release Summary - - Major Changes -- v1\.12\.0 - Release Summary -- v1\.11\.0 + - Major Changes +- v1\.12\.0 - Release Summary +- v1\.11\.0 + - Release Summary - Minor Changes - v1\.10\.0 - - Release Summary -- v1\.9\.1 - Release Summary +- v1\.9\.1 + - Release Summary - Minor Changes - v1\.9\.0 - - Release Summary - - Major Changes -- v1\.3\.2 - Release Summary + - Major Changes +- v1\.3\.2 + - Release Summary - Minor Changes - v1\.3\.1 - - Release Summary + - Release Summary - Minor Changes - v1\.3\.0 - - Release Summary + - Release Summary - Minor Changes - v1\.2\.2 - - Release Summary + - Release Summary - Minor Changes - v1\.2\.1 - - Release Summary + - Release Summary - Minor Changes - v1\.2\.0 - - Release Summary - - Major Changes -- v1\.1\.2 - Release Summary + - Major Changes +- v1\.1\.2 + - Release Summary - Minor Changes - v1\.1\.1 - - Release Summary + - Release Summary - Minor Changes - v1\.1\.0 - - Release Summary -- v1\.0\.5 - Release Summary +- v1\.0\.5 + - Release Summary - Minor Changes - v1\.0\.4 - - Release Summary - - Major Changes + - Release Summary + - Major Changes - Minor Changes - v1\.0\.3 - - Release Summary + - Release Summary - Minor Changes - v1\.0\.2 - - Release Summary - - Major Changes -- v1\.0\.0 - Release Summary - Major Changes +- v1\.0\.0 + - Release Summary + - Major Changes + + +## v1\.36\.0 + + +### Release Summary + +Feature release + + +### Major Changes + +* add role swmp \- to manage SAP SWPM \(download\, install\, uninstall\) ## v1\.35\.0 - + ### Release Summary Feature release @@ -153,12 +169,12 @@ Feature release ## v1\.34\.0 - + ### Release Summary Feature release - + ### Major Changes * add role hana\_preconfigure @@ -166,7 +182,7 @@ Feature release ## v1\.33\.1 - + ### Release Summary Documentation fix release @@ -179,12 +195,12 @@ Documentation fix release ## v1\.33\.0 - + ### Release Summary Feature release - + ### Major Changes * add filter plugin \- me\_aliases @@ -195,12 +211,12 @@ Feature release ## v1\.32\.0 - + ### Release Summary Feature release - + ### Major Changes * add role general\_preconfigure @@ -208,7 +224,7 @@ Feature release ## v1\.31\.1 - + ### Release Summary Feature release @@ -221,12 +237,12 @@ Feature release ## v1\.31\.0 - + ### Release Summary Feature release - + ### Major Changes * add \'commands\' show\_c and show\_w as mandated by GPL\-3\.0 license @@ -234,7 +250,7 @@ Feature release ## v1\.30\.3 - + ### Release Summary Bugfix release @@ -248,7 +264,7 @@ Bugfix release ## v1\.30\.2 - + ### Release Summary Lifecycle release @@ -261,7 +277,7 @@ Lifecycle release ## v1\.30\.1 - + ### Release Summary Bugfix release @@ -276,12 +292,12 @@ Bugfix release ## v1\.30\.0 - + ### Release Summary Feature release - + ### Major Changes * role \- download \- download SAP software from SWDC @@ -295,7 +311,7 @@ Feature release ## v1\.29\.0 - + ### Release Summary Feature release @@ -303,12 +319,12 @@ Feature release ## v1\.28\.0 - + ### Release Summary Feature and bugfix release - + ### Major Changes * add role powershell \- to manage powershell installation @@ -324,7 +340,7 @@ Feature and bugfix release ## v1\.27\.0 - + ### Release Summary Feature release @@ -338,7 +354,7 @@ Feature release ## v1\.26\.0 - + ### Release Summary Feature release @@ -346,7 +362,7 @@ Feature release ## v1\.25\.0 - + ### Release Summary Feature release @@ -354,7 +370,7 @@ Feature release ## v1\.24\.0 - + ### Release Summary Feature release @@ -362,12 +378,12 @@ Feature release ## v1\.23\.1 - + ### Release Summary Documentation release - + ### Major Changes * Added documentation website docs\.galaxy\.saponrhel\.org @@ -375,12 +391,12 @@ Documentation release ## v1\.23\.0 - + ### Release Summary Maintenance release - + ### Major Changes * minimal ansible version supported is 2\.15 @@ -388,7 +404,7 @@ Maintenance release ## v1\.22\.1 - + ### Release Summary Documentation release @@ -402,7 +418,7 @@ Documentation release ## v1\.22\.0 - + ### Release Summary Feature release @@ -413,12 +429,12 @@ Feature release ## v1\.20\.0 - + ### Release Summary Feature release - + ### Major Changes * Add role cf \- to manage Cloud Foundry cli @@ -426,12 +442,12 @@ Feature release ## v1\.19\.0 - + ### Release Summary Feature release - + ### Major Changes * Add role cloudconnector @@ -442,12 +458,12 @@ Feature release ## v1\.17\.0 - + ### Release Summary Feature release - + ### Major Changes * Add role sapjvm @@ -458,7 +474,7 @@ Feature release ## v1\.15\.1 - + ### Release Summary Bugfix release @@ -471,12 +487,12 @@ Bugfix release ## v1\.15\.0 - + ### Release Summary Feature release - + ### Major Changes * Add role hana @@ -484,7 +500,7 @@ Feature release ## v1\.14\.1 - + ### Release Summary Bug fix release @@ -501,12 +517,12 @@ Bug fix release ## v1\.13\.0 - + ### Release Summary Feature release - + ### Major Changes * Add ABAP transport management modules @@ -514,7 +530,7 @@ Feature release ## v1\.12\.0 - + ### Release Summary Feature release @@ -522,7 +538,7 @@ Feature release ## v1\.11\.0 - + ### Release Summary Feature release @@ -535,7 +551,7 @@ Feature release ## v1\.10\.0 - + ### Release Summary Feature release @@ -543,7 +559,7 @@ Feature release ## v1\.9\.1 - + ### Release Summary Bug fix release @@ -557,12 +573,12 @@ Bug fix release ## v1\.9\.0 - + ### Release Summary Lifecycle release - + ### Major Changes * Add \'all\' and \'any\' filter and test plugins @@ -575,7 +591,7 @@ Lifecycle release ## v1\.3\.2 - + ### Release Summary Bugfix release @@ -588,7 +604,7 @@ Bugfix release ## v1\.3\.1 - + ### Release Summary Bugfix release @@ -601,7 +617,7 @@ Bugfix release ## v1\.3\.0 - + ### Release Summary Feature release @@ -616,7 +632,7 @@ Feature release ## v1\.2\.2 - + ### Release Summary Feature release @@ -629,7 +645,7 @@ Feature release ## v1\.2\.1 - + ### Release Summary Feature release @@ -642,12 +658,12 @@ Feature release ## v1\.2\.0 - + ### Release Summary Feature release - + ### Major Changes * Introduction of NW RFC modules to connect to manage SAP ABAP system with Ansible @@ -655,7 +671,7 @@ Feature release ## v1\.1\.2 - + ### Release Summary Bug Fix Release @@ -668,7 +684,7 @@ Bug Fix Release ## v1\.1\.1 - + ### Release Summary Bug Fix Release @@ -684,7 +700,7 @@ Bug Fix Release ## v1\.1\.0 - + ### Release Summary Feature Release @@ -692,7 +708,7 @@ Feature Release ## v1\.0\.5 - + ### Release Summary Bug fix release @@ -705,12 +721,12 @@ Bug fix release ## v1\.0\.4 - + ### Release Summary Two roles are added hana\_update and prepare - + ### Major Changes * Role hana\_update \- update SAP HANA system @@ -724,7 +740,7 @@ Two roles are added hana\_update and ## v1\.0\.3 - + ### Release Summary Using changelog fragments to build collection changelog\. @@ -738,12 +754,12 @@ Using changelog fragments to build collection changelog\. ## v1\.0\.2 - + ### Release Summary First release of SAP Operations collection\. - + ### Major Changes * parameter\_info \- module to fetch parameter information\. @@ -755,12 +771,12 @@ First release of SAP Operations collection\. ## v1\.0\.0 - + ### Release Summary First release of SAP Operations collection\. - + ### Major Changes * parameter\_info \- module to fetch parameter information\. diff --git a/galaxy.yml b/galaxy.yml index 94e1c46..5d93c55 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -24,7 +24,7 @@ namespace: sap name: sap_operations -version: 1.35.0 +version: 1.36.0 readme: README.md diff --git a/plugins/modules/me_downloaditemset_info.py b/plugins/modules/me_downloaditemset_info.py index 36ff182..b825e4b 100644 --- a/plugins/modules/me_downloaditemset_info.py +++ b/plugins/modules/me_downloaditemset_info.py @@ -663,22 +663,25 @@ def main(): url = me_download_item_set_url( ENR=enr, - PECGRSC1=PECGRSC1_from_architecture_and_os_family[architecture][ - os_family - ], # noqa: E501 + PECGRSC1=PECGRSC1_from_architecture_and_os_family[architecture][os_family], ) response = module(url=url) if response.get("d") is None or response.get("d").get("results") is None: module.fail_json( - msg="Failed to fetch information from SAP software download center", # noqa: E501 + msg="Failed to fetch information from SAP software download center", response=response, ) + me_downloaditemset_info = response["d"]["results"] + for itemset in me_downloaditemset_info: + if ("FileSize" not in itemset) and ("Filesize" in itemset): + itemset["FileSize"] = itemset["Filesize"] + module.exit_json( changed=False, - me_downloaditemset_info=response["d"]["results"], + me_downloaditemset_info=me_downloaditemset_info, ) diff --git a/roles/download/tasks/main.yml b/roles/download/tasks/main.yml index 6eda7cf..2d5ccdc 100644 --- a/roles/download/tasks/main.yml +++ b/roles/download/tasks/main.yml @@ -52,7 +52,7 @@ when: - ansible_facts['mounts'] is defined - ansible_facts['mounts'] | length > 0 - - __mount_point['size_available'] // 1024 <= __size_needed + - (__mount_point['size_available'] // 1024) | int <= __size_needed | int vars: __mount_point: "{{ ansible_facts['mounts'] | sap.sap_operations.mount_path(filepath=download_destination) }}" @@ -89,28 +89,18 @@ default(item.item.DownloadDirectLink) }}" download_file_filename: "{{ item.me_file_info.FileName }}" - download_file_filepath: "{{ download_destination }}/{{ item_filename }}" + download_file_filepath: "{{ (download_destination, item_filename) | ansible.builtin.path_join }}" download_file_existing_file_checksum: >- {{ download_destination_stats.results | selectattr('stat', 'defined') | map(attribute='stat') - | selectattr('path', 'equalto', present_file_fullpath) + | selectattr('path', 'equalto', download_file_filepath) | map(attribute='checksum') | first | default("") }} - download_file_existing_file_filepath: "{{ download_destination }}/{{ item_filename }}" + download_file_existing_file_filepath: "{{ (download_destination, item_filename) | ansible.builtin.path_join }}" item_filename: "{{ item.me_file_info.FileName }}" - present_file_fullpath: "{{ download_destination }}/{{ item_filename }}" - present_file_checksum: >- - {{ download_destination_stats.results - | selectattr('stat', 'defined') - | map(attribute='stat') - | selectattr('path', 'equalto', present_file_fullpath) - | map(attribute='checksum') - | first - | default("") - }} loop: "{{ download_files_info.results }}" loop_control: label: "{{ download_file_url }} - {{ item_filename }}" diff --git a/roles/sapcar/meta/argument_specs.yml b/roles/sapcar/meta/argument_specs.yml index 00275b0..890bb12 100644 --- a/roles/sapcar/meta/argument_specs.yml +++ b/roles/sapcar/meta/argument_specs.yml @@ -30,6 +30,8 @@ argument_specs: description: - Path to sapcar executable file - Default value is from collection variable sap_operations_sapcar_exe_path + - All parent directories to directory where sapcar executable should be located should exists and be writable for ansible user + - Role will not create /usr/sap directory and will not set owner and mode for this type: path required: false default: /usr/sap/sapcar/sapcar diff --git a/roles/swpm/README.md b/roles/swpm/README.md new file mode 100644 index 0000000..522acec --- /dev/null +++ b/roles/swpm/README.md @@ -0,0 +1,165 @@ + + +# swpm + +Manage SAP SWPM (download / install / uninstall) + + +Manage SAP SWPM +Role will download SAP SWPM binary from SAP SWDC (software download center) +Role will use ansible_facts to determine current host os system and architecture to download correct binary +Role will download latest SP available from SAP SWDC web site in that sense role is not idempotent, +because next time one will run this role, there might be new SP of SAP SWPM + +Role will not do anything if swpm_state='present' and file sapinst exists in swpm_unpack_destination + + + +## Role Variables + +### Required parameters: + + +- [swpm_download_username](#swpm_download_username) + +- [swpm_download_password](#swpm_download_password) + + +#### swpm_download_username + + +_Type:_ `str` + + +_Required:_ `True` +_Description:_ +Username (sap support user, suser) that will be used to download software. +By default value is from collection variable `sap_operations_download_username`. +Collection variable `sap_operations_download_username` default value is set to environment variable SAP_OPERATIONS_DOWNLOAD_USERNAME + + + + +#### swpm_download_password + + +_Type:_ `str` + + +_Required:_ `True` +_Description:_ +Password of provided username that will be used to download software +By default value is from collection variable `sap_operations_download_password`. +Collection variable `sap_operations_download_password` default value is set to environment variable SAP_OPERATIONS_DOWNLOAD_PASSWORD + + + + +#### swpm_state + + +_Type:_ `str` + +_Default:_ `present` + +_Required:_ `False` +_Choices:_ +- present +- downloaded +- absent +_Description:_ +State for SAP SWPM +present - role will ensure that executable will downloaded and installed (copied to swpm_unpack_destination) +present - will do any changes only if file sapinst in swpm_unpack_destination does not exists +absent - role will ensure that SAP SWPM is absent, swpm_unpack_destination directory will be removed +downloaded - role will only download SAP SWPM binary archive + + + +#### swpm_unpack_destination + + +_Type:_ `path` + +_Default:_ `/usr/sap/swpm` + +_Required:_ `False` +_Description:_ +Path there SAP SWPM binary archive will be unpacked (in case of swpm_state='present') +Role will not create swpm_unpack_destination folder or any folders above it. It has to exists + + + +#### swpm_download_destination + + +_Type:_ `path` + +_Default:_ `/tmp/` + +_Required:_ `False` +_Description:_ +Path there SAP SWPM binary archive will be downloaded (in case of swpm_state='present' or swpm_state='downloaded') +Role will not create swpm_download_destination folder or any folders above it. It has to exists + + + +#### swpm_version + + +_Type:_ `str` + +_Default:_ `2.0` + +_Required:_ `False` +_Choices:_ +- 2.0 +- 1.0 +_Description:_ +SAP SWPM version that will be downloaded and / or installed +Role will always download SP version that was changed last on SAP SWDC (software download center) + + + + +## Limitations + +Tested only on RHEL 8 and 9 +Tested only on x86_64 architecture + +## Dependencies + +Role has no dependencies to other roles. + +## Example Playbooks + + + +## License + +GPL-3.0-only + +## Author Information + +Kirill Satarin (@kksat) diff --git a/roles/swpm/defaults/main.yml b/roles/swpm/defaults/main.yml new file mode 100644 index 0000000..3a51073 --- /dev/null +++ b/roles/swpm/defaults/main.yml @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2024 Red Hat, Project Atmosphere +# +# Copyright 2024 Red Hat, Project Atmosphere +# +# 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 . + +--- +sap_operations_download_username: "{{ lookup('ansible.builtin.env', 'SAP_OPERATIONS_DOWNLOAD_USERNAME') }}" # noqa var-naming[no-role-prefix] +sap_operations_download_password: "{{ lookup('ansible.builtin.env', 'SAP_OPERATIONS_DOWNLOAD_PASSWORD') }}" # noqa var-naming[no-role-prefix] + +swpm_download_username: "{{ sap_operations_download_username }}" +swpm_download_password: "{{ sap_operations_download_password }}" + +swpm_version: "2.0" +swpm_download_destination: /tmp/ +swpm_state: present + +sap_operations_swpm_unpack_destination: /usr/sap/swpm # noqa var-naming[no-role-prefix] +swpm_unpack_destination: "{{ sap_operations_swpm_unpack_destination }}" diff --git a/roles/swpm/meta/argument_specs.yml b/roles/swpm/meta/argument_specs.yml new file mode 100644 index 0000000..2513e9e --- /dev/null +++ b/roles/swpm/meta/argument_specs.yml @@ -0,0 +1,118 @@ +--- +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2024 Red Hat, Project Atmosphere +# +# Copyright 2024 Red Hat, Project Atmosphere +# +# 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 . + +argument_specs: + main: + short_description: Manage SAP SWPM (download / install / uninstall) + description: + - Manage SAP SWPM + - Role will download SAP SWPM binary from SAP SWDC (software download center) + - Role will use ansible_facts to determine current host os system and architecture to download correct binary + - | + Role will download latest SP available from SAP SWDC web site in that sense role is not idempotent, + because next time one will run this role, there might be new SP of SAP SWPM + - Role will not do anything if swpm_state='present' and file sapinst exists in swpm_unpack_destination + options: + swpm_state: + description: + - State for SAP SWPM + - present - role will ensure that executable will downloaded and installed (copied to swpm_unpack_destination) + - present - will do any changes only if file sapinst in swpm_unpack_destination does not exists + - absent - role will ensure that SAP SWPM is absent, swpm_unpack_destination directory will be removed + - downloaded - role will only download SAP SWPM binary archive + type: str + required: false + default: present + choices: + - present + - downloaded + - absent + swpm_unpack_destination: + description: + - Path there SAP SWPM binary archive will be unpacked (in case of swpm_state='present') + - Role will not create swpm_unpack_destination folder or any folders above it. It has to exists + type: path + required: false + default: /usr/sap/swpm + swpm_download_destination: + description: + - Path there SAP SWPM binary archive will be downloaded (in case of swpm_state='present' or swpm_state='downloaded') + - Role will not create swpm_download_destination folder or any folders above it. It has to exists + type: path + required: false + default: /tmp/ + swpm_version: + description: + - SAP SWPM version that will be downloaded and / or installed + - Role will always download SP version that was changed last on SAP SWDC (software download center) + type: str + choices: + - "2.0" + - "1.0" + required: false + default: "2.0" + swpm_download_username: + description: | + Username (sap support user, suser) that will be used to download software. + By default value is from collection variable `sap_operations_download_username`. + Collection variable `sap_operations_download_username` default value is set to environment variable SAP_OPERATIONS_DOWNLOAD_USERNAME + type: str + required: true + # collection_variable: sap_operations_download_username + swpm_download_password: + description: | + Password of provided username that will be used to download software + By default value is from collection variable `sap_operations_download_password`. + Collection variable `sap_operations_download_password` default value is set to environment variable SAP_OPERATIONS_DOWNLOAD_PASSWORD + type: str + required: true + + __limitations__: + options: {} + short_description: Limitations + description: + - Tested only on RHEL 8 and 9 + - Tested only on x86_64 architecture + + __dependencies__: + options: {} + short_description: Dependencies + description: + - Role has no dependencies to other roles. + + __examples__: + options: {} + short_description: Example Playbooks + description: + - "" + + __license__: + options: {} + short_description: License + description: + - GPL-3.0-only + + __author__: + options: {} + short_description: Author Information + description: + - Kirill Satarin (@kksat) diff --git a/roles/swpm/meta/main.yml b/roles/swpm/meta/main.yml new file mode 100644 index 0000000..9794ee5 --- /dev/null +++ b/roles/swpm/meta/main.yml @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2024 Red Hat, Project Atmosphere +# +# Copyright 2024 Red Hat, Project Atmosphere +# +# 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 . + +--- +galaxy_info: + author: Kirill Satarin (@kksat) + description: Manage SAP SWMP + license: GPL-3.0-only + min_ansible_version: "2.15" + platforms: + - name: EL + versions: + - "7" + - "8" + - "9" + galaxy_tags: [] +dependencies: [] diff --git a/roles/swpm/tasks/absent.yml b/roles/swpm/tasks/absent.yml new file mode 100644 index 0000000..2f69501 --- /dev/null +++ b/roles/swpm/tasks/absent.yml @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2024 Red Hat, Project Atmosphere +# +# Copyright 2024 Red Hat, Project Atmosphere +# +# 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 . + +--- +- name: Make sure that folder swpm_unpack_destination does not exist + ansible.builtin.file: + name: "{{ swpm_unpack_destination }}" + state: absent diff --git a/roles/swpm/tasks/downloaded.yml b/roles/swpm/tasks/downloaded.yml new file mode 100644 index 0000000..10e066c --- /dev/null +++ b/roles/swpm/tasks/downloaded.yml @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2024 Red Hat, Project Atmosphere +# +# Copyright 2024 Red Hat, Project Atmosphere +# +# 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 . + +--- +- name: Make sure SAP SWPM binaries downloaded + ansible.builtin.include_role: + name: sap.sap_operations.download + vars: + download_alias: "swpm-{{ swpm_version }}" + download_username: "{{ swpm_download_username }}" + download_password: "{{ swpm_download_password }}" + download_destination: "{{ swpm_download_destination }}" diff --git a/roles/swpm/tasks/main.yml b/roles/swpm/tasks/main.yml new file mode 100644 index 0000000..b7f77c1 --- /dev/null +++ b/roles/swpm/tasks/main.yml @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2024 Red Hat, Project Atmosphere +# +# Copyright 2024 Red Hat, Project Atmosphere +# +# 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 . + +--- +- name: Get statistics for sapinst + ansible.builtin.stat: + path: "{{ swpm_unpack_destination }}/sapinst" + register: swpm_sapinst_stat + +- name: Include tasks depending on swmp_state (skip if not needed) + ansible.builtin.include_tasks: "{{ swpm_state }}.yml" + when: + - ( + swpm_state == 'present' and not swpm_sapinst_stat.stat.exists + or + swpm_state != 'present' + ) diff --git a/roles/swpm/tasks/present.yml b/roles/swpm/tasks/present.yml new file mode 100644 index 0000000..66990b9 --- /dev/null +++ b/roles/swpm/tasks/present.yml @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-3.0-only +# SPDX-FileCopyrightText: 2024 Red Hat, Project Atmosphere +# +# Copyright 2024 Red Hat, Project Atmosphere +# +# 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 . + +--- +- name: Make sure SAP SWPM downloaded + ansible.builtin.include_tasks: downloaded.yml + +- name: Make sure SAP SWPM binaries unpacked + ansible.builtin.include_role: + name: sap.sap_operations.unpack + vars: + unpack_source: "{{ download_register_last.files | map(attribute='filepath') }}" + unpack_destination: "{{ swpm_unpack_destination }}" diff --git a/roles/unpack/tasks/main.yml b/roles/unpack/tasks/main.yml index 659b1d7..40e8ee0 100644 --- a/roles/unpack/tasks/main.yml +++ b/roles/unpack/tasks/main.yml @@ -38,7 +38,3 @@ loop: "{{ [unpack_source] | flatten }}" loop_control: loop_var: source - -- name: Print output variable - ansible.builtin.debug: - msg: "{{ unpack_register | default([]) }}" diff --git a/roles/unpack/tasks/unpack-sar.yml b/roles/unpack/tasks/unpack-sar.yml index 0e5e7a3..ab5fc58 100644 --- a/roles/unpack/tasks/unpack-sar.yml +++ b/roles/unpack/tasks/unpack-sar.yml @@ -1,8 +1,8 @@ --- # SPDX-License-Identifier: GPL-3.0-only -# SPDX-FileCopyrightText: 2023 Red Hat, Project Atmosphere +# SPDX-FileCopyrightText: 2023-2024 Red Hat, Project Atmosphere # -# Copyright 2023 Red Hat, Project Atmosphere +# Copyright 2023-2024 Red Hat, Project Atmosphere # # 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. @@ -33,12 +33,15 @@ - name: Register output variable ansible.builtin.set_fact: - unpack_register: | - 'results': "{{ unpack_register.results | default([]) + - [{ - 'file': item.path, - 'changed': unpack_sapcar_file.changed, - 'failed': unpack_sapcar_file.rc > 0 - }] }}" - 'changed': "{{ ( unpack_sapcar_file.changed ) or ( unpack_register.changed | default(false) ) }}" - 'failed': "{{ (unpack_sapcar_file.rc > 0) or ( unpack_register.failed | default(false) ) }}" + unpack_register: + changed: "{{ unpack_sapcar_file.changed or (unpack_register.changed | default(false)) }}" + failed: "{{ (unpack_sapcar_file.rc > 0) or (unpack_register.failed | default(false)) }}" + results: >- + {{ unpack_register.results | default([]) + [ + { + 'file': item.path, + 'changed': unpack_sapcar_file.changed, + 'failed': unpack_sapcar_file.rc > 0, + } + ] + }}