diff --git a/run_python_script.yml b/run_python_script.yml index 0de4a67..00b69e9 100644 --- a/run_python_script.yml +++ b/run_python_script.yml @@ -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 diff --git a/scripts/__pycache__/utils.cpython-312.pyc b/scripts/__pycache__/utils.cpython-312.pyc index 7603d92..f3a577e 100644 Binary files a/scripts/__pycache__/utils.cpython-312.pyc and b/scripts/__pycache__/utils.cpython-312.pyc differ diff --git a/scripts/my_script.py b/scripts/my_script.py index 24f299a..9613bfa 100644 --- a/scripts/my_script.py +++ b/scripts/my_script.py @@ -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() diff --git a/scripts/utils.py b/scripts/utils.py index b871e50..1a9f621 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -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) + +