Skip to content

Commit

Permalink
fix(ssh.upload): fix wrong connection string when using use_remote_su…
Browse files Browse the repository at this point in the history
…do and user (pyinfra-dev#623)

Fixes the ssh connection string when setting the use_remote_sudo and user options for the ssh.upload operation

Before:
```json
[
  "scp -P 22 local_filename [email protected]:_tempfile_",
  "ssh -p 22 test@[email protected] 'sudo mv _tempfile_ local_filename'"
]
```

After:
```json
[
  "scp -P 22 local_filename [email protected]:_tempfile_",
  "ssh -p 22 [email protected] 'sudo mv _tempfile_ local_filename'"
]
```
  • Loading branch information
GerardoGR authored Jul 15, 2021
1 parent bbb2694 commit 4e30aaf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyinfra/operations/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def upload(

# And sudo sudo to move it
yield command(
hostname=connection_target,
hostname=hostname,
command='sudo mv {0} {1}'.format(temp_remote_filename, remote_filename),
port=port,
user=user,
Expand Down
12 changes: 12 additions & 0 deletions tests/operations/ssh.upload/upload_remote_sudo_user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"args": ["remote-host.net", "local_filename"],
"kwargs": {
"user": "test",
"use_remote_sudo": true
},
"commands": [
"scp -P 22 local_filename [email protected]:_tempfile_",
"ssh -p 22 [email protected] 'sudo mv _tempfile_ local_filename'"
],
"idempotent": false
}

0 comments on commit 4e30aaf

Please sign in to comment.