@@ -51,6 +51,7 @@ It is recommended to install dependencies in venv that can be removed after exec
5151` ` `
5252
5353### Installation of dependencies with Python system default
54+ **NOTE:** Python modules are installed as packages to avoid ` externally-managed-environment` error.
5455` ` ` yaml
5556- name: Example play to install prerequisites with Python system default
5657 hosts: all
@@ -62,14 +63,15 @@ It is recommended to install dependencies in venv that can be removed after exec
6263 - python311-pip
6364 state: present
6465
65- - name : Install Python modules to Python system default
66- ansible.builtin.pip :
67- name :
68- - wheel
69- - urllib3
70- - requests
71- - beautifulsoup4
72- - lxml
66+ - name: Install Python module packages
67+ ansible.builtin.package:
68+ name:
69+ - python311-wheel
70+ - python311-urllib3
71+ - python311-requests
72+ - python311-beautifulsoup4
73+ - python311-lxml
74+ state: present
7375` ` `
7476
7577# # Additional execution methods
@@ -110,42 +112,3 @@ ansible-playbook --timeout 60 ./sample-playbook.yml \
110112--connection 'ssh' --user "$target_user" --inventory "$target_host," --private-key "$target_private_key_file" \
111113--ssh-extra-args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand='ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'"
112114` ` `
113-
114- ## Execution of Python Modules directly
115- ### Setup local Python environment
116- ``` shell
117- # Change directory to Python scripts source
118- cd ./plugins
119-
120- # Create isolated Python (protect system Python)
121- pyenv install 3.9.6
122- pyenv virtualenv 3.9.6 sap_launchpad
123- pyenv activate sap_launchpad
124-
125- # Install Python Modules to current Python environment
126- pip3 install beautifulsoup4 lxml requests
127-
128- # Run Python, import Python Modules and run Python Functions
129- python3
130- ```
131-
132- ### Execute Python Functions
133- ``` python
134- >> > from module_utils.sap_id_sso import sap_sso_login
135- >> > from module_utils.sap_launchpad_software_center_download_runner import *
136- >> >
137- >> > # Debug
138- >> > # from module_utils.sap_api_common import debug_https
139- >> > # debug_https()
140- >> >
141- >> > # # Perform API login requests to SAP Support
142- >> > username= ' S0000000'
143- >> > password= ' password'
144- >> > sap_sso_login(username, password)
145- >> > # # Perform API activity requests to SAP Support (e.g. software search without deduplication, and download software)
146- >> > query_result = search_software_filename(" HCMT_057_0-80003261.SAR" ,' ' )
147- >> > download_software(* query_result, output_dir = ' /tmp' )
148- ...
149- >> > # # API responses from SAP Support
150- >> > exit ()
151- ```
0 commit comments