Describe the bug
I have a feeling this is caused by the cron_name param. Basically, if I modify the command param for server.crontab but leave cron_name as is, when the deploy is run, it will consider the task to already be present resulting in a no-op.
To Reproduce
crontab -r#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Deploy to illustrate crontab bug.
"""
###############################################################################
# Imports
###############################################################################
# ==Site-Packages==
from pyinfra.operations import server
###############################################################################
# Main
###############################################################################
server.crontab(
name="Install test cron task.",
command="echo 'banana'",
# command="echo 'yummy'",
cron_name="My special task",
minute="*/10",
)
Expected behavior
The crontab should be updated to reflect the changes to the command.
Meta
โฏ pyinfra --support
--> Support information:
If you are having issues with pyinfra or wish to make feature requests, please
check out the GitHub issues at https://github.com/Fizzadar/pyinfra/issues .
When adding an issue, be sure to include the following:
System: Darwin
Platform: macOS-10.14.6-x86_64-i386-64bit
Release: 18.7.0
Machine: x86_64
pyinfra: v1.3.6
Executable: /Users/----/.virtualenvs/05-hz-pyinfra-d0Faa_8y-py3.9/bin/pyinfra
Python: 3.9.1 (CPython, Clang 10.0.1 (clang-1001.0.46.4))
Nice spot @taranlu-houzz, little bug in checking the command when using cron_name, fixed in https://github.com/Fizzadar/pyinfra/commit/228460d004175ebd539bba641d27773eb955bc40 for release in 1.3.7 shortly!
I'm still seeing this issue on 1.3.7. Did the fix not make it into that release?
It did! Will reopen this to investigate :grimacing:
So it looks like this happens due to a error handling the quotes in the command, for example the following file does change the command correctly:
server.crontab(
name="Install test cron task.",
command="echo banana",
#command="echo yummy",
cron_name="My special task",
minute="*/10",
)
Still looking into fixing this; certainly looks like it boils down to the sed_replace function but have no solution yet!
Figured this out!
The example code is now working in my tests :)
Awesome! Thank you for looking into that! I'll take a look at the next release.
Have now released those fixes in 1.3.9!