janus-idp / backstage-plugins

Plugins for Backstage
https://janus-idp.io
Apache License 2.0
126 stars 129 forks source link

Create Scaffolder Action to run Ansible playbook #332

Open joshgav opened 1 year ago

joshgav commented 1 year ago

Is your feature request related to a problem? Please describe. I don't have a graphical interface for non-technical users to easily run Ansible playbooks.

Describe the solution you'd like I want to publish Ansible playbooks via a web UI for users to provide a few parameters and run with a click.

Describe alternatives you've considered

Additional context This was requested by an enterprise that uses Ansible for automation and discussed with @serenamarie125 @cooktheryan and @scdaniels

tumido commented 1 year ago

Hi @joshgav, can you please check if there's an overlap with https://github.com/janus-idp/backstage-plugins/issues/189 ? If we're converging to the same solution, we may be able to close one of the issues as duplicate. 🙂

joshgav commented 1 year ago

Hi @tumido, I don't think they're quite the same but I'd like to do a bit of research before replying and hopefully clarify my ask. Thanks!

cooktheryan commented 1 year ago

@joshgav were you thinking of running playbooks with AAP or without?

joshgav commented 11 months ago

With AAP. I'd like to point to an existing playbook registered in AAP and use its vars as fields in a Backstage template. Then when I click "Run" it would run that one-off task.

Thinking about it, it actually wouldn't render any templates, it would just invoke an Ansible playbook.

joshgav commented 11 months ago

I'd like to explicitly contrast this request with the scaffolder template to run a job here: https://github.com/janus-idp/software-templates/tree/main/scaffolder-templates/ansible-job

That template renders a Kubernetes CR to invoke a job and writes it to a git repo, which is reasonable for GitOps-style long-term configuration. But this issue asks for the ability to invoke a job on demand without persisting it anywhere. It probably should be done by directly calling an Ansible API.

cooktheryan commented 11 months ago

@tumido @joshgav this may end up being a wall of text but hopefully it explains where I think we can go. So right now there is a PR that lists job templates within AAP. This func could be extended to list jobs within AAP as it would just be an additional API call and labeling within the catalog. How I believe that we could do this sooner than later would be the following.

joshgav commented 11 months ago

@cooktheryan a custom action to invoke the Ansible API with the parameters from a template as the vars values would be great, yes. :tada:

Also yes, it would be great to list the job runs. That could be a way for users to observe job runs too - for example, after triggering the action we could redirect the browser to the JobRuns view. It would also parallel the Tekton plugin which focuses on PipelineRuns as opposed to Pipelines.

As we've been chatting today I realized it would be nice for users to be able to invoke a one-off job straight from the Job Template entity page, as it seems that's where a user would actually discover them. Something to think about.

cooktheryan commented 11 months ago

after talking with @tumido this is available https://roadie.io/backstage/plugins/scaffolder-http-requests/