First
This commit is contained in:
commit
122741c989
|
|
@ -0,0 +1,2 @@
|
||||||
|
requests
|
||||||
|
pandas
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
- name: Run Python Script with External Functions
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: no
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
- name: Ensure required Python packages are installed
|
||||||
|
pip:
|
||||||
|
requirements: /Users/vadimshulkin/playbooks/requirements.txt # Ensure dependencies are installed
|
||||||
|
|
||||||
|
- name: Run the Python script
|
||||||
|
command: python3 /Users/vadimshulkin/playbooks/scripts/my_script.py
|
||||||
|
register: script_output
|
||||||
|
|
||||||
|
- name: Show script output
|
||||||
|
debug:
|
||||||
|
msg: "{{ script_output.stdout }}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,17 @@
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Ensure the script can locate utils.py
|
||||||
|
sys.path.append(str(Path(__file__).parent))
|
||||||
|
|
||||||
|
# Import custom functions
|
||||||
|
from utils import greet_user
|
||||||
|
|
||||||
|
def main():
|
||||||
|
user = "Ansible AWX"
|
||||||
|
message = greet_user(user)
|
||||||
|
print(message)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
def greet_user(name):
|
||||||
|
return f"Hello, {name}! Your Python script is running via Ansible AWX."
|
||||||
|
|
||||||
Loading…
Reference in New Issue