mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 14:01:42 -07:00
fix: format
This commit is contained in:
parent
b2583960c0
commit
ab11857bc0
1 changed files with 19 additions and 10 deletions
|
@ -161,23 +161,25 @@ class Connection(ConnectionBase):
|
||||||
|
|
||||||
return process.returncode, stdout, stderr
|
return process.returncode, stdout, stderr
|
||||||
|
|
||||||
|
|
||||||
def _get_remote_uid_gid(self) -> tuple[int, int]:
|
def _get_remote_uid_gid(self) -> tuple[int, int]:
|
||||||
"""Get the user and group id of 'remote_user' from the instance."""
|
"""Get the user and group id of 'remote_user' from the instance."""
|
||||||
|
|
||||||
rc, uid_out, err = self.exec_command("/bin/id -u")
|
rc, uid_out, err = self.exec_command("/bin/id -u")
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
raise AnsibleError(f"Failed to get remote uid for user {self.get_option('remote_user')}: {err}")
|
raise AnsibleError(
|
||||||
|
f"Failed to get remote uid for user {self.get_option('remote_user')}: {err}"
|
||||||
|
)
|
||||||
uid = uid_out.strip()
|
uid = uid_out.strip()
|
||||||
|
|
||||||
rc, gid_out, err = self.exec_command("/bin/id -g")
|
rc, gid_out, err = self.exec_command("/bin/id -g")
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
raise AnsibleError(f"Failed to get remote gid for user {self.get_option('remote_user')}: {err}")
|
raise AnsibleError(
|
||||||
|
f"Failed to get remote gid for user {self.get_option('remote_user')}: {err}"
|
||||||
|
)
|
||||||
gid = gid_out.strip()
|
gid = gid_out.strip()
|
||||||
|
|
||||||
return int(uid), int(gid)
|
return int(uid), int(gid)
|
||||||
|
|
||||||
|
|
||||||
def put_file(self, in_path, out_path):
|
def put_file(self, in_path, out_path):
|
||||||
""" put a file from local to lxd """
|
""" put a file from local to lxd """
|
||||||
super(Connection, self).put_file(in_path, out_path)
|
super(Connection, self).put_file(in_path, out_path)
|
||||||
|
@ -193,13 +195,20 @@ class Connection(ConnectionBase):
|
||||||
|
|
||||||
uid, gid = (-1, -1)
|
uid, gid = (-1, -1)
|
||||||
if self.get_option("remote_user") != "root":
|
if self.get_option("remote_user") != "root":
|
||||||
uid, gid = self._get_remote_uid_gid()
|
uid, gid = self._get_remote_uid_gid()
|
||||||
|
|
||||||
local_cmd.extend([
|
local_cmd.extend(
|
||||||
"file", "push", "--uid", str(uid), "--gid", str(gid),
|
[
|
||||||
in_path,
|
"file",
|
||||||
f"{self.get_option('remote')}:{self._host()}/{out_path}"
|
"push",
|
||||||
])
|
"--uid",
|
||||||
|
str(uid),
|
||||||
|
"--gid",
|
||||||
|
str(gid),
|
||||||
|
in_path,
|
||||||
|
f"{self.get_option('remote')}:{self._host()}/{out_path}",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
self._display.vvvvv(f"PUT COMMAND {local_cmd}", host=self._host())
|
self._display.vvvvv(f"PUT COMMAND {local_cmd}", host=self._host())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue