From patchwork Wed Feb 5 15:52:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13961407 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18DDD18FDA5 for ; Wed, 5 Feb 2025 15:52:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738770776; cv=none; b=pmjUdXjvhh7dIi4/81TpKPpxTAuBE5CwZqVL6Tmrs4GSqZSRFK9tfI/Z4fzwpdq7z+eGVAOG7x9pi6W8jZNRHHYV6rPz5/AgCJa+5wRaYOt1RXVDYGuHzDjGjzX1En3P35pZX9z02rkr0fojjftMfbK25P6O5vZ9Mui7nYqvNF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738770776; c=relaxed/simple; bh=WW8f0pXVp45nhgDuK3os6gNZ61V+QFcbZBHLwQO11Uw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h07K1Fc6oSF8BK+UM5SyQlcQczQZ0xhGSdtv6VsJHFozz5P8tiu94zzAW5cW2LRhWwl6aSSR2wJdTWj3BT+L5Cmkvu/3sWMyx+BPvGIADYYFFA45JuDmts8stJ3CRcBcJvGsRHg7fqlaJPbOW4KrhNcrRACag9I9rX5dPNztJ6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E4dMy8dM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E4dMy8dM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7B11C4CED6; Wed, 5 Feb 2025 15:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738770776; bh=WW8f0pXVp45nhgDuK3os6gNZ61V+QFcbZBHLwQO11Uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E4dMy8dM0iV9bMjyODLLpnOksWFdKD7J8jJfrRv1l25K7kuupLPEHKBWk5Cv49UBD dvgDkmh/NlWunk0GhNhUTEFmFXOcTXGzPXZRw3tknfZCUXbckV4BTGrnI1jWYRjh4S Ji1G3F1viAaxw6gEeaIBemofWjG1J8mclOk1Jj967mRyw2OtlC8ypx486fEkReobzR zj1Z+8vaRA90SeJtTifAo2ayloAa9BLD/4rmc+5lf+zjC/sUtscJhSK6GRRbCRNmaS h+BVbs9hNNW2vVc3e3rqz66jOrXcUgKLKt64txjYehlQ/YzvPaAYUrgycWa2MfehZD pMiqb6Ve22byg== From: cel@kernel.org To: Cc: Chuck Lever Subject: [PATCH v2 02/12] update_ssh_config: Use {{ sshconfig }} instead of raw path Date: Wed, 5 Feb 2025 10:52:42 -0500 Message-ID: <20250205155252.1317763-3-cel@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250205155252.1317763-1-cel@kernel.org> References: <20250205155252.1317763-1-cel@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever 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 --- .../roles/update_ssh_config/tasks/main.yml | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) 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 }}"