Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sap_control role can't call sap_system_facts module #25

Open
ge87sik opened this issue Apr 25, 2024 · 5 comments
Open

sap_control role can't call sap_system_facts module #25

ge87sik opened this issue Apr 25, 2024 · 5 comments

Comments

@ge87sik
Copy link

ge87sik commented Apr 25, 2024

Hello everyone,

I've encountered an issue when trying to use the sap_operations.sap_control role (with sap_control_function set to 'stop_all_nw').

code_snippet

When running the playbook i get the following error message:

nw_restart_error

From what I understand the role is trying to call the sap_system_facts module with a parameter named 'param', but sap_system_facts doesn't accept any parameters.
I've tried removing the offending line (l. 90) and calling the module without any parameters but then the sap_facts_register variable has no entry 'sap_facts'.
Am I doing something wrong or is there an issue in the code?

Greetings
Manuel

@Wabri
Copy link
Member

Wabri commented May 2, 2024

Hi @ge87sik I've gone through the code and there is definitely a problem in

community.sap_libs.sap_system_facts:

The problem came from the fact that the module sap_libs.sap_system_facts doesn't take any options with it so the param is an element no known by the task. You can see it here: https://github.com/sap-linuxlab/community.sap_libs/blob/7d8bc0f11c2e1f58da73710e7925f456d011ec0c/plugins/modules/sap_system_facts.py

Regarding the no entry sap_facts the problem came by the fact that sap_facts_register return ansible_facts and not sap_facts.

For now just try to replace sap_facts with ansible_facts and copy-paste the results here, I'll reach out the other developers to understand what is the correction that need to be done here.

Thanks for reporting this 🥇

@rob0d
Copy link

rob0d commented Jun 5, 2024

Just to add to this. Even when the parameters are removed from line 90 to allow community.sap_libs.sap_system_facts to work, the role fails further down as the returned values are not as expected by the rest of the code. community.sap_libs.sap_system_facts is not compatible with this role, making it unuseable :(..
This was probably introduced by commit #bfd09a5 ?
I will try to test the code as it was before to see if it works.

@Wabri
Copy link
Member

Wabri commented Jun 12, 2024

Thanks @rob0d we have already started an internal discussion about the sap_libs and how to handle the maintenance.

@kksat
Copy link

kksat commented Jun 12, 2024

This is a way to stop all SAP ABAP systems using sap.sap_operations collection
See
https://docs.galaxy.saponrhel.org/
https://galaxy.ansible.com/ui/repo/published/sap/sap_operations/

- name: Stop all ABAP instances on the host
   hosts: <hostname>
   gather_facts: false
   become: true
   become_user: root
   tasks: 
     - name: Get all instances on the host
        sap.sap_operations.host_info
        register: host_info

     - name: Stop all ABAP instances on the host
        sap.sap_operations.system:
           name: ABAP
           state: stopped
           instance_number: "{{ instance_number }}"
         loop: "{{ host_info.instances }}"
         vars:
             instance_number: "{{ item.mSystemNumber }}"

I just types this playbook, please use with caution, GPL3.0-only license and warranty.

python-suds package have to be installed on the host you want to run these modules against (if this is a RHEL system). Any other ways to install suds python package should also work.

Hope that helps

@crweller
Copy link

crweller commented Aug 1, 2024

Hi all,
I just suffered the same issue and figured out that with some minor changes on the main.yml and prepare.yml it started to work.

roles/sap_control/tasks/prepare.yml

- name: SAP Control
  vars:
    sap_control_execute_sid: "{{ item.SID }}"
    sap_control_execute_type: "{{ item.Type }}"
    sap_control_execute_instance_nr: "{{ item.NR }}"
    sap_control_execute_instance_type: "{{ item.InstanceType }}"
  ansible.builtin.include_tasks: "sapcontrol.yml"
  loop: "{{ sap_facts_register.ansible_facts.sap }}"
  when:
    - "item.InstanceType | lower == sap_type | lower"

Just changed following:

  • the loop to use the dict as it is given by sap_libs module
  • the when condition to use the result from InstanceType instead of Type and put both to lower case
  • in the vars change item.InstanceNumber to item.Nr

See the screenshots:

diff_main_yml
main.yml

diff_prepare_yml
prepare.yml

For my situation that worked.

Let me know what you think.
Id' be glad if you consider to use my solution.

Cheers,
Rainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants