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

Hidden global name argument | Crontab facts #1183

Open
kwilt opened this issue Aug 26, 2024 · 0 comments
Open

Hidden global name argument | Crontab facts #1183

kwilt opened this issue Aug 26, 2024 · 0 comments

Comments

@kwilt
Copy link

kwilt commented Aug 26, 2024

Is your feature request related to a problem? Please describe

Maybe my idea is only applicable to this one specific operation - I'm not yet familiar with ALL operations - however, there could be others that work similarly to server.crontab().

When using server.crontab() to modify already existing cronjobs, the cronjob must have a cron_name identifier set on it, otherwise it will make a new entry into your crontab. Since an existing cronjob must be identified in order to be modified, I find it a bit redundant that my pre-deployment "Detected Changes" output must now display both of the operations (identifying and modifying).

Solution 1

If this idea is something that is only applicable to server.crontab(), possibly the the Crontab facts could be enhanced so you could check if an identifier already exists in your crontab, then a second server.crontab() would no longer be necessary to use to verify cronjobs are identified before modifying them. Could be implemented something like this:

if not host.get_fact(Crontab, user=<user>, cron_name=<your identifer set by server.crontab()>):
    # Cron identifier not found in crontab, will now identify the cronjob
    server.crontab(
    name="Identify Cron"
    command=<command>
    cron_name=<your identifer>
    ...
    ...
    )

Solution 2

My alternative suggestion is to add an optional "Hidden" value to the global name argument so that an operation can be hidden from your pre-deployment "detected changes" output. In practice it would look something like this:

server.crontab(
    # Identifying a cron, don't want shown in detected changes
    name=Hidden,
    command="<your command here>",
    cron_name="<do a thing>"
    ...
    ...
    ...
)

Another way to implement this idea could be to add a global _hidden argument that would work something like this and accomplish the same thing:

server.crontab(
    name="Identifying a cron",
    command=<your command here>,
    cron_name="<do a thing>"
    ...
    ...
    ...
    # Don't want shown in detected changes
    _hidden=True
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@kwilt and others