Skip to content

Commit

Permalink
Merge pull request #11 from r-dvl/bugfix/crontab
Browse files Browse the repository at this point in the history
Fix Crontab service
  • Loading branch information
r-dvl authored May 20, 2024
2 parents 40e0659 + 70f8cff commit 181c6f5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
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

0 comments on commit 181c6f5

Please sign in to comment.