Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Crontab service #11

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions api/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ ENV VAULT_PASSWORD_FILE=/config/vault_password_file
# Install dependencies
COPY ./requirements.txt /api/requirements.txt

# Install Ansible
RUN apt-get update && apt-get install -y sshpass && \
# Install Ansible and cron
RUN apt-get update && apt-get install -y sshpass cron && \
pip install --no-cache-dir --upgrade -r /api/requirements.txt && \
pip install ansible

Expand All @@ -27,4 +27,10 @@ COPY ./v1 /api/v1
# API listener port
EXPOSE 8080

CMD ["python3", "./main.py"]
# Start cron service
RUN service cron start

# Copy startup script
COPY ./start.sh /start.sh

CMD ["/bin/bash", "/start.sh"]
7 changes: 7 additions & 0 deletions api/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Start cron service
service cron start

# Start your application
python3 ./main.py
2 changes: 1 addition & 1 deletion api/v1/endpoints/crontab.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
router = APIRouter()

# Crontabs path
path = '/crontabs'
path = '/cron.d'

@router.get("/read")
def get_crontab(crontab: str = Query(..., description="Crontab name")):
Expand Down
2 changes: 1 addition & 1 deletion api/v1/endpoints/playbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Playbooks path
base_path = "/ansible-playbooks/playbooks/"
scripts_path = "/ansible-playbooks/scripts/"
crontab_path = '/crontabs/ansible'
crontab_path = '/cron.d/ansible'

@router.get("/get-playbooks")
def get_playbooks():
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- 8080:8080
volumes:
- /DATA/AppData/ansible-manager/logs:/logs
- /DATA/AppData/ansible-manager/crontabs:/crontabs
- /DATA/AppData/ansible-manager/cron.d:/etc/cron.d
- /DATA/AppData/ansible-manager/ansible-playbooks:/ansible-playbooks
- /DATA/AppData/ansible-manager/config:/config
environment:
Expand Down
Loading