diff mbox series

[v2,02/12] update_ssh_config: Use {{ sshconfig }} instead of raw path

Message ID 20250205155252.1317763-3-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 sshconfig variable is set by Kconfig. The update_ssh_config role
needs to follow that setting, but was using a fixed "~/.ssh/config"
string instead.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 .../roles/update_ssh_config/tasks/main.yml    | 23 ++++++++-----------
 1 file changed, 10 insertions(+), 13 deletions(-)
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 98c86f164612..01fac9fbb69e 100644
--- a/playbooks/roles/update_ssh_config/tasks/main.yml
+++ b/playbooks/roles/update_ssh_config/tasks/main.yml
@@ -1,12 +1,12 @@ 
-- name: Check if the ssh config file exists
+- name: Check that the controller's ssh config file exists
   stat:
-    path: "~/.ssh/config"
+    path: "{{ sshconfig }}"
   register: ssh_config
 
 # Check if the include directive is already presetn
 - name: Check if the kdevops include directive was used
   lineinfile:
-    path: ~/.ssh/config
+    path: "{{ sshconfig }}"
     regexp: "Include ~/.ssh/config_kdevops_*"
     state: absent
   check_mode: yes
@@ -17,7 +17,7 @@ 
 # Check if the the kdevops_version was added in a comment
 - name: Check if the new include directive was used with a kdevops_version comment
   lineinfile:
-    path: ~/.ssh/config
+    path: "{{ sshconfig }}"
     regexp: "^#(.*)kdevops_version(.*)"
     state: absent
   check_mode: yes
@@ -34,34 +34,31 @@ 
     - kdevops_ssh_include.found
     - fixed_ssh_entry.found
 
-# If we're still running it means the correct include directive following a new
-# line was not found. So remove old stale include directives which may be
-# buggy.
-- name: Remove buggy stale include directive to ~/.ssh/config without a new line
+- name: Remove the stale Include directive
   lineinfile:
-    path: ~/.ssh/config
+    path: "{{ sshconfig }}"
     line: "Include ~/.ssh/config_kdevops_*"
     state: absent
   when: ssh_config.stat.exists
 
 - name: Remove any stale kdevops comments
   lineinfile:
-    path: ~/.ssh/config
+    path: "{{ sshconfig }}"
     regexp: "^#(.*)kdevops(.*)"
     state: absent
   when: ssh_config.stat.exists
 
 - name: Remove any extra new lines
   replace:
-    path: ~/.ssh/config
+    path: "{{ sshconfig }}"
     regexp: '(^\s*$)'
     replace: ''
   when: ssh_config.stat.exists
 
 # ssh include directives must follow a new line.
-- name: Add Include directive to ~/.ssh/config
+- name: Add a proper Include directive to {{ sshconfig }}
   blockinfile:
-    path: ~/.ssh/config
+    path: "{{ sshconfig }}"
     insertbefore: BOF
     marker: "{mark}"
     marker_begin: "# Automatically added by kdevops\n# kdevops_version: {{ kdevops_version }}"