[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] question about sudo executed
From: |
Christian Vest Hansen |
Subject: |
Re: [Fab-user] question about sudo executed |
Date: |
Tue, 7 Apr 2009 18:37:32 +0200 |
Yes:
def once():
run('uptime')
def twice():
once()
once()
The skip_executed part only affects commands called through invoke().
def once_invoke():
"same as calling once() once"
invoke(once)
invoke(once)
As demonstrated:
rowe:~$ fab once once
Fabric v. 0.1.1.
Running once...
Logging into the following hosts as vest:
localhost
Password for address@hidden:
[localhost] run: uptime
[localhost] out: 18:35 up 6 days, 22:55, 4 users, load averages: 0.61 0.33 0.22
Running once...
Logging into the following hosts as vest:
localhost
Password for address@hidden:
[localhost] run: uptime
[localhost] out: 18:35 up 6 days, 22:55, 4 users, load averages: 0.64 0.34 0.23
Done.
rowe:~$ fab twice
Fabric v. 0.1.1.
Running twice...
Logging into the following hosts as vest:
localhost
Password for address@hidden:
[localhost] run: uptime
[localhost] out: 18:35 up 6 days, 22:56, 4 users, load averages: 0.61 0.35 0.23
[localhost] run: uptime
[localhost] out: 18:35 up 6 days, 22:56, 4 users, load averages: 0.61 0.35 0.23
Done.
rowe:~$ fab once_invoke
Fabric v. 0.1.1.
Running once_invoke...
Chaining once...
Logging into the following hosts as vest:
localhost
Password for address@hidden:
[localhost] run: uptime
Skipping once (already invoked).
Done.
rowe:~$
On Tue, Apr 7, 2009 at 6:00 PM, Robert Ramírez Vique
<address@hidden> wrote:
> hi,
>
> is there any way to execute again a command which is already executed ? I
> saw the parameter skip_executed=True , but don't know how to set it.
>
> regards,
> Robert Ramírez Vique
> Computer Science Engineer
> Emo Philips - "A computer once beat me at chess, but it was no match for me
> at kick boxing."
>
> On Fri, Apr 3, 2009 at 10:00, Robert Ramírez Vique
> <address@hidden> wrote:
>>
>> thanks Christian, for the really fast response and solution, this works
>> perfectly
>>
>> Robert Ramírez Vique
>> Computer Science Engineer
>> Samuel Goldwyn - "I don't think anyone should write their autobiography
>> until after they're dead."
>>
>> On Thu, Apr 2, 2009 at 22:16, Christian Vest Hansen <address@hidden>
>> wrote:
>>>
>>> As you have learned, sudo() actually constructs a sudo command that
>>> calls bash (or whatever fab_shell is) which then calls your real
>>> command.
>>>
>>> The reason for this round-about way of sudo'ing can be illustrated thus:
>>>
>>> $ sudo echo poke && whoami
>>> poke
>>> vest
>>> $ sudo bash -c "echo poke && whoami"
>>> poke
>>> root
>>>
>>> So we introduce a limitation to what can be expressed in a command by
>>> not going through a shell.
>>>
>>> But, I have pushed a change that will allow you to avoid the shell for
>>> a single sudo command by setting a noshell keyword argument to True:
>>>
>>> sudo('uptime', noshell=True)
>>>
>>> Or, you can turn the shell off for all subsequent calls to sudo by
>>> setting the fab_sudo_noshell variable on config to True:
>>>
>>> config.fab_sudo_noshell=True
>>> sudo('uptime')
>>>
>>> But of these approaches are subject to the limitation described above,
>>> but you can try them out if you fetch the code from the git
>>> repositories. In fact, please do and tell me if you encounter any
>>> other problems.
>>>
>>> 2009/4/2 Robert Ramírez Vique <address@hidden>:
>>> > Hello,
>>> >
>>> > I am trying to execute a sudo command on one server, my problem is that
>>> > in
>>> > the remote server I got this error:
>>> >
>>> > [bronx] sudo: sudo -S -p 'sudo password:' /bin/bash -l -c "uptime"
>>> > [bronx] err: Sorry, user devel is not allowed to execute '/bin/bash -l
>>> > -c
>>> > uptime' as root on bronx.
>>> > Error: The sudo operation failed on bronx.
>>> >
>>> > here is the code of my fabfil:
>>> >
>>> > def test():
>>> > sudo('uptime')
>>> >
>>> > The problem probably is something I've something badly configured
>>> > because
>>> > the system is trying to execute "/bin/bash -l -c uptime", and I have to
>>> > give
>>> > sudo access (in the sudoers file) to the user devel on this command, to
>>> > every command I want to execute, including things like "/bin/bash -l -c
>>> > /etc/init.d/nginx start", "/bin/bash -l -c /etc/init.d/nginx stop",
>>> > "/bin/bash -l -c /etc/init.d/nginx reload" ... The other option is to
>>> > give
>>> > access to /bin/bash, but this is clearly not the correct solution, due
>>> > security issues.
>>> >
>>> > I tried to changing the fab_shell to nothing (''), but then the run
>>> > methods
>>> > don't work. Don't know any other option
>>> >
>>> > I am using the last Fabric 0.1.0 installed with easy_install, on an
>>> > ubuntu
>>> > 8.04
>>> >
>>> > Do you have any idea? any configuration I am missing ?
>>> >
>>> > cheers,
>>> >
>>> > Robert Ramírez Vique
>>> >
>>> > Computer Science Engineer
>>> > Bob Hope - "You know you are getting old when the candles cost more
>>> > than
>>> > the cake."
>>> > _______________________________________________
>>> > Fab-user mailing list
>>> > address@hidden
>>> > http://lists.nongnu.org/mailman/listinfo/fab-user
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Venlig hilsen / Kind regards,
>>> Christian Vest Hansen.
>>
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>
>
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.
- [Fab-user] question about sudo executed, Robert Ramírez Vique, 2009/04/02
- Re: [Fab-user] question about sudo executed, Christian Vest Hansen, 2009/04/02
- Re: [Fab-user] question about sudo executed, Robert Ramírez Vique, 2009/04/03
- Re: [Fab-user] question about sudo executed, Robert Ramírez Vique, 2009/04/07
- Re: [Fab-user] question about sudo executed,
Christian Vest Hansen <=
- Re: [Fab-user] question about sudo executed, Robert Ramírez Vique, 2009/04/07
- Re: [Fab-user] question about sudo executed, Christian Vest Hansen, 2009/04/07
- Message not available
- Re: [Fab-user] question about sudo executed, Robert Ramírez Vique, 2009/04/07
- Re: [Fab-user] question about sudo executed, Jeff Forcier, 2009/04/07
- Re: [Fab-user] question about sudo executed, Robert Ramírez Vique, 2009/04/15
- Re: [Fab-user] question about sudo executed, Robert Ramírez Vique, 2009/04/16
- Re: [Fab-user] question about sudo executed, Robert Ramírez Vique, 2009/04/08