Closed picoroma closed 1 year ago
Hi @picoroma, thank you for open this Issue. It is not necessary to install pyrfc on the nw host because we always do rfc calls.
Ansible always execute modules on the host defined on top of the playbook.
Therefore you have two possible solution and depends on the tasks which should be executed:
Execute your playbook on localhost like: (Only a good approach if you execute tasks which must not executed on the NW host for example)
- name: SAP_USER
hosts: localhost
tasks:
-
use delegation:
- name: Create SAP User
community.sap_libs.sap_user:
conn_username: 'ADMIN'
conn_password: 'MyAdminPSWD'
host: myhostname
sysnr: '00'
client: '200'
state: present
username: ANSIBLE
firstname: first_admin
lastname: last_admin
email: admin@test.de
password: Test123456
useralias: ANSIBLE-ADMIN
company: DEFAULT_COMPANY
roles:
- "SAP_ALL"
delegate_to: localhost
The delegation could also a other foreign host. Both approaches needs the installation of pyrfc and sdk on the control node or delegate host.
If you want to use AAP or AWX you have to build a custom ee which contains pyrfc.
Please let me know if this will solve your problem.
If you have any question feel free to reach out to me.
Hi @rainerleber ! THX to you for answer me!. I'm quite new to ANSIBLE and i have a lot of GAP on this. Anyway I have tested successfully both method you give me. One question - regarding for example "community.sap_libs.sap_user" How can I use the ANSIBLE methot to create user MASSIVELY ? Assigning each one for example different SAP Profile ? THX
It depends on what you want to achieve exactly a possible solution:
defining a var like:
user_groups: ''
- { firstname: "admin_user", username: "test_admin", role: "SAP_ALL" }
- { firstname: "monitoring_user", username: "test_mon", role: "SAP_ADMIN" }
and the task like:
- name: Create SAP User
community.sap_libs.sap_user:
conn_username: 'ADMIN'
conn_password: 'MyAdminPSWD'
host: myhostname
sysnr: '00'
client: '200'
state: present
username: "{{ item.username }}"
firstname: "{{ item.firstname }}"
lastname: last_admin
email: admin@test.de
password: Test123456
useralias: ANSIBLE-ADMIN
company: DEFAULT_COMPANY
roles:
- "{{ item.role}}"
loop:
- user_groups
You can also develop a solution reading AD user write them to a set_fact var and iterate over it for example.
OK. I will try! THX PLEASE correct (even into the Example Documentation of the module) ... roles:
profiles:
because "SAP_ALL" is a SAP profile and NOT a SAP role!
Thank for the hint i will correct it :-)
Solved
Summary
I have a Ansible CONTROL Node with: python version: Python 3.8.10 pyrfc version: 2.7.0
And a ansible "SAP NW" Node with: OS: SLES 15 SP2 Python 3.6.15 pyrfc: missing
When try to use the module "community.sap_libs.sap_user" to create a new USER I have the error:
"msg": "Failed to import the required Python library (pyrfc) on myhostname's Python /usr/bin/python3. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
Question1: Do I need to install the pyrfc even on SAP NW host ? (because this is not possible now) QUestion2: How to correct the error ? THX
Issue Type
Bug Report
Component Name
sap_user
Ansible Version
community.sap_libs Version
Configuration
OS / Environment
Source OS (Ansible Control Node): Ubuntu 20.04.5 LTS Target OS (SAP NW): SLES 15 SP2
Steps to Reproduce
Expected Results
Error NA
Actual Results
Code of Conduct