From: Chuck Lever <cel@kernel.org>
To: <kdevops@lists.linux.dev>
Cc: Chuck Lever <chuck.lever@oracle.com>
Subject: [PATCH v1 1/6] ansible.cfg: Allow the use of alternate ssh ports
Date: Thu, 2 Oct 2025 16:21:35 -0400 [thread overview]
Message-ID: <20251002202140.3596787-2-cel@kernel.org> (raw)
In-Reply-To: <20251002202140.3596787-1-cel@kernel.org>
From: Chuck Lever <chuck.lever@oracle.com>
Users can now configure the Anisble SSH port via a new Kconfig menu
option. The default remains port 22 (standard SSH) to avoid breaking
existing setups. This configuration setting applies globally to all
hosts in the Ansible inventory.
The new port setting is not used yet. The review concern is whether
the proposed new Kconfig option is the best user interface for this
setting.
Generated-by: Claude AI
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
kconfigs/Kconfig.ansible_cfg | 41 +++++++++++++++++++
.../ansible_cfg/templates/ansible.cfg.j2 | 3 ++
2 files changed, 44 insertions(+)
diff --git a/kconfigs/Kconfig.ansible_cfg b/kconfigs/Kconfig.ansible_cfg
index c04532e818b1..e3fd02f18d2d 100644
--- a/kconfigs/Kconfig.ansible_cfg
+++ b/kconfigs/Kconfig.ansible_cfg
@@ -316,6 +316,47 @@ config ANSIBLE_CFG_INVENTORY
endif # ANSIBLE_CFG_INVENTORY_CUSTOM
+config ANSIBLE_CFG_SSH_PORT_SET_BY_CLI
+ bool
+ default $(shell, scripts/check-cli-set-var.sh ANSIBLE_CFG_SSH_PORT)
+
+config ANSIBLE_CFG_SSH_PORT_CUSTOM
+ bool "Enable a custom Ansible SSH port setting"
+ default n
+ help
+ When this setting is enabled, specify the SSH port for
+ Ansible to use when connecting to target nodes.
+
+ When this setting is disabled, kdevops uses the default
+ SSH port (22), which can be overridden with
+ "ANSIBLE_CFG_SSH_PORT=NN" on the "make" command line.
+
+ This is useful when your target hosts use a non-standard
+ SSH port for security or network configuration reasons.
+
+if ANSIBLE_CFG_SSH_PORT_CUSTOM
+
+config ANSIBLE_CFG_SSH_PORT
+ int "Ansible SSH port"
+ output yaml
+ help
+ Set the SSH port for Ansible to use when connecting to target
+ nodes. The default port is 22.
+
+ https://docs.ansible.com/ansible/latest/collections/ansible/builtin/ssh_connection.html#parameter-remote_port
+
+endif # ANSIBLE_CFG_SSH_PORT_CUSTOM
+
+if !ANSIBLE_CFG_SSH_PORT_CUSTOM
+
+config ANSIBLE_CFG_SSH_PORT
+ int
+ output yaml
+ default 22 if !ANSIBLE_CFG_SSH_PORT_SET_BY_CLI
+ default $(shell, ./scripts/append-makefile-vars-int.sh $(ANSIBLE_CFG_SSH_PORT)) if ANSIBLE_CFG_SSH_PORT_SET_BY_CLI
+
+endif # !ANSIBLE_CFG_SSH_PORT_CUSTOM
+
if DISTRO_OPENSUSE
config ANSIBLE_CFG_RECONNECTION_RETRIES
diff --git a/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 b/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2
index f3f6c723f937..deb1a559dc2c 100644
--- a/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2
+++ b/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2
@@ -47,7 +47,10 @@ playbook_on_stats_msg_color = bright green
[callback_profile_tasks]
summary_only = true
{% endif %}
+[ssh_connection]
+remote_port = {{ ansible_cfg_ssh_port }}
{% if ansible_facts['distribution'] == 'openSUSE' %}
+
[connection]
retries = {{ ansible_cfg_reconnection_retries }}
{% endif %}
--
2.51.0
next prev parent reply other threads:[~2025-10-02 20:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-02 20:21 [PATCH v1 0/6] Enable users to set an alternate ssh port Chuck Lever
2025-10-02 20:21 ` Chuck Lever [this message]
2025-10-02 20:21 ` [PATCH v1 2/6] base_image: Make the semanage command available on base images Chuck Lever
2025-10-02 20:21 ` [PATCH v1 3/6] guestfs: Refactor the construction of the virt-sysprep command line Chuck Lever
2025-10-02 20:21 ` [PATCH v1 4/6] guestfs: Use the alternate ssh port for Ansible control Chuck Lever
2025-10-02 20:21 ` [PATCH v1 5/6] terraform: Hoist the AWS cloud-init script into terraform/ Chuck Lever
2025-10-02 20:21 ` [PATCH v1 6/6] terraform: Use the alternate ssh port for Ansible control Chuck Lever
2025-10-02 20:25 ` Chuck Lever
2025-10-03 0:50 ` [PATCH v1 0/6] Enable users to set an alternate ssh port Luis Chamberlain
2025-10-03 13:44 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251002202140.3596787-2-cel@kernel.org \
--to=cel@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=kdevops@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox