Added
This commit is contained in:
parent
83e83ed2a6
commit
9a6a0a858f
|
|
@ -2,10 +2,14 @@
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Copy requirements.txt to remote host
|
||||||
- name: Ensure required Python packages are installed
|
copy:
|
||||||
|
src: ./requirements.txt # Ensure this exists locally
|
||||||
|
dest: /tmp/requirements.txt
|
||||||
|
|
||||||
|
- name: Install dependencies from copied requirements.txt
|
||||||
pip:
|
pip:
|
||||||
requirements: requirements.txt
|
requirements: /tmp/requirements.txt
|
||||||
|
|
||||||
- name: Run the Python script
|
- name: Run the Python script
|
||||||
command: python3 scripts/my_script.py
|
command: python3 scripts/my_script.py
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1,16 +1,20 @@
|
||||||
import sys
|
import sys
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Ensure the script can locate utils.py
|
# Ensure the script can locate utils.py
|
||||||
sys.path.append(str(Path(__file__).parent))
|
sys.path.append(str(Path(__file__).parent))
|
||||||
|
|
||||||
# Import custom functions
|
# Import custom functions
|
||||||
from utils import greet_user
|
from utils import greet_user, get_ad_groups
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
user = "Ansible AWX"
|
user = "Ansible AWX"
|
||||||
message = greet_user(user)
|
message = greet_user(user)
|
||||||
print(message)
|
print(message)
|
||||||
|
get_ad_groups()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,14 @@
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
def greet_user(name):
|
def greet_user(name):
|
||||||
return f"Hello, {name}! Your Python script is running via Ansible AWX."
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue