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

Custom actions stanza #15713

Closed
davidlublink opened this issue Jan 6, 2023 · 6 comments
Closed

Custom actions stanza #15713

davidlublink opened this issue Jan 6, 2023 · 6 comments
Assignees
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/actions Nomad Task Actions theme/allocation API theme/ui type/enhancement

Comments

@davidlublink
Copy link

When I go into the nomad web interface I have the options 'stop' and 'restart alloc', and 'exec'. I propose a new stanza that will allow adding arbitrary/custom buttons to any job/group/task

/*
Use case ideas 1 : Asterisk reloads
*/
 action "Reload" {
    command = "/usr/bin/asterisk"
    args = [ "-r", "-x", "core reload" ]
  }

 action "SIP Reload" {
    command = "/usr/bin/asterisk"
    args = [ "-r", "-x", "sip reload" ]
  }
/* 
Use case idea 2 : Minecraft server, leave it running but signal no new joins
*/
 action "Stop New Players" {
    command = "/opt/bin/minecraft"
    args = [ "-x", "banana" ]
  }

 action "Allow New Players" {
    command = "/opt/bin/minecraft"
    args = [ "-Z", "banana" ]
  }


/* 
Use case idea 3 : Quick access to consoles

In this case you can imagine that an interactive window ( like exec ) would appear, but with a different command entered.
*/

 action "Asterisk Console" {
    command = "/opt/bin/asterisk"
    args = [ "-r" ]
    interactive = true
  }
/* Use case idea 4: Having a website that is 'open' and 'closed' */
 action "Close Service" {
    command = "rm"
    args = [ "/opt/service-open" ]
    interactive = true
  }

 action "Open Service" {
    command = "touch"
    args = [ "/opt/service-closed" ]
    interactive = true
  }
@tgross
Copy link
Member

tgross commented Jan 9, 2023

Hi @davidlublink! This is interesting because it's kind of like a scoped-down nomad alloc exec. With the alloc-exec ACL users can run arbitrary commands in the allocation, including the via the web UI. But this proposal would limit that to a particular set of commands -- what's you're thinking around how the ACL policy for this sort of thing might work?

@davidlublink
Copy link
Author

davidlublink commented Jan 11, 2023

This is interesting because it's kind of like a scoped-down nomad alloc exec. With the alloc-exec ACL users can run arbitrary commands in the allocation, including the via the web UI. But this proposal would limit that to a particular set of commands -- what's you're thinking around how the ACL policy for this sort of thing might work?

Not just scoped-down, but predefined. The real selling point here is that since it's predefined, an operator can trigger an action without worrying about typing the command right.

For ACL, I would suggest a new ACL 'alloc-exec-preconfigured' that would allow you to execute any preconfigured action, but not necessarily run an arbitrary action. With this ACL, and not alloc-exec, running the command would not allow any changes to the command itself, but would allow interacting with the output ( if it launchs a mysql terminal, I can run commands on it, but if I exit the mysql client, the connection to the allocation ends. )

If you have the ACL alloc-exec, you would be able to not only run the preconfigured commands, but possibly modify ( one time ) the parameters run, so it becomes like alloc-exec with a default command.

So alloc-exec would imply alloc-exec-preconfigured.

@falsaform
Copy link

falsaform commented Feb 14, 2023

Highly recommend adding this as a feature, we have a few Django sites where we would love to have the ability to be able to run preconfigured actions ondemand, actions triggerable from the nomad gui and via api calls, such as clearing a cache or performing a backup of a DB /media before a deployment.

@philrenaud philrenaud self-assigned this Feb 21, 2023
@philrenaud philrenaud linked a pull request Feb 23, 2023 that will close this issue
@mikenomitch
Copy link
Contributor

Hey all, just FYI that we're planning to do this hopefully as part of the 1.7 release. Thanks for the suggestion!

@davidlublink
Copy link
Author

I looked at the videos and examples in #16249, it looks great!

Looking forward to trying it out. Great work!

@philrenaud philrenaud added theme/actions Nomad Task Actions stage/accepted Confirmed, and intend to work on. No timeline committment though. and removed stage/needs-discussion labels Oct 31, 2023
@josegonzalez
Copy link
Contributor

Should this be closed now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/accepted Confirmed, and intend to work on. No timeline committment though. theme/actions Nomad Task Actions theme/allocation API theme/ui type/enhancement
Projects
Status: 1.7 - Beta (ETA October 31)
Development

Successfully merging a pull request may close this issue.

6 participants