From 9a6a0a858fd722ec72d4132b566149140812cf0c Mon Sep 17 00:00:00 2001 From: Vadim Shulkin Date: Mon, 3 Mar 2025 22:04:12 -0500 Subject: [PATCH] Added --- run_python_script.yml | 10 +++++++--- scripts/__pycache__/utils.cpython-312.pyc | Bin 332 -> 841 bytes scripts/my_script.py | 6 +++++- scripts/utils.py | 11 +++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) 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 7603d92b75ad42c6ed100b14c2b74dbd8af2c6d5..f3a577eb993bbf1fa588c5afb521c7d0fbc92f62 100644 GIT binary patch literal 841 zcmah{&1(}u6rZ=d`Dof$w1tX@OzFji(zHDXA*K{bBve$iwG!6sx?Q{3tTVgSgbF!S zP(0XM!H-LCe*6_4ym(35i;TVLWp83`o_w>-w&KMH^P4xnH}Ac9@6DHdK1WbqG(X#Q zAmqC|B%%zI{#jIZh)GOv$qJat7FkhD6;W-2u0`@%t%2UhqM{~O{}cjx!X|l5Oy#Y5 zo#<+-Nk$ zqJz*pqiJ!OkN%!3+~gMHg$=`WntUyE*B!4ASUjlvMq}Nut-?`IUI+un!lEeh^7YiqBo9Nk^u0}F-BwrfI zB6L;2V*zae9kj`h5RFT?FtC*bTozE)H8zY48<95Itw?4@R!*0VA_#aS;2|=nB_n$o z%}cn5fJqeJ6hjL}U@S76oJjf1@d8~Ds(F7-!aSExqLj(*ioA`}G0eKnTA|O`Byw_0 zyok^xhq;lL)6b`0Ex)gSD(+1z9ptWc%L%!>D3L_^ATGH!}7s4R96u K=@g8{PJaL-=eFbk delta 196 zcmX@fc81C9G%qg~0}$MfJ(ivfq#uJgFu(|9dYCTCp$AwzaS^EGATblyI8+CxhS)sq*%YSBr~U2ub}c4S9(!uYDs)4 zP*V{b&^*S;tc>#ZewvJ6UJ)};sE8dzumXu&95%W6DWy57c10W@wLo0V4J1A=Gcq!M MW@2RYVFW7%0GiP*M*si- 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) + +