diff mbox series

[v2,03/12] update_ssh_config: Fix ansible-lint nits

Message ID 20250205155252.1317763-4-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>

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 <chuck.lever@oracle.com>
---
 .../roles/update_ssh_config/tasks/main.yml    | 32 +++++++++----------
 1 file changed, 16 insertions(+), 16 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 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_*