Closed GoogleCodeExporter closed 8 years ago
In general, it seems that this information should be available on the host.
For example, would the following command be suitable?
pssh -h pssh_hosts.txt -l root -v -o out -e err 'sed -i
"s/foobar.example.com/$(hostname -s)/g" /etc/apticron/apticron.conf'
Or is the output of `hostname -s` different than the name to which pssh is
connecting?
Original comment by amcna...@gmail.com
on 19 Jan 2012 at 11:16
We're using EC2, so hostname -s and hostname -f both show the internal IP.
We'd rather show the external IP or external FQDN.
Original comment by phi...@armorgames.com
on 19 Jan 2012 at 11:19
That makes sense. So, it turns out that this is a terrifically easy feature to
add. Would you mind testing the attached patch? If it works, I'll commit it
right away.
Thanks.
Original comment by amcna...@gmail.com
on 19 Jan 2012 at 11:25
Attachments:
I made the change, deleted /usr/local/bin/pssh, and re-ran the install command,
then tried something simple:
pssh -h pssh_hosts.txt -l root -v -o out -e err "echo $PSSH_HOST"
Ran it, and the response was a series of blank lines.
Ran:
pssh -h pssh_hosts.txt -l root -v -o out -e err "set | grep PSSH"
Response was a series of lines, all the same:
BASH_EXECUTION_STRING='set | grep PSSH'
(Which means the PSSH_NODENUM is not being created as an environment variable
on the connected-to-host either...)
Ran:
pssh -h pssh_hosts.txt -l root -v -o out -e err "set | grep BASH"
Output was the following repeated:
BASH=/bin/bash
BASHOPTS=cmdhist:extquote:force_fignore:hostcomplete:interactive_comments:progco
mp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_EXECUTION_STRING='set | grep BASH'
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="1" [2]="5" [3]="1" [4]="release"
[5]="x86_64-pc-linux-gnu")
BASH_VERSION='4.1.5(1)-release'
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_EXECUTION_STRING='set | grep BASH'
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="2" [2]="39" [3]="1" [4]="release"
[5]="i486-pc-linux-gnu")
BASH_VERSION='3.2.39(1)-release'
(which means that the 'set | grep' command does work)
as does:
pssh -h AllEC2Hosts.txt -l root -v -o out -e err "echo $BASH"
Result, repeated several times:
/bin/bash
(so the 'echo' command also works)
Did you try the same patch on your configuration? Why would mine fail and your
succeed? We use Debian 5 & 6.
Original comment by phi...@armorgames.com
on 20 Jan 2012 at 2:01
You have a few interesting things going on here.
1) pssh -h pssh_hosts.txt -l root -v -o out -e err "echo $PSSH_HOST"
In this case, the PSSH_HOST environment variable is being evaluated on your
local machine rather than the remote host. If you change the double quotes to
single quotes, it will make it evaluate on the remote host.
2) After actually testing this change myself, I noticed that I had omitted an
important change. In bin/pssh, the line with "SendEnv" should be changed to
"'-o', 'SendEnv=PSSH_NODENUM PSSH_HOST']". You can either change this by hand,
or you can grab commit 6631acf, which contains both of the changes associated
with this issue. My apologies for not taking the time to test the change
earlier.
3) I believe that you are also running into a problem with sshd trimming down
the environment on the remote host. In my sshd_config, I have "AcceptEnv
PSSH_NODENUM PSSH_HOST", which instructs sshd to allow these variables to pass
through. I will add a comment about this to the pssh.1 man page.
Thanks for your patience and your thorough report which helped me to track
these issues down very quickly.
Can you confirm that
Original comment by amcna...@gmail.com
on 23 Jan 2012 at 5:04
Sorry, my post cut off at the end.
Can you confirm that the feature works after making the change to bin/ssh,
updating the sshd_config, and making sure to use single quotes?
Thanks.
Original comment by amcna...@gmail.com
on 23 Jan 2012 at 5:32
Success! Using (1) single quotes, (2) git pull, (3) modified sshd_config, I
was able to echo back $PSSH_HOST.
Thanks!
Original comment by phi...@armorgames.com
on 23 Jan 2012 at 5:53
Great. I'll mark this as done, and it will end up in the next release of pssh.
Thanks for your participation and help.
Original comment by amcna...@gmail.com
on 23 Jan 2012 at 6:36
Original issue reported on code.google.com by
phi...@armorgames.com
on 19 Jan 2012 at 10:34