From patchwork Wed Feb 5 15:52:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13961408 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 9312F18FDA5 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=uIB9cggBMq0l0jKfHbCCcyokVYQVh1rwYiWadTrdWP/yQ6b7Jr+FYljP7Ea8Yj+W8YV0Lk40Kyq143oZ4PSdjkFReRtx1ZlnKjHbpjLCx73d+Cw/kF2pp7crhLFxY0Achgqo4CLCFbpw0b0W6fPuy6VW/Ld2JT7S9tqF1jyEdqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738770776; c=relaxed/simple; bh=Rm6i1W27PhO18122HmKFeAfjFYIof0eiQ5stGiogyZs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L4B/B4RBHeDcXa8AJ+awg/3ROjX3bKjYQBCLFbLvtUogFJtHab57Nzd41CbzvsSW9dsSiVgNWXQxGmoSg7MLXGbzWQV8HQuDTFFrak9sNUzDD0tGVbicKgXGmqKwpKrvQ4tJFMZiAxdYKlLiefcKGULaw+mFlC9XJjRXUyYJCmk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oWMis2A7; 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="oWMis2A7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31AFFC4CEDD; Wed, 5 Feb 2025 15:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738770776; bh=Rm6i1W27PhO18122HmKFeAfjFYIof0eiQ5stGiogyZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oWMis2A7q5PvnTN3UPTACbPYyV9HJESwNPraYQZT+oz49lIy5ER87mc4xHF+UpmfG l7n/krnQOI04Gt1gHPwcHBsDyRz/+2CzNbSTv0v1amZqF1I8az1RclZ01htxyX6Jp5 aw9pGayQ8Kc5vSxQsfLZ7f2pvODsyXJhvjuAGqRhqiYoH9hP8Z+IEFC8/hqNHgVK2L 0l1nIuXpacMwjKtkmIzPRfda9Th9HtBvW6GHdoId7REZ4giB2zj6N2O1uFdyrE4h7A QB6sYVbd1S2oJFN1Xq+6AvaaCX+hjQEFTS8czyPjNIVR7ZTc9QZ+nWTEsb9nn0Gk71 hVWOCzqx/gMFA== From: cel@kernel.org To: Cc: Chuck Lever Subject: [PATCH v2 03/12] update_ssh_config: Fix ansible-lint nits Date: Wed, 5 Feb 2025 10:52:43 -0500 Message-ID: <20250205155252.1317763-4-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 ansible-lint called out a few nits: - Use FQDN for module names - Update truthy values to true/false - Add a "mode:" parameter to blockinfile As an additional clean-up, remove comments that more-or-less repeat what is already in the "- name:" of a step. Signed-off-by: Chuck Lever --- .../roles/update_ssh_config/tasks/main.yml | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/playbooks/roles/update_ssh_config/tasks/main.yml b/playbooks/roles/update_ssh_config/tasks/main.yml index 01fac9fbb69e..6a7b58d8a556 100644 --- a/playbooks/roles/update_ssh_config/tasks/main.yml +++ b/playbooks/roles/update_ssh_config/tasks/main.yml @@ -1,26 +1,25 @@ +--- - name: Check that the controller's ssh config file exists - stat: + ansible.builtin.stat: path: "{{ sshconfig }}" register: ssh_config -# Check if the include directive is already presetn -- name: Check if the kdevops include directive was used - lineinfile: +- name: Check that the kdevops Include directive is present + ansible.builtin.lineinfile: path: "{{ sshconfig }}" regexp: "Include ~/.ssh/config_kdevops_*" state: absent - check_mode: yes + check_mode: true changed_when: false register: kdevops_ssh_include when: ssh_config.stat.exists -# 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: +- name: Check that the Include directive has a kdevops_version comment + ansible.builtin.lineinfile: path: "{{ sshconfig }}" regexp: "^#(.*)kdevops_version(.*)" state: absent - check_mode: yes + check_mode: true changed_when: false register: fixed_ssh_entry when: ssh_config.stat.exists @@ -28,28 +27,28 @@ # If both the include directive was found and kdevops version comment was found # we bail right away to avoid updating the ssh config file always. - name: Check if the new fixed include directive was used - meta: end_play + ansible.builtin.meta: end_play when: - ssh_config.stat.exists - kdevops_ssh_include.found - fixed_ssh_entry.found - name: Remove the stale Include directive - lineinfile: + ansible.builtin.lineinfile: path: "{{ sshconfig }}" line: "Include ~/.ssh/config_kdevops_*" state: absent when: ssh_config.stat.exists -- name: Remove any stale kdevops comments - lineinfile: +- name: Remove stale kdevops comments + ansible.builtin.lineinfile: path: "{{ sshconfig }}" regexp: "^#(.*)kdevops(.*)" state: absent when: ssh_config.stat.exists -- name: Remove any extra new lines - replace: +- name: Remove extraneous extra new lines + ansible.builtin.replace: path: "{{ sshconfig }}" regexp: '(^\s*$)' replace: '' @@ -57,12 +56,13 @@ # ssh include directives must follow a new line. - name: Add a proper Include directive to {{ sshconfig }} - blockinfile: + ansible.builtin.blockinfile: path: "{{ sshconfig }}" insertbefore: BOF marker: "{mark}" marker_begin: "# Automatically added by kdevops\n# kdevops_version: {{ kdevops_version }}" marker_end: "" create: true + mode: "u=rw,g=r,o=r" block: | Include ~/.ssh/config_kdevops_*