Hi Brandon,

$cat fabfile.py
from fabric import task, Connection

@task
def check_kernel_version(c):
    password = 'dac@123'
    connect_kwargs = {'password': password}
    connection = Connection(host="192.168.0.188", user="root",
connect_kwargs=connect_kwargs)
    result = connection.run('uname -a')

$ fab check-kernel-version
Linux learnpython 3.10.0-1160.24.1.el7.x86_64 #1 SMP Thu Apr 8 19:51:47 UTC
2021 x86_64 x86_64 x86_64 GNU/Linux
$

Thanks Brandon for the email and it worked like a charm. I have one
more question, Can I have multiple fabfile.py files for executing multiple
tasks?

For example :- fabfile1.py , fabfile2.py, fabfile3.py ...... to
execute multiple tasks on multiple servers.

Please correct me. I look forward to hearing from you.

Thanks in advance.

Best Regards,

Kaushal

On Fri, Apr 16, 2021 at 10:48 PM Brandon Whaley <[email protected]> wrote:

> You should read up on what a task is and how the command line tool uses
> them.
>
>
> https://docs.fabfile.org/en/2.6/getting-started.html#addendum-the-fab-command-line-tool
>
> On Fri, Apr 16, 2021, 12:59 Kaushal Shriyan <[email protected]>
> wrote:
>
>> Hi Brandon,
>>
>> I have created the below fabfile.py.
>>
>> $ cat fabfile.py
>> from fabric import task, Connection
>>
>> password = 'test#@!123'
>> connect_kwargs = {'password': password}
>> connection = Connection(host="192.168.0.168", user="root",
>> connect_kwargs=connect_kwargs)
>> result = connection.run('uname -a')
>> $
>> $fab result
>> Linux learnpython 3.10.0-1160.24.1.el7.x86_64 #1 SMP Thu Apr 8 19:51:47
>> UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
>> No idea what 'result' is!
>> $
>>
>> I am facing No idea what 'result' is! issue. I am sure I am missing the
>> configuration in the fabfile.py file. Please correct me. I look forward to
>> hearing from you.
>>
>> Thanks in advance.
>>
>> Best Regards,
>>
>> On Fri, Apr 16, 2021 at 12:36 PM Kaushal Shriyan <
>> [email protected]> wrote:
>>
>>> Thanks Brandon for the email and it worked like a charm. Appreciate your
>>> help !!!
>>>
>>> On Thu, Apr 15, 2021 at 10:52 PM Brandon Whaley <[email protected]>
>>> wrote:
>>>
>>>> ```
>>>> >>> connection = Connection(host="192.168.0.188", user="root", port=22,
>>>> connect_kwargs={"password":"test@#!123"})
>>>> >>> result = connection.run('uname -a')
>>>> ```
>>>>
>>>> On Thu, Apr 15, 2021 at 1:20 PM Kaushal Shriyan
>>>> <[email protected]> wrote:
>>>> >
>>>> >
>>>> > On Thu, Apr 15, 2021 at 9:14 PM Brandon Whaley <[email protected]>
>>>> wrote:
>>>> >>
>>>> >> The connection object you're making is just a dictionary. Those keys
>>>> should be keyword arguments to the Connection constructor you imported.
>>>> >>
>>>> >
>>>> > Thanks  Brandon for the email. I am not sure if I completely
>>>> understood it. Please help me understand with some examples. Thanks in
>>>> advance.
>>>> >
>>>> > Best Regards,
>>>> >
>>>> > Kaushal
>>>> >
>>>> >
>>>>
>>>

Reply via email to