diff mbox series

[v2,07/12] update_ssh_config: make Include directive follow ssh config directory

Message ID 20250205155252.1317763-8-cel@kernel.org (mailing list archive)
State New
Headers show
Series Replace terraform update_ssh_config module | expand

Commit Message

Chuck Lever Feb. 5, 2025, 3:52 p.m. UTC
From: Chuck Lever <chuck.lever@oracle.com>

The file containing the kdevops target node entries needs to be
placed in the same directory as the controller's .ssh/config.
Usually that's ~/.ssh/config, but there is a Kconfig setting that
can change that.

XXX: Actually, to make this work 100% correctly, "make mrproper"
should remove the ssh Include directive. That way a user can modify
the ssh config via "make menuconfig", then do a "make" to get the
updated include path added into her .ssh/config.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 .../roles/update_ssh_config/tasks/main.yml     | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

Comments

Chuck Lever Feb. 6, 2025, 7:58 p.m. UTC | #1
On 2/5/25 10:52 AM, cel@kernel.org wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
> 
> The file containing the kdevops target node entries needs to be
> placed in the same directory as the controller's .ssh/config.
> Usually that's ~/.ssh/config, but there is a Kconfig setting that
> can change that.
> 
> XXX: Actually, to make this work 100% correctly, "make mrproper"
> should remove the ssh Include directive. That way a user can modify
> the ssh config via "make menuconfig", then do a "make" to get the
> updated include path added into her .ssh/config.
> 
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  .../roles/update_ssh_config/tasks/main.yml     | 18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/playbooks/roles/update_ssh_config/tasks/main.yml b/playbooks/roles/update_ssh_config/tasks/main.yml
> index 417781936f7f..72c5f2e365f5 100644
> --- a/playbooks/roles/update_ssh_config/tasks/main.yml
> +++ b/playbooks/roles/update_ssh_config/tasks/main.yml
> @@ -5,18 +5,7 @@
>      path: "{{ sshconfig }}"
>    register: ssh_config
>  
> -- name: Check that the kdevops Include directive is present
> -  tags: deps
> -  ansible.builtin.lineinfile:
> -    path: "{{ sshconfig }}"
> -    regexp: "Include ~/.ssh/config_kdevops_*"
> -    state: absent
> -  check_mode: true
> -  changed_when: false
> -  register: kdevops_ssh_include
> -  when: ssh_config.stat.exists
> -
> -- name: Check that the Include directive has a kdevops_version comment
> +- name: Check for a kdevops_version comment

One minor misbehavior I noticed while working on this series is that if
I use "make defconfig-yada", it doesn't populate the kdevops_version
variable. Looks like the defconfig-* target does not build
include/config/project.release , so kdevops_version is an empty string
in that case.

"make defconfig-yada menuconfig" works fine, though.


>    tags: deps
>    ansible.builtin.lineinfile:
>      path: "{{ sshconfig }}"
> @@ -34,10 +23,9 @@
>    ansible.builtin.meta: end_play
>    when:
>      - ssh_config.stat.exists
> -    - kdevops_ssh_include.found
>      - fixed_ssh_entry.found
>  
> -- name: Remove the stale Include directive
> +- name: Remove any stale Include directives
>    tags: deps
>    ansible.builtin.lineinfile:
>      path: "{{ sshconfig }}"
> @@ -73,4 +61,4 @@
>      create: true
>      mode: "u=rw,g=r,o=r"
>      block: |
> -      Include ~/.ssh/config_kdevops_*
> +      Include {{ sshdir }}/config_kdevops_*
diff mbox series

Patch

diff --git a/playbooks/roles/update_ssh_config/tasks/main.yml b/playbooks/roles/update_ssh_config/tasks/main.yml
index 417781936f7f..72c5f2e365f5 100644
--- a/playbooks/roles/update_ssh_config/tasks/main.yml
+++ b/playbooks/roles/update_ssh_config/tasks/main.yml
@@ -5,18 +5,7 @@ 
     path: "{{ sshconfig }}"
   register: ssh_config
 
-- name: Check that the kdevops Include directive is present
-  tags: deps
-  ansible.builtin.lineinfile:
-    path: "{{ sshconfig }}"
-    regexp: "Include ~/.ssh/config_kdevops_*"
-    state: absent
-  check_mode: true
-  changed_when: false
-  register: kdevops_ssh_include
-  when: ssh_config.stat.exists
-
-- name: Check that the Include directive has a kdevops_version comment
+- name: Check for a kdevops_version comment
   tags: deps
   ansible.builtin.lineinfile:
     path: "{{ sshconfig }}"
@@ -34,10 +23,9 @@ 
   ansible.builtin.meta: end_play
   when:
     - ssh_config.stat.exists
-    - kdevops_ssh_include.found
     - fixed_ssh_entry.found
 
-- name: Remove the stale Include directive
+- name: Remove any stale Include directives
   tags: deps
   ansible.builtin.lineinfile:
     path: "{{ sshconfig }}"
@@ -73,4 +61,4 @@ 
     create: true
     mode: "u=rw,g=r,o=r"
     block: |
-      Include ~/.ssh/config_kdevops_*
+      Include {{ sshdir }}/config_kdevops_*