Debian Codegraph @

ansible_collections/community/general/plugins/module_utils/_ssh.py

raw
1 # Copyright (c) 2015, Björn Andersson
2 # Copyright (c) 2021, Ansible Project
3 # Copyright (c) 2021, Abhijeet Kasurde <[email protected]>
4 # Copyright (c) 2022, Alexei Znamensky <[email protected]>
5 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
6 # SPDX-License-Identifier: GPL-3.0-or-later
7
8 # Note that this module util is **PRIVATE** to the collection. It can have breaking changes at any time.
9 # Do not use this from other collections or standalone plugins/modules!
10
11 from __future__ import annotations
12
13 import os
14
15
16 def determine_config_file(user: str | None, config_file: str | None) -> str:
17 if user:
18 config_file = os.path.join(os.path.expanduser(f"~{user}"), ".ssh", "config")
19 elif config_file is None:
20 config_file = "/etc/ssh/ssh_config"
21 return config_file