Fabric as a WebApp

144 views
Skip to first unread message

Abdul Qoyyuum Haji Abdul Kadir (Agent Q)

unread,
Sep 29, 2024, 10:43:11 PMSep 29
to Django users
Hi all,

I'm working on a Django project that puts Fabric into a webpage. The idea is simple, make a Fabric task that automates remote code execution from a webpage to authenticated/connected/authorized servers/machines/switches with a click of a button on a webpage with Fabric.

Example usage and quick tutorial on how to use the Fabric package: FabFile Tutorial — Qoyyuum (buymeacoffee.com)

This idea works but up to the point where I really need to respond to the commands executed on server-side (e.g. confirmation or it awkwardly re-prompting for sudo password). The webpage doesn't get this prompt for me to respond to, or rather, it won't stream the output from server side to django view side, enabling interactivity.

Some suggested to use Async but I have no idea how to apply this: Asynchronous support | Django documentation | Django (djangoproject.com) 

If anyone can explain how to apply Async (or other solution) to enable interactivity to an automation script, I appreciate it. Thanks. 

Obodoma Uzondu Vincent

unread,
Sep 30, 2024, 7:09:25 AMSep 30
to django...@googlegroups.com
Use celery. It is easy to implement. 
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/21c986b4-0eb9-4454-86ea-fd0486973843n%40googlegroups.com.

Abdul Qoyyuum Haji Abdul Kadir

unread,
Sep 30, 2024, 9:04:26 AMSep 30
to django...@googlegroups.com
Thanks. Can you explain a little bit more on how celery can help stream the output prompts from Fabric commands for me to input them, so that it continues its process?

E.g. of a Fabric task where we need to get the latest git commit of a puppet configuration (this will prompt for the root password):

from fabric import task

@task
def get_latest_git_commit_puppet(context):
    context.run("su -c 'cd /etc/puppet && git rev-parse --short HEAD~2'")


On Mon, 30 Sept 2024 at 19:09, Obodoma Uzondu Vincent <uobod...@gmail.com> wrote:
Use celery. It is easy to implement. 

On Monday, September 30, 2024, Abdul Qoyyuum Haji Abdul Kadir (Agent Q) <abdul....@gmail.com> wrote:
Hi all,

I'm working on a Django project that puts Fabric into a webpage. The idea is simple, make a Fabric task that automates remote code execution from a webpage to authenticated/connected/authorized servers/machines/switches with a click of a button on a webpage with Fabric.

Example usage and quick tutorial on how to use the Fabric package: FabFile Tutorial — Qoyyuum (buymeacoffee.com)

This idea works but up to the point where I really need to respond to the commands executed on server-side (e.g. confirmation or it awkwardly re-prompting for sudo password). The webpage doesn't get this prompt for me to respond to, or rather, it won't stream the output from server side to django view side, enabling interactivity.

Some suggested to use Async but I have no idea how to apply this: Asynchronous support | Django documentation | Django (djangoproject.com) 

If anyone can explain how to apply Async (or other solution) to enable interactivity to an automation script, I appreciate it. Thanks. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACsKspmYA9xsX_O0joMewFAP-03gyceFn1EhGx-a5vTdyK6UPQ%40mail.gmail.com.


--
Abdul Qoyyuum Bin Haji Abdul Kadir
Nickname: Q

Hernan Gustavo

unread,
Sep 30, 2024, 11:46:16 AMSep 30
to django...@googlegroups.com
To resolve the task to apply async calls on this app using celery it's more easy. You can use the apply_async method to resolve this issue.

Abdul Qoyyuum Haji Abdul Kadir

unread,
Sep 30, 2024, 8:13:26 PMSep 30
to django...@googlegroups.com
I still don't understand. Can you explain with a code example?

Jonah Katz

unread,
Oct 3, 2024, 1:47:06 PMOct 3
to Django users
You should try using the Django AI Chat Assistant in VS Code. Can be pretty helpful with these kinds of things  https://marketplace.visualstudio.com/items?itemName=buildwithlayer.django-integration-expert-Gus30
The contents of this email are intended for the named addressee only. It
contains information that may be confidential and which may also be
privileged. Unless you are the named addressee (or authorized to receive for
the addressee) you may not copy or use it, or disclose it to anyone else.
If you received it in error please immediately notify the sender by
telephone or by electronic mail and then destroy it.
Reply all
Reply to author
Forward
0 new messages