semaphoreui / semaphore

Modern UI for Ansible, Terraform, OpenTofu, PowerShell and other DevOps tools.
https://semaphoreui.com
MIT License
10.37k stars 1.04k forks source link

Feature: Add Variables to Scheduled Jobs #2378

Open DaniiC00kie opened 2 hours ago

DaniiC00kie commented 2 hours ago

Related to

Service (scheduled tasks, alerts)

Impact

nice to have

Missing Feature

It would be nice, if you can add custom variables to the scheduler.

== Detailed Explaination == I have one playbook, which runs different tasks, depending on the os group selected. For example, I build an "enum" where the end user (myself) can select which hosts are going to be rebootet. For example: "Frontend" or "Backend"

It should not be restartet at the same time - but it should serve the same purpose (and it is a bit easier to maintain one playbook, instead of many!)

Now I want to restart the backend once every 2 weeks and the frontend every other week. So I would need to create two jobs and two templates for that for the same purpose - which is counterintutive in my opinion.

Implementation

While creating or edit an scheduled job, the user should be able to add default variables, which gets added to the playbook.

For now, the config option looks like that: image

You can add the following option from the templates itself: image

Maybe, change the option to "Available Variables" and give the use the option to select it, or just make a new field - e.g. textbox for strings ...

Then within the dropdown you can select the varaiable, and right next to it a textbox, where you can set it, whatever you want.

Design

I just have basic programming experience, and just c#, sorry for that.

But maybe grep the existing variables from the template, and give the user the option, to add them. (It sounds very simple, sorry.)

What edge-cases need to be covered? It is way easier to maintain one single playbook, instead of multiple, which serve the same purpose, even in the enterprise environment. A playbook (in my opinion) should do anything it should to, and the end user should not care how to playbook does it.

For example: A playbook called "reboot-service.yml" should restart the service, depending on what the user needs. If I want to restart a tomcat daily, I should be able to tell the playbook "restart service tomcat, on host xyz" - the playbook does the rest. It should not matter if the host itself is oracle linux, ubuntu, debian, or even, windows. Thats where the variables come in play. Without the option in scheduled jobs, you have to maintain many different templates - and if thats too much, even creating another project is counter intutive - because on bigger changes, you have to maintain everything.

DaniiC00kie commented 2 hours ago

I hope I could explain it .. if not, please do not hesitate to contact me :)