-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: kksat <[email protected]>
- Loading branch information
Showing
13 changed files
with
809 additions
and
146 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# 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 <https://www.gnu.org/licenses/>. | ||
|
||
--- | ||
DOCUMENTATION: | ||
name: app_instance | ||
author: Kirill Satarin (@kksat) | ||
extends_documentation_fragment: sap.sap_operations.community | ||
version_added: 2.3.0 | ||
short_description: Test to check if the provided sap instance is SAP application instance. | ||
description: | ||
- Test to check if the provided sap instance is SAP application instance. | ||
- This test filter is expected to be used with combination of sap.sap_operations.host_info module | ||
- Type of instance is determined by processes this instance runs (ProcessList value) | ||
options: | ||
value: | ||
description: One of the instances, returned by sap.sap_operations.host_info | ||
required: true | ||
seealso: | ||
- module: sap.sap_operations.host_info | ||
|
||
EXAMPLES: | | ||
- name: Get all sap instances | ||
sap.sap_operations.host_info: | ||
become: true | ||
become_user: root | ||
register: host_info | ||
- name: Filter only SAP APP instances | ||
ansible.builtin.debug: | ||
msg: "{{ host_info.instances | select('sap.sap_operations.app_instance') }}" | ||
RETURN: | ||
_value: | ||
type: boolean | ||
description: True if instance is SAP APP instance | ||
example: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# 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 <https://www.gnu.org/licenses/>. | ||
|
||
--- | ||
DOCUMENTATION: | ||
name: ascs_instance | ||
author: Kirill Satarin (@kksat) | ||
extends_documentation_fragment: sap.sap_operations.community | ||
version_added: 2.3.0 | ||
short_description: Test to check if the provided sap instance is SAP ASCS instance. | ||
description: | ||
- Test to check if the provided sap instance is SAP ASCS instance. | ||
- This test filter is expected to be used with combination of sap.sap_operations.host_info module | ||
- Type of instance is determined by processes this instance runs (ProcessList value) | ||
options: | ||
value: | ||
description: One of the instances, returned by sap.sap_operations.host_info | ||
required: true | ||
seealso: | ||
- module: sap.sap_operations.host_info | ||
|
||
EXAMPLES: | | ||
- name: Get all sap instances | ||
sap.sap_operations.host_info: | ||
become: true | ||
become_user: root | ||
register: host_info | ||
- name: Filter only SAP ASCS instances | ||
ansible.builtin.debug: | ||
msg: "{{ host_info.instances | select('sap.sap_operations.ascs_instance') }}" | ||
RETURN: | ||
_value: | ||
type: boolean | ||
description: True if instance is SAP ASCS instance | ||
example: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# 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 <https://www.gnu.org/licenses/>. | ||
|
||
--- | ||
DOCUMENTATION: | ||
name: hana_instance | ||
author: Kirill Satarin (@kksat) | ||
extends_documentation_fragment: sap.sap_operations.community | ||
version_added: 2.3.0 | ||
short_description: Test to check if the provided sap instance is SAP HANA instance. | ||
description: | ||
- Test to check if the provided sap instance is SAP HANA instance. | ||
- This test filter is expected to be used with combination of sap.sap_operations.host_info module | ||
- Type of instance is determined by processes this instance runs (ProcessList value) | ||
options: | ||
value: | ||
description: One of the instances, returned by sap.sap_operations.host_info | ||
required: true | ||
seealso: | ||
- module: sap.sap_operations.host_info | ||
|
||
EXAMPLES: | | ||
- name: Get all sap instances | ||
sap.sap_operations.host_info: | ||
become: true | ||
become_user: root | ||
register: host_info | ||
- name: Filter only SAP HANA instances | ||
ansible.builtin.debug: | ||
msg: "{{ host_info.instances | select('sap.sap_operations.hana_instance') }}" | ||
RETURN: | ||
_value: | ||
type: boolean | ||
description: True if instance is SAP HANA instance | ||
example: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# 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 <https://www.gnu.org/licenses/>. | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
|
||
def sap_instance(name: str, description: str): | ||
def f(instance): | ||
try: | ||
return any( | ||
instance_process["name"] == name | ||
and instance_process["description"] == description | ||
for instance_process in instance["ProcessList"] | ||
) | ||
except KeyError: | ||
return False | ||
|
||
return f | ||
|
||
|
||
def ascs_instance(instance): | ||
return sap_instance(name="enserver", description="EnqueueServer")( | ||
instance | ||
) and sap_instance(name="msg_server", description="MessageServer")(instance) | ||
|
||
|
||
class TestModule(object): | ||
def tests(self): | ||
return { | ||
"hana_instance": sap_instance(name="hdbdaemon", description="HDB Daemon"), | ||
"app_instance": sap_instance(name="disp+work", description="Dispatcher"), | ||
"ascs_instance": ascs_instance, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<!-- | ||
SPDX-License-Identifier: GPL-3.0-only | ||
SPDX-FileCopyrightText: 2023-2024 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. | ||
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/>. | ||
--> | ||
|
||
# ssh_keys_distribute | ||
|
||
Generate and distribute ssh keys for host to host communication | ||
|
||
|
||
Generate and distribute ssh keys for host to host communication | ||
Role has two modes of operation - present and absent, see variable ssh_keys_distribute_state | ||
If state=present role will ensure that ssh key (see below about key name) | ||
is present, key will be generated if absent, key will never be regenerated. | ||
After that role will distribute this key to other hosts, see how list of hosts defined below. | ||
|
||
If state=absent, role will make sure that key authorization on all hosts is removed. | ||
ssh key, even if it was generated will not be removed by the role. | ||
|
||
|
||
|
||
|
||
## Role Variables | ||
|
||
### Required parameters: | ||
|
||
|
||
|
||
#### ssh_keys_distribute_state | ||
|
||
|
||
_Type:_ `str` | ||
|
||
_Default:_ `present` | ||
|
||
_Required:_ `False` | ||
_Choices:_ | ||
- present | ||
- absent | ||
_Description:_ | ||
State=present - role will ensure that ssh keys are present (generated) | ||
State=absent - role will ensure that ssh key with name defined in variable ssh_keys_distribute_key | ||
cannot be used to login to hosts (using user defined in ssh_keys_distribute_user) | ||
|
||
|
||
|
||
|
||
#### ssh_keys_distribute_user | ||
|
||
|
||
_Type:_ `str` | ||
|
||
_Default:_ `root` | ||
|
||
_Required:_ `False` | ||
_Description:_ | ||
User for which key if be generated (if required) and distributed to all the hosts | ||
ansible_user should be able to sudo to this user | ||
|
||
|
||
|
||
|
||
#### ssh_keys_distribute_key | ||
|
||
|
||
_Type:_ `str` | ||
|
||
_Default:_ `id_rsa` | ||
|
||
_Required:_ `False` | ||
_Description:_ | ||
Name of the key to distribute, should not contain '*.pub' | ||
|
||
|
||
|
||
#### ssh_keys_distribute_hosts | ||
|
||
|
||
_Type:_ `list` | ||
|
||
|
||
_Required:_ `False` | ||
_Description:_ | ||
Lists of hosts, where key will be distributed, default value is ansible magic variable ansible_play_hosts | ||
|
||
|
||
|
||
|
||
## Limitations | ||
|
||
|
||
|
||
## Dependencies | ||
|
||
Role depend on collection community.crypto | ||
|
||
## Example Playbooks | ||
|
||
- name: Run role ssh_keys_distribute | ||
ansible.builtin.include_role: | ||
name: sap.sap_operations.ssh_keys_distribute | ||
|
||
## License | ||
|
||
GPL-3.0-only | ||
|
||
## Author Information | ||
|
||
Kirill Satarin (@kksat) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
|
||
--- | ||
ssh_keys_distribute_state: present | ||
ssh_keys_distribute_user: root | ||
ssh_keys_distribute_key: id_rsa | ||
ssh_keys_distribute_hosts: "{{ ansible_play_hosts }}" |
Oops, something went wrong.