Skip to content

Commit

Permalink
Fixed issue where policy server IP was not printed in info command
Browse files Browse the repository at this point in the history
sudo is already used / needed for other parts of cf-remote
(such as cf-remote install and deploy), so attempting to use it
here should be acceptable.

Ticket: CFE-4361
Signed-off-by: Ole Herman Schumacher Elgesem <[email protected]>
  • Loading branch information
olehermanse committed Apr 9, 2024
1 parent 734973d commit 5194b24
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cf_remote/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ def get_info(host, *, users=None, connection=None):
data["policy_server"] = ssh_cmd(
connection, "cat /var/cfengine/policy_server.dat"
)
if user != "root" and not data["policy_server"]:
# If we are not SSHing as root and we failed to read
# the policy_server.dat file try again using sudo:
data["policy_server"] = ssh_sudo(
connection, "cat /var/cfengine/policy_server.dat"
)

agent = r"/var/cfengine/bin/cf-agent"
data["agent"] = agent
Expand Down

0 comments on commit 5194b24

Please sign in to comment.