This commit is contained in:
Vadim Shulkin 2025-03-03 22:04:12 -05:00
parent 83e83ed2a6
commit 9a6a0a858f
4 changed files with 23 additions and 4 deletions

View File

@ -2,10 +2,14 @@
hosts: localhost
gather_facts: no
tasks:
- name: Ensure required Python packages are installed
- name: Copy requirements.txt to remote host
copy:
src: ./requirements.txt # Ensure this exists locally
dest: /tmp/requirements.txt
- name: Install dependencies from copied requirements.txt
pip:
requirements: requirements.txt
requirements: /tmp/requirements.txt
- name: Run the Python script
command: python3 scripts/my_script.py

View File

@ -1,16 +1,20 @@
import sys
import pandas as pd
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
from utils import greet_user, get_ad_groups
def main():
user = "Ansible AWX"
message = greet_user(user)
print(message)
get_ad_groups()
if __name__ == "__main__":
main()

View File

@ -1,3 +1,14 @@
import pandas as pd
def greet_user(name):
return f"Hello, {name}! Your Python script is running via Ansible AWX."
def get_ad_groups():
df1 = pd.DataFrame({'A': [1, 2, 3], 'B': ['x', 'y', 'z'], 'C': [10, 20, 30]})
df2 = pd.DataFrame({'A': [2, 3, 4, 5], 'B': ['y', 'z', 'w', 'q'], 'C': [20, 30, 50, 40]})
print(df1)
print(df2)